codea: bug mit addq regel gefixt
[uebersetzerbau-ss10.git] / codea / parser.y
index fa8d988e2beaba4e79e879c48234d8bec38d7fce..d1e6024959281b916d762ca57b342a465139a9e6 100644 (file)
@@ -39,8 +39,8 @@
 @attributes { char *name; } IDENT
 @attributes { long val; } NUM
 @attributes { struct symbol *f; int paramges; int parms; } Parms
-@attributes { struct symbol *f; int soffset; } Program
-@attributes { struct symbol *f; int soffset; int offsetcount; } FeldID Structdef
+@attributes { struct symbol *f; } Program Structdef;
+@attributes { struct symbol *f; int offsetcount; } FeldID
 @attributes { struct symbol *s; } Methoddef
 @attributes { struct symbol *s; int gparamges; } Statseq Exprs
 @attributes { struct symbol *s; int gparamges; struct treenode *node; int exprcount; } Expr Minusterm Multerm Orterm Feld Term
@@ -56,7 +56,6 @@ Input:
          Program
          @{
            @i @Program.f@ = tab_new();
-               @i @Program.soffset@ = 0;
            @gen @revorder(1) printf("\t.text\n");
          @}
        ;
@@ -66,14 +65,11 @@ Program:
          @{
            @i @Methoddef.s@ = @Program.0.f@;
            @i @Program.1.f@ = @Program.0.f@;
-           @i @Program.1.soffset@ = @Program.0.soffset@;
          @}
 
        | Structdef ';' Program
          @{
            @i @Program.1.f@ = tab_merge(@Program.0.f@, @Structdef.f@, 1);
-               @i @Structdef.offsetcount@ = @Program.0.soffset@;
-               @i @Program.1.soffset@ = @Structdef.soffset@;
          @}
        |
        ;
@@ -92,8 +88,7 @@ Structdef:
          STRUCT FeldID END
          @{
            @i @Structdef.f@ = @FeldID.f@;
-               @i @FeldID.offsetcount@ = @Structdef.offsetcount@;
-               @i @Structdef.soffset@ = @FeldID.soffset@;
+               @i @FeldID.offsetcount@ = 0;
          @}
        ;
 
@@ -117,15 +112,12 @@ FeldID:
          IDENT FeldID
          @{
            @i @FeldID.1.offsetcount@ = @FeldID.0.offsetcount@ + 1;
-               @i @FeldID.0.soffset@ = @FeldID.1.soffset@;
-               /* TODO: offset hier verwenden */
            @i @FeldID.0.f@ = tab_add_symbol(@FeldID.1.f@, @IDENT.name@, S_FIELD, 1, -1, @FeldID.0.offsetcount@);
          @}
 
        |
          @{
            @i @FeldID.f@ = tab_new();
-               @i @FeldID.soffset@ = @FeldID.offsetcount@;
          @}
        ;
 
@@ -230,8 +222,10 @@ Expr:
 
        | NOT Term
          @{
-           @i @Expr.node@ = TREENULL;
                @i @Expr.exprcount@ = @Term.exprcount@; fprintf(stderr, "(Expr)- NOT Term\n");
+               @i @Expr.node@ = new_node(O_EQ, @Term.node@, new_node(O_NULL, TREENULL, TREENULL, @Expr.exprcount@), @Expr.exprcount@);
+
+               @reg @Term.node@->reg = @Expr.node@->reg;
          @}
 
        | Term Minusterm