Commit 6e7219f0 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

More tests.

parent eab69a1e
......@@ -13,7 +13,7 @@ type optional_comma =
positions * nothing option
type annotations =
positions * positions * optional_dot * optional_comma
positions * position * position * optional_dot * optional_comma
type raw_expr =
| EInt
......@@ -22,7 +22,7 @@ type raw_expr =
| EUnOp of expr
and expr =
positions * raw_expr
positions * position * int * raw_expr
type main =
positions * nothing * expr
......@@ -35,6 +35,17 @@ let iter f = function
module Print = struct
let position msg pos =
Printf.printf "%s = %s/%03d,\n"
msg
pos.pos_fname
pos.pos_cnum
let offset msg ofs =
Printf.printf "%s = %03d,\n"
msg
ofs
let positions nt (startpos, endpos) =
Printf.printf "%s: startpos = %s/%03d,\n%s: endpos = %s/%03d\n"
nt
......@@ -55,9 +66,10 @@ module Print = struct
positions "optional_comma" poss;
iter nothing no
let annotations (poss1, poss2, odot, ocomma) =
positions "annotations" poss1;
positions "annotations(internal)" poss2;
let annotations (poss, pos1, pos2, odot, ocomma) =
positions "annotations" poss;
position "annotations: $endpos($1)" pos1;
position "annotations: $startpos($2)" pos2;
optional_dot odot;
optional_comma ocomma
......@@ -75,8 +87,10 @@ module Print = struct
| EUnOp e ->
expr e
and expr (poss, e) =
and expr (poss, pos, ofs, e) =
positions "expr" poss;
position "expr: $endpos($0)" pos;
offset "expr: $endofs($0)" ofs;
raw_expr e
let main (poss, n, e) =
......
......@@ -39,7 +39,7 @@ optional_dot:
%inline annotations:
optional_dot optional_comma
{ ($startpos, $endpos),
($endpos($1), $startpos($2)),
$endpos($1), $startpos($2),
$1, $2 }
raw_expr:
......@@ -57,5 +57,5 @@ raw_expr:
%inline expr:
e = raw_expr
{ ($startpos, $endpos), e }
{ ($startpos, $endpos), $endpos($0), $endofs($0), e }
......@@ -46,7 +46,7 @@ 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_end_pos 1, Parsing.rhs_start_pos 2,
$1, $2 }
raw_expr:
......@@ -67,5 +67,5 @@ raw_expr:
expr:
raw_expr
{ (Parsing.rhs_start_pos 1, Parsing.symbol_end_pos()), $1 }
{ (Parsing.rhs_start_pos 1, Parsing.symbol_end_pos()), Parsing.rhs_end_pos 0, Parsing.rhs_end 0, $1 }
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