Commit 4986f5ca authored by POTTIER Francois's avatar POTTIER Francois
Browse files

More complex grammar in quicktest/positions/.

parent a1bc99d2
, (1 + 2 * 10) * 2
. , (1 + 2 * 10) * 2
( . , (1 + 2 * 10) * 2) - . (2)
......@@ -46,6 +46,8 @@ and token = parse
{ RPAREN }
| '.'
{ DOT }
| ','
{ COMMA }
| _
{ raise (Error (Printf.sprintf "At offset %d: unexpected character.\n" (Lexing.lexeme_start lexbuf))) }
......@@ -2,7 +2,7 @@
%token PLUS MINUS TIMES DIV
%token LPAREN RPAREN
%token EOL
%token DOT
%token DOT COMMA
%left PLUS MINUS /* lowest precedence */
%left TIMES DIV /* medium precedence */
......@@ -27,12 +27,21 @@ optional_dot:
| DOT
{ Aux.print "optional_dot" $startpos $endpos}
optional_comma:
| nothing
| COMMA
{ Aux.print "optional_comma" $startpos $endpos}
annotations:
optional_dot optional_comma
{ Aux.print "annotations" $startpos $endpos }
%inline operator:
PLUS | MINUS | TIMES | DIV {}
raw_expr:
| INT
| optional_dot LPAREN nothing expr RPAREN optional_dot
| annotations LPAREN nothing expr RPAREN optional_dot
| expr operator expr
| MINUS expr %prec UMINUS
{}
......
......@@ -2,7 +2,7 @@
%token PLUS MINUS TIMES DIV
%token LPAREN RPAREN
%token EOL
%token DOT
%token DOT COMMA
%left PLUS MINUS /* lowest precedence */
%left TIMES DIV /* medium precedence */
......@@ -29,10 +29,20 @@ optional_dot:
| DOT
{ Aux.print "optional_dot" (Parsing.symbol_start_pos()) (Parsing.symbol_end_pos())}
optional_comma:
| nothing
{ Aux.print "optional_comma" (Parsing.symbol_start_pos()) (Parsing.symbol_end_pos())}
| COMMA
{ Aux.print "optional_comma" (Parsing.symbol_start_pos()) (Parsing.symbol_end_pos())}
annotations:
optional_dot optional_comma
{ Aux.print "annotations" (Parsing.symbol_start_pos()) (Parsing.symbol_end_pos())}
raw_expr:
| INT
{}
| optional_dot LPAREN nothing expr RPAREN optional_dot
| annotations LPAREN nothing expr RPAREN optional_dot
{}
| expr PLUS expr
{}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment