Skip to content

Commit

Permalink
syntax-p5: seperate if rule, allow ws before if block
Browse files Browse the repository at this point in the history
  • Loading branch information
Reini Urban committed Apr 10, 2013
1 parent 971491f commit c9b5cf8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions syn/syntax-p5.g
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,19 @@ statements =
(sep s2:stmt { $$ = s1 = PN_PUSH(s1, s2); })* sep?
| '' { $$ = PN_NIL; }

stmt =
"package" - arg-name ';' {} # TODO: set namespace
| "if" e:ifexpr s:block { s = PN_OP(AST_AND, e, s); }
| "if" e:ifexpr s1:block { s1 = PN_AST(MESSAGE, PN_if); }
('elsif' e1:ifexpr f:block )* { f = PN_AST(MESSAGE, PN_elsif); }
('else' s2:block )? { s2 = PN_AST(MESSAGE, PN_else); }
stmt = "package" - arg-name ';' {} # TODO: set namespace
| if
| s:sets ';'
( or x:sets ';' { s = PN_OP(AST_OR, s, x); }
| and x:sets ';' { s = PN_OP(AST_AND, s, x); })*
{ $$ = s; }
| expr

if = "if" e:ifexpr - s:block { s = PN_OP(AST_AND, e, s); }
| "if" e:ifexpr - s1:block { s1 = PN_AST(MESSAGE, PN_if); }
('elsif' e1:ifexpr - f:block )* { f = PN_AST(MESSAGE, PN_elsif); }
('else' - s2:block )? { s2 = PN_AST(MESSAGE, PN_else); }

ifexpr = - '(' - expr - ')'

sets = e:eqs
Expand Down

0 comments on commit c9b5cf8

Please sign in to comment.