Parcourir la source

Fix the meta_block error

develop-theo
Theo Souchon il y a 2 ans
Parent
révision
99ed98b99a
3 fichiers modifiés avec 40 ajouts et 22 suppressions
  1. +5
    -5
      ccmeta.leg
  2. +28
    -0
      tests-parsimony/006.c
  3. +7
    -17
      tests-parsimony/tmp.c

+ 5
- 5
ccmeta.leg Voir le fichier

@ -2172,7 +2172,7 @@ _FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float1
# input buffer from moving past it before redirecting input from the imported file
metaCatch = META_AT ( m:mvalue { map_append(outputProgram, eval(globals, m)); }
| m:mexp { eval(globals, m) }
| m:mexp { map_append(outputProgram, m) }
| META_LCB m:mstmts { map_append(outputProgram, m) }
| META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) }
)
@ -2181,9 +2181,9 @@ metaCatch = META_AT ( m:mvalue { map_
mvalue = i:META_IDENT { $$ = newGetVariable(i) }
| META_LPAREN i:MO_OPERATION META_RPAREN { $$ = i }
mexp = META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { $$ = i }
mexp = { listBegin() } META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { $$ = eval(globals, listEnd()) }
mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* META_RCB { $$ = listEnd() }
mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* META_RCB { $$ = listEnd() }
# oop ret = eval(globals, s); if (isReturnable(s, ret)) listAppend(ret)
@ -2207,9 +2207,9 @@ meta_stmt = s:meta_block
| e:meta_exp META_SEMICOLON { $$ = e }
meta_block = META_LCB m:meta_makeMap
( s:meta_stmt { map_append(m, s) }
( s:meta_stmt { eval(globals, s); map_append(m, s) }
) *
( s:meta_exp { map_append(m, s) }
( s:meta_exp { eval(globals, s); map_append(m, s) }
) ?
META_RCB { $$ = newBlock(m) }

+ 28
- 0
tests-parsimony/006.c Voir le fichier

@ -0,0 +1,28 @@
@{
(`declaration int a = 5;);
a = (`declaration int a = 5;);
@(`declaration int a = 5;);
};
@a;
@(t = `integer 2)
@(`declaration int abc = @t;);
int main() {
@a;
int b = 0;
@{
@(`declaration int c = 0;);
x = (`declaration int d = 5;);
@x;
if (1) {
if (1) {
x = (`declaration int d = 5;);
@x;
}
}
};
int e = 0;
return 0;
}

+ 7
- 17
tests-parsimony/tmp.c Voir le fichier

@ -1,28 +1,18 @@
@{
(`declaration int a = 5;);
a = (`declaration int a = 5;);
@(`declaration int a = 5;);
};
@a;
@(t = `integer 2)
@(`declaration int abc = @t;);
int main() {
@a;
int b = 0;
@{
@(`declaration int c = 0;);
@({
@(`declaration int a = 5;);
t = 2;
print(t);
@(`declaration int a = 5;);
x = (`declaration int d = 5;);
@x;
@x;
if (1) {
if (1) {
x = (`declaration int d = 5;);
@x;
}
}
};
int e = 0;
return 0;
});
}

Chargement…
Annuler
Enregistrer