Преглед на файлове

Added the ability to return more things in one language exchange

develop-theo
Theo Souchon преди 2 години
родител
ревизия
55869205aa
променени са 7 файла, в които са добавени 142 реда и са изтрити 90 реда
  1. +86
    -67
      ccmeta.leg
  2. +5
    -5
      tests-parsimony/003.c
  3. +7
    -5
      tests-parsimony/004.c
  4. +16
    -0
      tests-parsimony/005.c
  5. +0
    -5
      tests-parsimony/err_001.c
  6. +0
    -8
      tests-parsimony/err_002.c
  7. +28
    -0
      tests-parsimony/tmp.c

+ 86
- 67
ccmeta.leg Целия файл

@ -1299,6 +1299,21 @@ int getProtoNumber(oop obj) {
return get(map_get(map_get(obj, __proto___symbol), __name___symbol), Symbol, prototype); return get(map_get(map_get(obj, __proto___symbol), __name___symbol), Symbol, prototype);
} }
int isReturnable(oop obj, oop obj2) {
printf("%i", getProtoNumber(obj));
if (getType(obj) == 6 && (getProtoNumber(obj) < 8 || getProtoNumber(obj) > 13) ) {
return 0;
}
if (getType(obj2) != 6)
return 0;
int objNB = getProtoNumber(obj2);
if (objNB <= 65)
return 0;
return 1;
}
oop outputProgram= 0;
%} %}
@ -1444,8 +1459,7 @@ sCharSequence = ( escapeSequence | !EOL [^\"\\] )* #"
# 6.5.1 # 6.5.1
primaryExpression = stringLiteral | constant | id primaryExpression = stringLiteral | constant | id
| META_AT ( META_LCB x:mstmts { $$ = eval(globals, x) }
| META_OPERATORS META_LPAREN x:mvalue { $$ = eval(globals, x) }
| META_AT ( META_LCB x:mstmts { $$ = x }
| x:mvalue { $$ = eval(globals, x) } | x:mvalue { $$ = eval(globals, x) }
) )
| l:LPAREN x:expression r:RPAREN { $$= new_C_subexpr(l, x, r) } | l:LPAREN x:expression r:RPAREN { $$= new_C_subexpr(l, x, r) }
@ -1602,8 +1616,7 @@ declaration = @{ C_declarationBegin() }
d:initDeclaratorListOpt d:initDeclaratorListOpt
t:SEMI { $$= new_C_declaration(s, d, t) } t:SEMI { $$= new_C_declaration(s, d, t) }
@{ C_declarationEnd() } @{ C_declarationEnd() }
|
&{ C_declarationAbort() }
| &{ C_declarationAbort() }
) )
declarationSpecifiers = @{ int specified= 0 } { listBegin() } declarationSpecifiers = @{ int specified= 0 } { listBegin() }
@ -1935,7 +1948,7 @@ functionDefinition = @{ C_declarationBegin() }
l:declarationListOpt l:declarationListOpt
c:compoundStatement { $$= new_C_functionDef(s, d, l, c) } c:compoundStatement { $$= new_C_functionDef(s, d, l, c) }
@{ C_declarationEnd() } @{ C_declarationEnd() }
| &{ C_declarationAbort() }
| &{ C_declarationAbort() }
functionDeclarationSpecifiers = @{ int specified= 0 } { listBegin() } functionDeclarationSpecifiers = @{ int specified= 0 } { listBegin() }
( s:functionStorageClassSpecifier { listAppend(s) } ( s:functionStorageClassSpecifier { listAppend(s) }
@ -2094,22 +2107,22 @@ BXOR = '^' !'=' { $$= newToken("^" ) } -
BXOR_ASSIGN = "^=" { $$= newToken("^=" ) } - BXOR_ASSIGN = "^=" { $$= newToken("^=" ) } -
ALIGNOF = '__alignof__' !IDREST { $$= newToken("__alignof__" ) } - ALIGNOF = '__alignof__' !IDREST { $$= newToken("__alignof__" ) } -
| '__alignof' !IDREST { $$= newToken("__alignof" ) } -
| '__alignof' !IDREST { $$= newToken("__alignof" ) } -
ASM = 'asm' !IDREST { $$= newToken("asm" ) } -
ASM = 'asm' !IDREST { $$= newToken("asm" ) } -
| '__asm' !IDREST { $$= newToken("__asm" ) } - | '__asm' !IDREST { $$= newToken("__asm" ) } -
| '__asm__' !IDREST { $$= newToken("__asm__" ) } - | '__asm__' !IDREST { $$= newToken("__asm__" ) } -
ATTRIBUTE = '__attribute__' !IDREST { $$= newToken("__attribute__") } -
ATTRIBUTE = '__attribute__' !IDREST { $$= newToken("__attribute__") } -
AUTO = 'auto' !IDREST { $$= newToken("auto" ) } - AUTO = 'auto' !IDREST { $$= newToken("auto" ) } -
BOOL = '_Bool' !IDREST { $$= newToken("_Bool" ) } - BOOL = '_Bool' !IDREST { $$= newToken("_Bool" ) } -
BREAK = 'break' !IDREST { $$= newToken("break" ) } - BREAK = 'break' !IDREST { $$= newToken("break" ) } -
CASE = 'case' !IDREST { $$= newToken("case" ) } - CASE = 'case' !IDREST { $$= newToken("case" ) } -
CHAR = 'char' !IDREST { $$= newToken("char" ) } - CHAR = 'char' !IDREST { $$= newToken("char" ) } -
COMPLEX = '_Complex' !IDREST { $$= newToken("_Complex" ) } - COMPLEX = '_Complex' !IDREST { $$= newToken("_Complex" ) } -
| '__complex__' !IDREST &{gnu} { $$= newToken("__complex__" ) } -
| '__complex__' !IDREST &{gnu} { $$= newToken("__complex__" ) } -
CONST = 'const' !IDREST { $$= newToken("const" ) } - CONST = 'const' !IDREST { $$= newToken("const" ) } -
| '__const' !IDREST { $$= newToken("__const" ) } -
| '__const' !IDREST { $$= newToken("__const" ) } -
CONTINUE = 'continue' !IDREST { $$= newToken("continue" ) } - CONTINUE = 'continue' !IDREST { $$= newToken("continue" ) } -
DEFAULT = 'default' !IDREST { $$= newToken("default" ) } - DEFAULT = 'default' !IDREST { $$= newToken("default" ) } -
DO = 'do' !IDREST { $$= newToken("do" ) } - DO = 'do' !IDREST { $$= newToken("do" ) } -
@ -2122,7 +2135,7 @@ FOR = 'for' !IDREST { $$= newToken("for"
GOTO = 'goto' !IDREST { $$= newToken("goto" ) } - GOTO = 'goto' !IDREST { $$= newToken("goto" ) } -
IF = 'if' !IDREST { $$= newToken("if" ) } - IF = 'if' !IDREST { $$= newToken("if" ) } -
INLINE = 'inline' !IDREST { $$= newToken("inline" ) } - INLINE = 'inline' !IDREST { $$= newToken("inline" ) } -
| '__inline__' !IDREST &{gnu} { $$= newToken("__inline__" ) } -
| '__inline__' !IDREST &{gnu} { $$= newToken("__inline__" ) } -
INT = 'int' !IDREST { $$= newToken("int" ) } - INT = 'int' !IDREST { $$= newToken("int" ) } -
LONG = 'long' !IDREST { $$= newToken("long" ) } - LONG = 'long' !IDREST { $$= newToken("long" ) } -
REGISTER = 'register' !IDREST { $$= newToken("register" ) } - REGISTER = 'register' !IDREST { $$= newToken("register" ) } -
@ -2136,7 +2149,7 @@ STRUCT = 'struct' !IDREST { $$= newToken("struct"
SWITCH = 'switch' !IDREST { $$= newToken("switch" ) } - SWITCH = 'switch' !IDREST { $$= newToken("switch" ) } -
TYPEDEF = 'typedef' !IDREST { $$= newToken("typedef" ) } - TYPEDEF = 'typedef' !IDREST { $$= newToken("typedef" ) } -
TYPEOF = 'typeof' !IDREST { $$= newToken("typeof" ) } - TYPEOF = 'typeof' !IDREST { $$= newToken("typeof" ) } -
| '__typeof__' !IDREST { $$= newToken("__typeof__" ) } -
| '__typeof__' !IDREST { $$= newToken("__typeof__" ) } -
UNION = 'union' !IDREST { $$= newToken("union" ) } - UNION = 'union' !IDREST { $$= newToken("union" ) } -
UNSIGNED = 'unsigned' !IDREST { $$= newToken("unsigned" ) } - UNSIGNED = 'unsigned' !IDREST { $$= newToken("unsigned" ) } -
VOID = 'void' !IDREST { $$= newToken("void" ) } - VOID = 'void' !IDREST { $$= newToken("void" ) } -
@ -2157,18 +2170,19 @@ _FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float1
# the semicolon has to be explicit with no space eaten afterwards to prevent the # the semicolon has to be explicit with no space eaten afterwards to prevent the
# input buffer from moving past it before redirecting input from the imported file # input buffer from moving past it before redirecting input from the imported file
metaCatch = META_AT ( META_OPERATORS META_LPAREN m:mvalue { eval(globals, m) }
| META_LPAREN m:mvalue { eval(globals, m) }
| META_LCB m:mstmts
| META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) }
metaCatch = META_AT ( m:mvalue { map_append(outputProgram, eval(globals, m)); }
| META_LCB m:mstmts { map_append(outputProgram, m); }
| META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) }
) )
mvalue = i:META_IDENT { $$ = newGetVariable(i) }
| META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { $$ = i }
mvalue = i:META_IDENT { $$ = newGetVariable(i) }
| META_LPAREN i:MO_OPERATION META_RPAREN { $$ = i }
| META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { eval(globals, i); $$ = null }
mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* META_RCB { $$ = listEnd() }
mstmts = ( s:meta_stmt { eval(globals, s) })* META_RCB
| &{ 0 }
# oop ret = eval(globals, s); if (isReturnable(s, ret)) listAppend(ret)
meta_stmt = s:meta_block { $$ = s } meta_stmt = s:meta_block { $$ = s }
| META_SEMICOLON { $$ = null } | META_SEMICOLON { $$ = null }
@ -2180,6 +2194,7 @@ meta_stmt = s:meta_block
| META_FOR META_LPAREN i:meta_ident META_IN e:meta_exp META_RPAREN s:meta_stmt { $$ = newForIn(i, e, s) } | META_FOR META_LPAREN i:meta_ident META_IN e:meta_exp META_RPAREN s:meta_stmt { $$ = newForIn(i, e, s) }
| META_FOR META_LPAREN i:meta_stmt c:meta_stmt u:meta_exp META_RPAREN s:meta_stmt { $$ = newFor(i, c, u, s) } | META_FOR META_LPAREN i:meta_stmt c:meta_stmt u:meta_exp META_RPAREN s:meta_stmt { $$ = newFor(i, c, u, s) }
| s:meta_switch { $$ = s } | s:meta_switch { $$ = s }
| META_AT m:mvalue { listAppend(eval(globals, m))} #right place ???
| META_RETURN e:meta_exp { $$ = newReturn(e) } | META_RETURN e:meta_exp { $$ = newReturn(e) }
| META_RETURN { $$ = newReturn(null) } | META_RETURN { $$ = newReturn(null) }
| META_BREAK { $$ = newBreak() } | META_BREAK { $$ = newBreak() }
@ -2195,21 +2210,21 @@ meta_block = META_LCB m:meta_makeMap
) ? ) ?
META_RCB { $$ = newBlock(m) } META_RCB { $$ = newBlock(m) }
meta_exp = META_VAR l:meta_ident META_ASSIGN e:meta_exp { $$ = newDeclaration(l, e) }
meta_exp = META_VAR l:meta_ident META_ASSIGN e:meta_exp { $$ = newDeclaration(l, e) }
# | META_SYNTAX l:META_IDENT p:meta_paramList q:META_IDENT e:meta_block { $$ = (map_append(p, q), newFunc(l, p, e, makeInteger(2))) } # | META_SYNTAX l:META_IDENT p:meta_paramList q:META_IDENT e:meta_block { $$ = (map_append(p, q), newFunc(l, p, e, makeInteger(2))) }
# | META_SYNTAX p:meta_paramList q:META_IDENT e:meta_block { $$ = (map_append(p, q), newFunc(null, p, e, makeInteger(2))) } # | META_SYNTAX p:meta_paramList q:META_IDENT e:meta_block { $$ = (map_append(p, q), newFunc(null, p, e, makeInteger(2))) }
# | META_SYNTAX l:META_IDENT p:meta_paramList e:meta_block { $$ = newFunc(l, p, e, makeInteger(1)) } # | META_SYNTAX l:META_IDENT p:meta_paramList e:meta_block { $$ = newFunc(l, p, e, makeInteger(1)) }
# | META_SYNTAX p:meta_paramList e:meta_block { $$ = newFunc(null, p, e, makeInteger(1)) } # | META_SYNTAX p:meta_paramList e:meta_block { $$ = newFunc(null, p, e, makeInteger(1)) }
| l:META_IDENT o:meta_assignOp e:meta_exp { $$ = newAssign(Assign_proto, l, o, e) }
| l:meta_postfix META_DOT i:META_IDENT o:meta_assignOp e:meta_exp { $$ = newSetMap(SetMember_proto, l, i, o, e) }
| l:meta_postfix META_LBRAC i:meta_exp META_RBRAC o:meta_assignOp e:meta_exp { $$ = newSetMap(SetIndex_proto, l, i, o, e) }
| l:meta_syntax2 a:meta_argumentList s:meta_block { $$ = (map_append(a, s), apply(globals, globals, l, a, a)) }
| c:meta_cond { $$ = c }
| l:META_IDENT o:meta_assignOp e:meta_exp { $$ = newAssign(Assign_proto, l, o, e) }
| l:meta_postfix META_DOT i:META_IDENT o:meta_assignOp e:meta_exp { $$ = newSetMap(SetMember_proto, l, i, o, e) }
| l:meta_postfix META_LBRAC i:meta_exp META_RBRAC o:meta_assignOp e:meta_exp { $$ = newSetMap(SetIndex_proto, l, i, o, e) }
| l:meta_syntax2 a:meta_argumentList s:meta_block { $$ = (map_append(a, s), apply(globals, globals, l, a, a)) }
| c:meta_cond { $$ = c }
meta_ident = l:META_IDENT { $$ = l }
# | META_AT n:meta_prefix { $$ = newUnary(Unquote_proto, n) }
meta_ident = l:META_IDENT { $$ = l }
# | META_AT n:meta_prefix { $$ = newUnary(Unquote_proto, n) }
meta_syntax2 = < [a-zA-Z_][a-zA-Z0-9_]* > meta_syntax2 = < [a-zA-Z_][a-zA-Z0-9_]* >
&{ null != getSyntaxId(2, intern(yytext)) } -- { $$ = getSyntaxId(2, intern(yytext)) } &{ null != getSyntaxId(2, intern(yytext)) } -- { $$ = getSyntaxId(2, intern(yytext)) }
@ -2218,54 +2233,54 @@ meta_try = META_TRY t:meta_stmt i:me
( META_CATCH META_LPAREN i:META_IDENT META_RPAREN c:meta_stmt ) ? ( META_CATCH META_LPAREN i:META_IDENT META_RPAREN c:meta_stmt ) ?
( META_FINALLY f:meta_stmt ) ? { $$ = newTry(t, i, c, f) } ( META_FINALLY f:meta_stmt ) ? { $$ = newTry(t, i, c, f) }
meta_null = { $$ = null }
meta_null = { $$ = null }
meta_assignOp = META_ASSIGN { $$= null }
| META_ASSIGNADD { $$= Add_symbol }
| META_ASSIGNSUB { $$= Sub_symbol }
| META_ASSIGNMUL { $$= Mul_symbol }
| META_ASSIGNDIV { $$= Div_symbol }
| META_ASSIGNMOD { $$= Mod_symbol }
| META_ASSIGNBITOR { $$= Bitor_symbol }
| META_ASSIGNBITXOR { $$= Bitxor_symbol }
| META_ASSIGNBITAND { $$= Bitand_symbol }
| META_ASSIGNSHLEFT { $$= Shleft_symbol }
| META_ASSIGNSHRIGHT { $$= Shright_symbol }
meta_assignOp = META_ASSIGN { $$= null }
| META_ASSIGNADD { $$= Add_symbol }
| META_ASSIGNSUB { $$= Sub_symbol }
| META_ASSIGNMUL { $$= Mul_symbol }
| META_ASSIGNDIV { $$= Div_symbol }
| META_ASSIGNMOD { $$= Mod_symbol }
| META_ASSIGNBITOR { $$= Bitor_symbol }
| META_ASSIGNBITXOR { $$= Bitxor_symbol }
| META_ASSIGNBITAND { $$= Bitand_symbol }
| META_ASSIGNSHLEFT { $$= Shleft_symbol }
| META_ASSIGNSHRIGHT { $$= Shright_symbol }
meta_switch = META_SWITCH META_LPAREN e:meta_exp META_RPAREN meta_switch = META_SWITCH META_LPAREN e:meta_exp META_RPAREN
META_LCB statements:meta_makeMap labels:meta_makeMap META_LCB statements:meta_makeMap labels:meta_makeMap
( META_CASE l:meta_exp META_COLON { map_set(labels, eval(globals, l), makeInteger(map_size(statements))) }
| META_DEFAULT META_COLON { map_set(labels, __default___symbol, makeInteger(map_size(statements))) }
| s:meta_stmt { map_append(statements, s) }
( META_CASE l:meta_exp META_COLON { map_set(labels, eval(globals, l), makeInteger(map_size(statements))) }
| META_DEFAULT META_COLON { map_set(labels, __default___symbol, makeInteger(map_size(statements))) }
| s:meta_stmt { map_append(statements, s) }
)* )*
META_RCB { $$= newSwitch(e, labels, statements) }
META_RCB { $$= newSwitch(e, labels, statements) }
meta_cond = c:meta_logor META_QUERY t:meta_exp META_COLON f:meta_cond { $$ = newIf(c, t, f) }
meta_cond = c:meta_logor META_QUERY t:meta_exp META_COLON f:meta_cond { $$ = newIf(c, t, f) }
| meta_logor | meta_logor
meta_logor = l:meta_logand meta_logor = l:meta_logand
( META_LOGOR r:meta_logand { l = newBinary(Logor_proto, l, r) }
( META_LOGOR r:meta_logand { l = newBinary(Logor_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_logand = l:meta_bitor meta_logand = l:meta_bitor
( META_LOGAND r:meta_bitor { l = newBinary(Logand_proto, l, r) }
( META_LOGAND r:meta_bitor { l = newBinary(Logand_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_bitor = l:meta_bitxor meta_bitor = l:meta_bitxor
( META_BITOR r:meta_bitxor { l = newBinary(Bitor_proto, l, r) }
( META_BITOR r:meta_bitxor { l = newBinary(Bitor_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_bitxor = l:meta_bitand meta_bitxor = l:meta_bitand
( META_BITXOR r:meta_bitand { l = newBinary(Bitxor_proto, l, r) }
( META_BITXOR r:meta_bitand { l = newBinary(Bitxor_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_bitand = l:meta_eq meta_bitand = l:meta_eq
( META_BITAND r:meta_eq { l = newBinary(Bitand_proto, l, r) }
( META_BITAND r:meta_eq { l = newBinary(Bitand_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_eq = l:meta_ineq meta_eq = l:meta_ineq
( META_EQUAL r:meta_ineq { l = newBinary(Equal_proto, l, r) }
| META_NOTEQ r:meta_ineq { l = newBinary(Noteq_proto, l, r) }
( META_EQUAL r:meta_ineq { l = newBinary(Equal_proto, l, r) }
| META_NOTEQ r:meta_ineq { l = newBinary(Noteq_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_ineq = l:meta_shift meta_ineq = l:meta_shift
@ -2276,19 +2291,19 @@ meta_ineq = l:meta_shift
)* { $$ = l } )* { $$ = l }
meta_shift = l:meta_sum meta_shift = l:meta_sum
( META_SHLEFT r:meta_sum { l = newBinary(Shleft_proto, l, r) }
| META_SHRIGHT r:meta_sum { l = newBinary(Shright_proto, l, r) }
( META_SHLEFT r:meta_sum { l = newBinary(Shleft_proto, l, r) }
| META_SHRIGHT r:meta_sum { l = newBinary(Shright_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_sum = l:meta_prod meta_sum = l:meta_prod
( META_PLUS r:meta_prod { l = newBinary(Add_proto, l, r) }
| META_MINUS r:meta_prod { l = newBinary(Sub_proto, l, r) }
( META_PLUS r:meta_prod { l = newBinary(Add_proto, l, r) }
| META_MINUS r:meta_prod { l = newBinary(Sub_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_prod = l:meta_prefix meta_prod = l:meta_prefix
( META_MULTI r:meta_prefix { l = newBinary(Mul_proto, l, r) }
| META_DIVIDE r:meta_prefix { l = newBinary(Div_proto, l, r) }
| META_MODULO r:meta_prefix { l = newBinary(Mod_proto, l, r) }
( META_MULTI r:meta_prefix { l = newBinary(Mul_proto, l, r) }
| META_DIVIDE r:meta_prefix { l = newBinary(Div_proto, l, r) }
| META_MODULO r:meta_prefix { l = newBinary(Mod_proto, l, r) }
)* { $$ = l } )* { $$ = l }
meta_prefix = META_PLUS n:meta_prefix { $$= n } meta_prefix = META_PLUS n:meta_prefix { $$= n }
@ -2297,15 +2312,12 @@ meta_prefix = META_PLUS n:meta_prefix { $$= n }
| META_PLING n:meta_prefix { $$= newUnary(Not_proto, n) } | META_PLING n:meta_prefix { $$= newUnary(Not_proto, n) }
| META_PLUSPLUS n:meta_prefix { $$= newPreIncrement(n) } | META_PLUSPLUS n:meta_prefix { $$= newPreIncrement(n) }
| META_MINUSMINUS n:meta_prefix { $$= newPreDecrement(n) } | META_MINUSMINUS n:meta_prefix { $$= newPreDecrement(n) }
| 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) }
| m:MO_OPERATION { $$= m }
# | META_BACKTICK n:meta_prefix { $$ = newUnary(Quasiquote_proto, n) } # | META_BACKTICK n:meta_prefix { $$ = newUnary(Quasiquote_proto, n) }
# | META_AT n:meta_prefix { $$ = newUnary(Unquote_proto, n) } # | META_AT n:meta_prefix { $$ = newUnary(Unquote_proto, n) }
| n:meta_postfix { $$= n } | n:meta_postfix { $$= n }
meta_postfix = i:meta_value
meta_postfix = i:meta_value
( META_DOT s:META_IDENT a:meta_argumentList { i = newInvoke(i, s, a) } ( META_DOT s:META_IDENT a:meta_argumentList { i = newInvoke(i, s, a) }
| META_DOT s:META_IDENT !meta_assignOp { i = newGetMap(GetMember_proto, i, s) } | META_DOT s:META_IDENT !meta_assignOp { i = newGetMap(GetMember_proto, i, s) }
| META_LBRAC p:meta_exp META_RBRAC !meta_assignOp { i = newGetMap(GetIndex_proto, i, p) } | META_LBRAC p:meta_exp META_RBRAC !meta_assignOp { i = newGetMap(GetIndex_proto, i, p) }
@ -2389,12 +2401,20 @@ META_FLOAT = < [-+]* [0-9]+ '.' [0-9]* ('e'[-+]*[0-9]+)? > { $$ = mak
###### META operators ###### ###### META operators ######
META_OPERATORS = MO_INITIALIZER | MO_CONSTANT | MO_STATEMENT | MO_INTEGER
MO_OPERATION = META_BACKTICK ( MO_INITIALIZER i:initializer { $$ = newUnary(Quote_proto ,i) }
| MO_CONSTANT c:constant { $$ = newUnary(Quote_proto ,c) }
| MO_STATEMENT c:statement { $$ = newUnary(Quote_proto ,c) }
| MO_INTEGER i:integerConstant { $$ = newUnary(Quote_proto ,i) }
| MO_DECLARATION i:declaration { $$ = newUnary(Quote_proto ,i) }
)
META_OPERATORS = MO_INITIALIZER | MO_CONSTANT | MO_STATEMENT | MO_INTEGER | MO_DECLARATION
MO_INITIALIZER = 'initializer' ![(a-zA-Z0-9_] -- MO_INITIALIZER = 'initializer' ![(a-zA-Z0-9_] --
MO_CONSTANT = 'constant' ![(a-zA-Z0-9_] -- MO_CONSTANT = 'constant' ![(a-zA-Z0-9_] --
MO_STATEMENT = 'statement' ![(a-zA-Z0-9_] -- MO_STATEMENT = 'statement' ![(a-zA-Z0-9_] --
MO_INTEGER = 'integer' ![(a-zA-Z0-9_] --
MO_INTEGER = 'integer' ![(a-zA-Z0-9_] --
MO_DECLARATION = 'declaration' ![(a-zA-Z0-9_] --
############################ ############################
@ -3500,7 +3520,6 @@ oop evalArgs(oop scope, oop args)
} }
oop AST= NULL; oop AST= NULL;
oop outputProgram= 0;
void outputNode(oop node); void outputNode(oop node);
void printTree(oop element, language id); void printTree(oop element, language id);

+ 5
- 5
tests-parsimony/003.c Целия файл

@ -1,12 +1,12 @@
@{ @{
nTimes = `constant 10; nTimes = `constant 10;
forLoop = `statement for (int i = 0; i < 10; ++i) printf("%d\n", i); ;
forLoop = (`statement for (int i = 0; i < 10; ++i) printf("%d\n", i); class="p">);
whileLoop = `statement while (i < 10) { printf("%d\n", i); ++il; }; whileLoop = `statement while (i < 10) { printf("%d\n", i); ++il; };
useForLoop = 1; useForLoop = 1;
x = null; x = null;
} }
@{forLoop = `statement for (int i = 0; i < 10; ++i) printf("%d\n", i);;}
@{forLoop = `statement for (int i = 0; i < 10; ++i) printf("%d\n", i);;}
@{ @{
if (useForLoop) { if (useForLoop) {
@ -18,7 +18,7 @@
int main() int main()
{ {
@(x);
@x;
@(`statement for (int i = 0; i < @(nTimes); ++i) printf("%d\n", i);); @(`statement for (int i = 0; i < @(nTimes); ++i) printf("%d\n", i););
@ -32,9 +32,9 @@ int main()
@{ @{
useForLoop = 0; useForLoop = 0;
if (useForLoop) { if (useForLoop) {
forLoop;
@forLoop;
} else { } else {
whileLoop;
@whileLoop;
} }
}; };

+ 7
- 5
tests-parsimony/004.c Целия файл

@ -6,17 +6,19 @@
} }
int x = @{`initializer 2 * @(num);};
int x = @{
@(`initializer 2 * @num);
};
int main() { int main() {
int i = @(`initializer 2 * @num); int i = @(`initializer 2 * @num);
int y = @test; int y = @test;
int a = @{ int a = @{
num = `integer 21;
test = 2;
`initializer @(num);
};
num = `integer 21;
test = 2;
@(`initializer @num);
};
return 0; return 0;
} }

+ 16
- 0
tests-parsimony/005.c Целия файл

@ -0,0 +1,16 @@
@{
@(`declaration int a = 5;);
@(`declaration int b = 2;);
}
int main() {
@{
a = (`declaration int a = 2;);
@(`declaration int c = 5;);
b = 5;
@(`declaration int d = 2;);
@(`statement for(int i =0; i < 10; i++) {
a = 2;
});
};
}

+ 0
- 5
tests-parsimony/err_001.c Целия файл

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

+ 0
- 8
tests-parsimony/err_002.c Целия файл

@ -1,8 +0,0 @@
@{
num = `integer 21;
t = `initializer 2 * @(num);
}
int x = @{t;};

+ 28
- 0
tests-parsimony/tmp.c Целия файл

@ -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;
}

Зареждане…
Отказ
Запис