diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/generator.c | 2 | ||||
-rw-r--r-- | src/tpc.y | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/generator.c b/src/generator.c index 1dfe8f3..bb95e08 100644 --- a/src/generator.c +++ b/src/generator.c | |||
@@ -456,7 +456,7 @@ int gen_value(const char ident[], Scope scope) { | |||
456 | 456 | ||
457 | case GLOBAL: | 457 | case GLOBAL: |
458 | if (is_read_only(ident, scope)) | 458 | if (is_read_only(ident, scope)) |
459 | fprintf(output, "push QWORD %s\n", ident); | 459 | fprintf(output, "push QWORD [%s]\n", ident); |
460 | else | 460 | else |
461 | fprintf(output, "push QWORD [globals + %d] ;%s\n", glo_get_addr(ident), | 461 | fprintf(output, "push QWORD [globals + %d] ;%s\n", glo_get_addr(ident), |
462 | ident); | 462 | ident); |
@@ -27,6 +27,7 @@ static int num_while = 0; | |||
27 | static int nb_param[255]; | 27 | static int nb_param[255]; |
28 | static int num_scope = -1; | 28 | static int num_scope = -1; |
29 | static char fname[64]; | 29 | static char fname[64]; |
30 | static Type type; | ||
30 | %} | 31 | %} |
31 | 32 | ||
32 | %union { | 33 | %union { |
@@ -75,15 +76,15 @@ NombreSigne: | |||
75 | | ADDSUB NUM { $<num>$ = $<addsub>1 == '-' ? - $<num>2 : $<num>2; } | 76 | | ADDSUB NUM { $<num>$ = $<addsub>1 == '-' ? - $<num>2 : $<num>2; } |
76 | ; | 77 | ; |
77 | DeclVars: | 78 | DeclVars: |
78 | DeclVars TYPE Declarateurs ';' | 79 | DeclVars TYPE Declarateurs ';' {type = $<type>2;} |
79 | | | 80 | | |
80 | ; | 81 | ; |
81 | Declarateurs: | 82 | Declarateurs: |
82 | Declarateurs ',' Declarateur | 83 | Declarateurs ',' Declarateur |
83 | | Declarateur | 84 | | Declarateur |
84 | ; | 85 | ; |
85 | Declarateur: | 86 | Declarateur: |
86 | IDENT { gen_declaration($<ident>1, $<type>0, scope);} | 87 | IDENT { gen_declaration($<ident>1, type, scope);} |
87 | | IDENT '[' NUM ']' { gen_tab_declaration($<ident>1, scope, $<num>3);} | 88 | | IDENT '[' NUM ']' { gen_tab_declaration($<ident>1, scope, $<num>3);} |
88 | ; | 89 | ; |
89 | DeclFoncts: | 90 | DeclFoncts: |