Browse Source

Added some test files

develop-theo
Theo Souchon 2 years ago
parent
commit
14b31fe6f0
5 changed files with 53 additions and 10 deletions
  1. +19
    -9
      ccmeta.leg
  2. +1
    -1
      tests-parsimony/002.c
  3. +22
    -0
      tests-parsimony/004.c
  4. +5
    -0
      tests-parsimony/err_001.c
  5. +6
    -0
      tests-parsimony/err_002.c

+ 19
- 9
ccmeta.leg View File

@ -1295,6 +1295,10 @@ typedef enum {
language lang = C, printLang = C;
int getProtoNumber(oop obj) {
return get(map_get(map_get(obj, __proto___symbol), __name___symbol), Symbol, prototype);
}
%}
@ -1443,6 +1447,7 @@ primaryExpression = stringLiteral | constant | id
| META_AT ( META_LCB x:mstmt { $$ = eval(globals, x) }
| META_OPERATORS META_LPAREN x:mexp { $$ = eval(globals, x) }
| META_LPAREN x:mexp { $$ = eval(globals, x) }
| META_COMMA x:mcomma { $$ = eval(globals, x) }
)
| l:LPAREN x:expression r:RPAREN { $$= new_C_subexpr(l, x, r) }
| l:LPAREN x:compoundStatement r:RPAREN &{gnu} { $$= new_C_subexpr(l, x, r) }
@ -2154,8 +2159,8 @@ _FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float1
metaCatch = META_AT @{ lang= META } ( META_OPERATORS META_LPAREN m:mexp { eval(globals, m) }
| META_LPAREN m:mexp { eval(globals, m) }
| META_LCB m:mstmt
| META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) }
| META_LCB - (s:meta_stmt { eval(globals, s) })* META_RCB { lang = C }
)
@ -2163,7 +2168,10 @@ metaCatch = META_AT @{ lang= META } ( META_OPERATORS META_LPAREN m:mexp
mexp = @{ lang = META } s:meta_exp META_RPAREN @{ lang = C } { $$= s }
| @{ lang = C } &{ 0 }
mstmt = @{ lang = META } - (s:meta_stmt { eval(globals, s) })* META_RCB { lang = C; $$ = s } # The last one must be a C operator
mcomma = @{ lang = META } s:meta_exp @{ lang = C } { $$= s }
| @{ lang = C } &{ 0 }
mstmt = @{ lang = META } - (s:meta_stmt { eval(globals, s) })* META_RCB { lang = C }
| @{ lang = C } &{ 0 }
meta_stmt = s:meta_block { $$ = s }
@ -2293,9 +2301,10 @@ meta_prefix = META_PLUS n:meta_prefix { $$= n }
| META_PLING n:meta_prefix { $$= newUnary(Not_proto, n) }
| META_PLUSPLUS n:meta_prefix { $$= newPreIncrement(n) }
| META_MINUSMINUS n:meta_prefix { $$= newPreDecrement(n) }
| META_BACKTICK META_INITIALIZER i:initializer { $$ = newUnary(Quote_proto ,i) }
| META_BACKTICK META_CONSTANT c:constant { $$ = newUnary(Quote_proto ,c) }
| META_BACKTICK META_STATEMENT c:statement { $$ = newUnary(Quote_proto ,c) }
| META_BACKTICK MO_INITIALIZER i:initializer { $$ = newUnary(Quote_proto ,i) }
| META_BACKTICK MO_CONSTANT c:constant { $$ = newUnary(Quote_proto ,c) }
| META_BACKTICK MO_STATEMENT c:statement { $$ = newUnary(Quote_proto ,c) }
| META_BACKTICK MO_INTEGER i:integerConstant { $$ = newUnary(Quote_proto ,i) }
# | META_BACKTICK n:meta_prefix { $$ = newUnary(Quasiquote_proto, n) }
# | META_AT n:meta_prefix { $$ = newUnary(Unquote_proto, n) }
| n:meta_postfix { $$= n }
@ -2384,11 +2393,12 @@ META_FLOAT = < [-+]* [0-9]+ '.' [0-9]* ('e'[-+]*[0-9]+)? > - { $$ = ma
###### META operators ######
META_OPERATORS = META_INITIALIZER | META_CONSTANT | META_STATEMENT
META_OPERATORS = MO_INITIALIZER | MO_CONSTANT | MO_STATEMENT | MO_INTEGER
META_INITIALIZER = 'initializer' ![(a-zA-Z0-9_] -
META_CONSTANT = 'constant' ![(a-zA-Z0-9_] -
META_STATEMENT = 'statement' ![(a-zA-Z0-9_] -
MO_INITIALIZER = 'initializer' ![(a-zA-Z0-9_] -
MO_CONSTANT = 'constant' ![(a-zA-Z0-9_] -
MO_STATEMENT = 'statement' ![(a-zA-Z0-9_] -
MO_INTEGER = 'integer' ![(a-zA-Z0-9_] -
############################

+ 1
- 1
tests-parsimony/002.c View File

@ -1,6 +1,6 @@
@{
saved = `initializer (1,2,"stringy thingy",21<<1);
cons = `constant 2;
cons = `constant 2;
}
@(a = `constant 10)

+ 22
- 0
tests-parsimony/004.c View File

@ -0,0 +1,22 @@
@{
num = `integer 21;
// print(num.text);
// print("\n");
test = `initializer 2 * 10;
}
int x = @{`initializer 2 * @,num;};
int main() {
int i = @(`initializer 2 * @,num);
int y = @,test;
int a = @{
num = `integer 21;
test = 2;
`initializer @(num);
};
return 0;
}

+ 5
- 0
tests-parsimony/err_001.c View File

@ -0,0 +1,5 @@
@{
num = `integer 21;
test = 2;
`initializer @(num);
}

+ 6
- 0
tests-parsimony/err_002.c View File

@ -0,0 +1,6 @@
@{
num = `integer 21;
test = `initializer 2 * @,num;
}
int x = @{`initializer 2 * @,num;};

Loading…
Cancel
Save