aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam NAILI2018-06-06 02:14:35 +0200
committerAdam NAILI2018-06-06 02:14:35 +0200
commit7ab0b07d8224280330320238c45889c460cd0bda (patch)
tree93695a064ffdfabe1d113d5f5ebb77addbb775b2 /src
parentd9f0d3f59f39f7787b0aa41a8e2e82244bad9d37 (diff)
downloadtpc-compiler-7ab0b07d8224280330320238c45889c460cd0bda.tar.gz
Fix const + fix entier x,y,...
Diffstat (limited to 'src')
-rw-r--r--src/generator.c2
-rw-r--r--src/tpc.y9
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);
diff --git a/src/tpc.y b/src/tpc.y
index ff95f64..50bfa5d 100644
--- a/src/tpc.y
+++ b/src/tpc.y
@@ -27,6 +27,7 @@ static int num_while = 0;
27static int nb_param[255]; 27static int nb_param[255];
28static int num_scope = -1; 28static int num_scope = -1;
29static char fname[64]; 29static char fname[64];
30static 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;
77DeclVars: 78DeclVars:
78 DeclVars TYPE Declarateurs ';' 79 DeclVars TYPE Declarateurs ';' {type = $<type>2;}
79| 80|
80; 81;
81Declarateurs: 82Declarateurs:
82 Declarateurs ',' Declarateur 83 Declarateurs ',' Declarateur
83| Declarateur 84| Declarateur
84; 85;
85Declarateur: 86Declarateur:
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;
89DeclFoncts: 90DeclFoncts: