diff options
author | pacien | 2018-06-05 22:11:03 +0200 |
---|---|---|
committer | pacien | 2018-06-05 22:11:03 +0200 |
commit | cabbac92126f168124372fc502dbc1fa2313eee3 (patch) | |
tree | fe90de697fe55e4c74b7d905b9b977171b773daa /src/tpc.y | |
parent | 56e31e3b8a1a569f42140547ffda5a91ef451b47 (diff) | |
download | tpc-compiler-cabbac92126f168124372fc502dbc1fa2313eee3.tar.gz |
gen const decl
Diffstat (limited to 'src/tpc.y')
-rw-r--r-- | src/tpc.y | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -54,32 +54,32 @@ static char fname[64]; | |||
54 | %precedence ELSE | 54 | %precedence ELSE |
55 | 55 | ||
56 | %% | 56 | %% |
57 | Prog: { gen_prologue(); } | 57 | Prog: { gen_prologue(); } |
58 | DeclConsts DeclVars DeclFoncts { gen_const_declaration(); } | 58 | DeclConsts DeclVars DeclFoncts { gen_const_declaration(); } |
59 | ; | 59 | ; |
60 | DeclConsts: | 60 | DeclConsts: |
61 | DeclConsts CONST ListConst ';' | 61 | DeclConsts CONST ListConst ';' |
62 | | | 62 | | |
63 | ; | 63 | ; |
64 | ListConst: | 64 | ListConst: |
65 | ListConst ',' IDENT '=' Litteral | 65 | ListConst ',' IDENT '=' Litteral { gen_const($<ident>1, $<num>3, scope); } |
66 | | IDENT '=' Litteral | 66 | | IDENT '=' Litteral { gen_const($<ident>1, $<num>3, scope); } |
67 | ; | 67 | ; |
68 | Litteral: | 68 | Litteral: |
69 | NombreSigne | 69 | NombreSigne { $<num>$ = $<num>1; } |
70 | | CARACTERE | 70 | | CARACTERE { $<num>$ = $<num>1; } |
71 | ; | 71 | ; |
72 | NombreSigne: | 72 | NombreSigne: |
73 | NUM | 73 | NUM { $<num>$ = $<num>1; } |
74 | | ADDSUB NUM | 74 | | ADDSUB NUM { $<num>$ = $<addsub>1 == '-' ? - $<num>2 : $<num>2; } |
75 | ; | 75 | ; |
76 | DeclVars: | 76 | DeclVars: |
77 | DeclVars TYPE Declarateurs ';' | 77 | DeclVars TYPE Declarateurs ';' |
78 | | | 78 | | |
79 | ; | 79 | ; |
80 | Declarateurs: | 80 | Declarateurs: |
81 | Declarateurs ',' Declarateur { gen_declaration($<ident>3, $<type>0, scope); } | 81 | Declarateurs ',' Declarateur { gen_declaration($<ident>3, $<type>0, scope); } |
82 | | Declarateur { gen_declaration($<ident>1, $<type>0, scope); } | 82 | | Declarateur { gen_declaration($<ident>1, $<type>0, scope); } |
83 | ; | 83 | ; |
84 | Declarateur: | 84 | Declarateur: |
85 | IDENT | 85 | IDENT |