codea: orterme
[uebersetzerbau-ss10.git] / codea / parser.y
index 4e460e087d662fbf093802aad1a673039990487c..74fe1f45c551c11f552c8fa83453829907acf621 100644 (file)
@@ -43,8 +43,7 @@
 @attributes { struct symbol *f; } FeldID Structdef Program
 @attributes { struct symbol *s; } Methoddef
 @attributes { struct symbol *s; int gparamges; } Statseq Exprs
-@attributes { struct symbol *s; int gparamges; struct treenode *node; short imm; int exprcount; } Expr Minusterm Term Multerm
-@attributes { struct symbol *s; int gparamges; struct treenode *node; int exprcount; } Orterm
+@attributes { struct symbol *s; int gparamges; struct treenode *node; short imm; int exprcount; } Expr Minusterm Term Multerm Orterm
 @attributes { struct symbol *s; int gparamges; struct treenode *node; } Lexpr Feld
 @attributes { struct symbol *sin; int gparamges; struct symbol *sout; struct treenode *node; } Statement
 
@@ -250,8 +249,16 @@ Expr:
 
        | Term Orterm
          @{
-           @i @Expr.node@ = TREENULL;
                @i @Expr.exprcount@ = @Term.exprcount@ + @Orterm.exprcount@; fprintf(stderr, "(Expr)- Term Orterm\n");
+           @i @Expr.node@ = new_node(O_OR, @Term.node@, @Orterm.node@, @Expr.exprcount@);
+               @i @Expr.imm@ = @Term.imm@ && @Orterm.imm@;
+
+               @reg {
+                       /* TODO */
+                       @Term.node@->reg = @Expr.node@->reg;
+                       @Term.node@->skip = 0;
+                       @Orterm.node@->reg = next_reg(@Term.node@->reg, @Expr.node@->skip, @Expr.gparamges@);
+               }
          @}
 
        | Term '<' Term
@@ -313,15 +320,18 @@ Orterm:
          OR Term Orterm
          @{
                @i @Orterm.0.exprcount@ = @Term.exprcount@ + @Orterm.1.exprcount@; fprintf(stderr, "(Orterm)- - Term Orterm\n");
-               /* TODO */
-               /* TODO: imm */
-           @i @Orterm.node@ = TREENULL;
+           @i @Orterm.node@ = new_node(O_OR, @Orterm.1.node@, @Term.node@, @Orterm.0.exprcount@);
+               @i @Orterm.imm@ = @Term.imm@ && @Orterm.1.imm@;
+
+           @reg {
+                       @Orterm.1.node@->reg = @Orterm.node@->reg;
+                       @Term.node@->reg = next_reg(@Orterm.1.node@->reg, @Orterm.node@->skip, @Orterm.gparamges@);
+               }
          @}
        | OR Term
          @{
                @i @Orterm.exprcount@ = @Term.exprcount@; fprintf(stderr, "(Orterm)- - Term\n");
-               /* TODO */
-           @i @Orterm.node@ = TREENULL;
+           @reg @Term.node@->reg = @Orterm.node@->reg;
          @}
 
        ;