diff options
Diffstat (limited to 'src/tpc.y')
-rw-r--r-- | src/tpc.y | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -79,12 +79,12 @@ DeclVars: | |||
79 | | | 79 | | |
80 | ; | 80 | ; |
81 | Declarateurs: | 81 | Declarateurs: |
82 | Declarateurs ',' Declarateur { gen_declaration($<ident>3, $<type>0, scope); } | 82 | Declarateurs ',' Declarateur |
83 | | Declarateur { gen_declaration($<ident>1, $<type>0, scope); } | 83 | | Declarateur |
84 | ; | 84 | ; |
85 | Declarateur: | 85 | Declarateur: |
86 | IDENT | 86 | IDENT { gen_declaration($<ident>1, $<type>0, scope);} |
87 | | IDENT '[' NUM ']' | 87 | | IDENT '[' NUM ']' { gen_tab_declaration($<ident>1, scope, $<num>3);} |
88 | ; | 88 | ; |
89 | DeclFoncts: | 89 | DeclFoncts: |
90 | DeclFoncts DeclFonct | 90 | DeclFoncts DeclFonct |
@@ -133,7 +133,13 @@ IfHandling: { gen_if_start($<num>$ = num_if++); }; | |||
133 | IfEndHandling: { gen_if_end($<num>-3); }; | 133 | IfEndHandling: { gen_if_end($<num>-3); }; |
134 | IfElseEndHandling: { gen_ifelse_end($<num>-5); }; | 134 | IfElseEndHandling: { gen_ifelse_end($<num>-5); }; |
135 | Exp: | 135 | Exp: |
136 | LValue '=' Exp { $$ = gen_assign($<ident>1, scope); } | 136 | LValue '=' Exp { |
137 | if(loc_lookup($<ident>1) != TAB){ | ||
138 | $$ = gen_assign($<ident>1, scope); | ||
139 | }else{ | ||
140 | $$ = gen_assign_tab($<ident>1,scope); | ||
141 | } | ||
142 | } | ||
137 | | EB | 143 | | EB |
138 | ; | 144 | ; |
139 | EB: | 145 | EB: |
@@ -164,7 +170,12 @@ F: | |||
164 | ADDSUB F { $$ = gen_signed_expr($1, $2); } | 170 | ADDSUB F { $$ = gen_signed_expr($1, $2); } |
165 | | '!' F { $$ = gen_negate_expr($2); } | 171 | | '!' F { $$ = gen_negate_expr($2); } |
166 | | '(' Exp ')' { $$ = $2; } | 172 | | '(' Exp ')' { $$ = $2; } |
167 | | LValue { $$ = gen_value($<ident>1, scope); } | 173 | | LValue { if(loc_lookup($<ident>1) != TAB){ |
174 | $$ = gen_value($<ident>1, scope); | ||
175 | }else{ | ||
176 | $$ = gen_value_tab($<ident>1,scope); | ||
177 | } | ||
178 | } | ||
168 | | NUM { $$ = gen_num($1, scope); } | 179 | | NUM { $$ = gen_num($1, scope); } |
169 | | CARACTERE { $$ = gen_char($1, scope); } | 180 | | CARACTERE { $$ = gen_char($1, scope); } |
170 | | IDENT '(' Arguments ')' { $$ = gen_function_call($<ident>1,$<num>3); } | 181 | | IDENT '(' Arguments ')' { $$ = gen_function_call($<ident>1,$<num>3); } |