Commit 103e44ef authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Test [$symbolstartpos] and [$symbolstartofs].

parent ace1333b
. (1 + 2 * , (3 - 4) . )
. (1 + 2 * , (3 - (4+3)) . )
......@@ -13,11 +13,11 @@ type optional_comma =
positions * nothing option
type annotations =
positions * position * position * int * optional_dot * optional_comma
positions * position * position * int * position * optional_dot * optional_comma
type raw_expr =
| EInt
| EParen of annotations * nothing * expr * optional_dot
| EParen of annotations * nothing * expr * optional_dot * int
| EBinOp of expr * expr
| EUnOp of expr
......@@ -66,22 +66,24 @@ module Print = struct
positions "optional_comma" poss;
iter nothing no
let annotations (poss, pos1, pos2, ofs3, odot, ocomma) =
let annotations ((poss, pos1, pos2, ofs3, pos4, odot, ocomma) : annotations) =
positions "annotations" poss;
position "annotations: $endpos($1)" pos1;
position "annotations: $startpos($2)" pos2;
offset "annotations: $startofs" ofs3;
position "annotations: $endpos($1)" pos1;
position "annotations: $startpos($2)" pos2;
offset "annotations: $startofs" ofs3;
position "annotations: $symbolstartpos" pos4;
optional_dot odot;
optional_comma ocomma
let rec raw_expr = function
| EInt ->
()
| EParen (a, n, e, o) ->
| EParen (a, n, e, o, ofs) ->
annotations a;
nothing n;
expr e;
optional_dot o
optional_dot o;
offset "eparen: $symbolstartofs" ofs;
| EBinOp (e1, e2) ->
expr e1;
expr e2
......
......@@ -8,6 +8,7 @@
%left TIMES DIV /* medium precedence */
%nonassoc UMINUS /* highest precedence */
%type<Aux.annotations> annotations
%start<Aux.main> main
%{ open Aux %}
......@@ -39,14 +40,14 @@ optional_dot:
%inline annotations:
optional_dot optional_comma
{ ($startpos, $endpos),
$endpos($1), $startpos($2), $startofs,
$endpos($1), $startpos($2), $startofs, $symbolstartpos,
$1, $2 }
raw_expr:
| INT
{ EInt }
| a = annotations LPAREN n = nothing e = expr RPAREN o = optional_dot
{ EParen(a, n, e, o) }
{ EParen(a, n, e, o, $symbolstartofs) }
| expr PLUS expr
| expr MINUS expr
| expr TIMES expr
......
......@@ -8,6 +8,7 @@
%left TIMES DIV /* medium precedence */
%nonassoc UMINUS /* highest precedence */
%type<Aux.annotations> annotations
%type<Aux.main> main
%start main
......@@ -46,14 +47,14 @@ optional_comma:
annotations:
optional_dot optional_comma
{ (Parsing.rhs_start_pos 1, Parsing.symbol_end_pos()),
Parsing.rhs_end_pos 1, Parsing.rhs_start_pos 2, Parsing.rhs_start 1,
Parsing.rhs_end_pos 1, Parsing.rhs_start_pos 2, Parsing.rhs_start 1, Parsing.symbol_start_pos(),
$1, $2 }
raw_expr:
| INT
{ EInt }
| annotations LPAREN nothing expr RPAREN optional_dot
{ EParen($1, $3, $4, $6) }
{ EParen($1, $3, $4, $6, Parsing.symbol_start()) }
| expr PLUS expr
{ EBinOp ($1, $3) }
| expr MINUS 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