ref: 3d37937626b037cf83716ed201bcc404bc1d69a9
parent: d955c5a9e5827c873670f62fe76bac435e649625
author: Ori Bernstein <[email protected]>
date: Thu Jun 28 17:32:37 EDT 2012
Rearrange gramar. This does two things: It removes a source of ambiguity, and it makes the precedence rules make a bit more sense.
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -383,39 +383,41 @@
| landexpr
;
-landexpr: landexpr Tland castexpr
+landexpr: landexpr Tland cmpexpr
{$$ = mkexpr($1->line, binop($2->type), $1, $3, NULL);}
+ | cmpexpr
+ ;
+
+cmpexpr : cmpexpr cmpop castexpr
+ {$$ = mkexpr($1->line, binop($2->type), $1, $3, NULL);}
| castexpr
;
-castexpr: borexpr Tcast Toparen type Tcparen
+castexpr: unioncons Tcast Toparen type Tcparen
{$$ = mkexpr($1->line, Ocast, $1, NULL);
$$->expr.type = $4;}
- | borexpr
+ | unioncons
;
-borexpr : borexpr Tbor bandexpr
- {$$ = mkexpr($1->line, binop($2->type), $1, $3, NULL);}
- | bandexpr
- ;
-bandexpr: bandexpr Tband cmpexpr
- {$$ = mkexpr($1->line, binop($2->type), $1, $3, NULL);}
- | cmpexpr
- ;
-
-cmpexpr : cmpexpr cmpop unioncons
- {$$ = mkexpr($1->line, binop($2->type), $1, $3, NULL);}
- | unioncons
- ;
-
cmpop : Teq | Tgt | Tlt | Tge | Tle | Tne ;
unioncons
- : Ttick Tident addexpr
+ : Ttick Tident borexpr
{$$ = mkexpr($1->line, Ocons, mkname($2->line, $2->str), $3, NULL);}
| Ttick Tident
{$$ = mkexpr($1->line, Ocons, mkname($2->line, $2->str), NULL);}
+ | borexpr
+ ;
+
+
+borexpr : borexpr Tbor bandexpr
+ {$$ = mkexpr($1->line, binop($2->type), $1, $3, NULL);}
+ | bandexpr
+ ;
+
+bandexpr: bandexpr Tband addexpr
+ {$$ = mkexpr($1->line, binop($2->type), $1, $3, NULL);}
| addexpr
;