Commit 113c75be authored by Meyer Olivier's avatar Meyer Olivier

Modifs de Pascal sur le parser

parent 48262cd3
......@@ -10,12 +10,12 @@
%token INIT ITER
%token TRANSLATION ROTATION
%token COMMA SEMICOLON
%token BEGIN END
%token BEGIN END
%token OR
%token LPAREN RPAREN
%token EOF
(*
%token DEF IF ELSE
%token DEF IF ELSE
%token PLUS MINUS TIMES DIV
%token REPEAT PENUP PENDOWN FORWARD TURNLEFT TURNRIGHT
%token COLOR BLACK WHITE RED GREEN BLUE
......@@ -25,6 +25,9 @@
Tokens priorities and associativities
*/
%nonassoc OR
%nonassoc ITER
%nonassoc FLOAT
(*
%left MINUS PLUS
%left TIMES DIV
......@@ -33,13 +36,13 @@
%nonassoc ELSE
*)
/*
Grammar entry point
/*
Grammar entry point
*/
%start program
/*
/*
Value types returned by the parser
*/
......@@ -48,7 +51,7 @@
%%
program:
| INIT LPAREN xmin = FLOAT COMMA xmax = FLOAT COMMA ymin = FLOAT COMMA ymax = FLOAT RPAREN s = stmt EOF
| INIT LPAREN xmin = FLOAT COMMA xmax = FLOAT COMMA ymin = FLOAT COMMA ymax = FLOAT RPAREN s = stmt EOF
{
((xmin, xmax, ymin, ymax), s)
}
......@@ -58,9 +61,9 @@ stmt:
{ Translation (x, y) }
| ROTATION LPAREN x = FLOAT COMMA y = FLOAT COMMA theta = FLOAT RPAREN SEMICOLON
{ Rotation (x, y, theta) }
| BEGIN s1 = stmt OR LPAREN weight = FLOAT RPAREN s2 = stmt END
| s1 = stmt OR weight = FLOAT s2 = stmt
{ Or (s1, s2, weight) }
| ITER LPAREN it1 = INT COMMA it2 = INT RPAREN BEGIN s = stmt END
| ITER LPAREN it1 = INT COMMA it2 = INT RPAREN s = stmt %prec ITER
{ Iter (s, it1, it2) }
| BEGIN stmtList = stmt* END
{ StmtList stmtList }
......
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