|
@ -30,7 +30,7 @@ |
|
|
_DO(PostDecVariable) _DO(PostDecMember) _DO(PostDecIndex) \ |
|
|
_DO(PostDecVariable) _DO(PostDecMember) _DO(PostDecIndex) \ |
|
|
_DO(GetVariable) _DO(GetMember) _DO(SetMember) _DO(GetIndex) _DO(SetIndex) \ |
|
|
_DO(GetVariable) _DO(GetMember) _DO(SetMember) _DO(GetIndex) _DO(SetIndex) \ |
|
|
_DO(Return) _DO(Break) _DO(Continue) _DO(Throw) _DO(Try) \ |
|
|
_DO(Return) _DO(Break) _DO(Continue) _DO(Throw) _DO(Try) \ |
|
|
_DO(Quote) /* _DO(Quasiquote) _DO(Unquote) */ \ |
|
|
|
|
|
|
|
|
_DO(Quote) _DO(Append) /* _DO(Quasiquote) _DO(Unquote) */ \ |
|
|
DO_C_PROTOS() |
|
|
DO_C_PROTOS() |
|
|
|
|
|
|
|
|
#define META_PROTO_MAX t_Try |
|
|
#define META_PROTO_MAX t_Try |
|
@ -1295,24 +1295,24 @@ typedef enum { |
|
|
|
|
|
|
|
|
language printLang = C; |
|
|
language printLang = C; |
|
|
|
|
|
|
|
|
int getProtoNumber(oop obj) { |
|
|
|
|
|
return get(map_get(map_get(obj, __proto___symbol), __name___symbol), Symbol, prototype); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
oop outputProgram= 0; |
|
|
|
|
|
|
|
|
int isReturnable(oop obj, oop obj2) { |
|
|
|
|
|
printf("%i", getProtoNumber(obj)); |
|
|
|
|
|
if (getType(obj) == 6 && (getProtoNumber(obj) < 8 || getProtoNumber(obj) > 13) ) { |
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
oop mapFunction(oop func, oop args) { |
|
|
|
|
|
println(args); |
|
|
|
|
|
oop mapValue = makeMap(); |
|
|
|
|
|
oop argsObj = eval(globals, args); |
|
|
|
|
|
int size = map_size(argsObj); |
|
|
|
|
|
for(int i = 0; i < size; i++) { |
|
|
|
|
|
oop oopInt = makeInteger(i); |
|
|
|
|
|
oop obj = map_get(map_get(args, value_symbol), oopInt); |
|
|
|
|
|
obj = newCall(func, obj); |
|
|
|
|
|
map_append(mapValue, obj); |
|
|
} |
|
|
} |
|
|
if (getType(obj2) != 6) |
|
|
|
|
|
return 0; |
|
|
|
|
|
int objNB = getProtoNumber(obj2); |
|
|
|
|
|
if (objNB <= 65) |
|
|
|
|
|
return 0; |
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
|
map_set(args, value_symbol, mapValue); |
|
|
|
|
|
println(args); |
|
|
|
|
|
return args; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
oop outputProgram= 0; |
|
|
|
|
|
|
|
|
|
|
|
%} |
|
|
%} |
|
|
|
|
|
|
|
@ -1459,9 +1459,8 @@ sCharSequence = ( escapeSequence | !EOL [^\"\\] )* #" |
|
|
# 6.5.1 |
|
|
# 6.5.1 |
|
|
|
|
|
|
|
|
primaryExpression = stringLiteral | constant | id |
|
|
primaryExpression = stringLiteral | constant | id |
|
|
| META_AT ( META_LCB x:mstmts { $$ = x } |
|
|
|
|
|
| x:mvalue { $$ = eval(globals, x) } |
|
|
|
|
|
| x:mexp { $$ = eval(globals, x) } |
|
|
|
|
|
|
|
|
| META_AT ( META_LCB x:mstmts |
|
|
|
|
|
| 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) } |
|
|
| l:LPAREN x:compoundStatement r:RPAREN &{gnu} { $$= new_C_subexpr(l, x, r) } |
|
|
| l:LPAREN x:compoundStatement r:RPAREN &{gnu} { $$= new_C_subexpr(l, x, r) } |
|
@ -2171,23 +2170,26 @@ _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 ( m:mvalue { map_append(outputProgram, eval(globals, m)); } |
|
|
|
|
|
| m:mexp { map_append(outputProgram, m) } |
|
|
|
|
|
|
|
|
metaCatch = META_AT ( m:mvalue { map_append(outputProgram, m) } |
|
|
| META_LCB m:mstmts { map_append(outputProgram, m) } |
|
|
| META_LCB m:mstmts { map_append(outputProgram, m) } |
|
|
| META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) } |
|
|
| META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) } |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mvalue = i:META_IDENT { $$ = newGetVariable(i) } |
|
|
|
|
|
| META_LPAREN i:MO_OPERATION META_RPAREN { $$ = i } |
|
|
|
|
|
|
|
|
|
|
|
mexp = { listBegin() } META_LPAREN ( i:meta_block | i:meta_exp ) META_RPAREN { $$ = eval(globals, listEnd()) } |
|
|
|
|
|
|
|
|
mvalue = { listBegin() } ( i:META_IDENT { listAppend(eval(globals, newGetVariable(i))) } |
|
|
|
|
|
| META_LPAREN ( i:MO_OPERATION |
|
|
|
|
|
i:meta_block |
|
|
|
|
|
i:meta_exp |
|
|
|
|
|
) META_RPAREN { listAppend(eval(globals, i)) } |
|
|
|
|
|
) { $$ = listEnd() } |
|
|
|
|
|
|
|
|
mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* META_RCB { $$ = listEnd() } |
|
|
|
|
|
|
|
|
|
|
|
# oop ret = eval(globals, s); if (isReturnable(s, ret)) listAppend(ret) |
|
|
|
|
|
|
|
|
mstmts = { listBegin() } ( s:meta_stmt { eval(globals, s) } )* |
|
|
|
|
|
( (META_NIL META_SEMICOLON )? META_RCB { listEnd(); $$ = null } |
|
|
|
|
|
| META_DAT META_SEMICOLON META_RCB { $$ = listEnd() } |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
meta_stmt = s:meta_block { $$ = s } |
|
|
meta_stmt = s:meta_block { $$ = s } |
|
|
|
|
|
| META_DAT META_DOT META_APPEND META_LPAREN s:meta_exp META_RPAREN META_SEMICOLON { $$ = newUnary(Append_proto, s) } |
|
|
| META_SEMICOLON { $$ = null } |
|
|
| META_SEMICOLON { $$ = null } |
|
|
| l:META_IDENT p:meta_paramList e:meta_block { $$ = newFunc(l, p, e, null) } |
|
|
| l:META_IDENT p:meta_paramList e:meta_block { $$ = newFunc(l, p, e, null) } |
|
|
| META_IF META_LPAREN c:meta_exp META_RPAREN t:meta_stmt META_ELSE f:meta_stmt { $$ = newIf(c, t, f ) } |
|
|
| META_IF META_LPAREN c:meta_exp META_RPAREN t:meta_stmt META_ELSE f:meta_stmt { $$ = newIf(c, t, f ) } |
|
@ -2197,7 +2199,6 @@ 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() } |
|
@ -2207,13 +2208,14 @@ meta_stmt = s:meta_block |
|
|
| e:meta_exp META_SEMICOLON { $$ = e } |
|
|
| e:meta_exp META_SEMICOLON { $$ = e } |
|
|
|
|
|
|
|
|
meta_block = META_LCB m:meta_makeMap |
|
|
meta_block = META_LCB m:meta_makeMap |
|
|
( s:meta_stmt { eval(globals, s); map_append(m, s) } |
|
|
|
|
|
|
|
|
( s:meta_stmt { map_append(m, s) } |
|
|
) * |
|
|
) * |
|
|
( s:meta_exp { eval(globals, s); map_append(m, s) } |
|
|
|
|
|
|
|
|
( s:meta_exp { map_append(m, s) } |
|
|
) ? |
|
|
) ? |
|
|
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_FUNCMAP m:meta_funcMap {$$ = m} |
|
|
# | 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)) } |
|
@ -2225,7 +2227,6 @@ meta_exp = META_VAR l:meta_ident META_ASSIGN e:meta_exp |
|
|
| c:meta_cond { $$ = c } |
|
|
| c:meta_cond { $$ = c } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
meta_ident = l:META_IDENT { $$ = l } |
|
|
meta_ident = l:META_IDENT { $$ = l } |
|
|
# | META_AT n:meta_prefix { $$ = newUnary(Unquote_proto, n) } |
|
|
# | META_AT n:meta_prefix { $$ = newUnary(Unquote_proto, n) } |
|
|
|
|
|
|
|
@ -2324,11 +2325,13 @@ 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) } |
|
|
| a:meta_argumentList { i = (null != getSyntax(1, i)) ? apply(globals, globals, getSyntax(1, i), a, i) : newCall(i, a) } |
|
|
|
|
|
|
|
|
| a:meta_argumentList { i = (null != getSyntax(1, i)) ? apply(globals, globals, getSyntax(1, i), a, i) : newCall(i, a); } |
|
|
| META_PLUSPLUS { i = newPostIncrement(i) } |
|
|
| META_PLUSPLUS { i = newPostIncrement(i) } |
|
|
| META_MINUSMINUS { i = newPostDecrement(i) } |
|
|
| META_MINUSMINUS { i = newPostDecrement(i) } |
|
|
) * { $$ = i } |
|
|
) * { $$ = i } |
|
|
|
|
|
|
|
|
|
|
|
meta_funcMap = META_LPAREN i:meta_value META_COMMA e:meta_exp META_RPAREN { mapFunction(i, e) } |
|
|
|
|
|
|
|
|
meta_paramList = META_LPAREN m:meta_makeMap |
|
|
meta_paramList = META_LPAREN m:meta_makeMap |
|
|
( i:META_IDENT { map_append(m, i) } |
|
|
( i:META_IDENT { map_append(m, i) } |
|
|
( META_COMMA i:META_IDENT { map_append(m, i) } |
|
|
( META_COMMA i:META_IDENT { map_append(m, i) } |
|
@ -2384,7 +2387,7 @@ meta_makeMap = { $$ = makeMap() } |
|
|
meta_key = META_IDENT | meta_integer |
|
|
meta_key = META_IDENT | meta_integer |
|
|
|
|
|
|
|
|
meta_keyword = META_SWITCH | META_CASE | META_DEFAULT | META_DO | META_FOR | META_IN | META_WHILE | META_IF | META_ELSE | META_NULL | META_RETURN | META_BREAK | META_CONTINUE |
|
|
meta_keyword = META_SWITCH | META_CASE | META_DEFAULT | META_DO | META_FOR | META_IN | META_WHILE | META_IF | META_ELSE | META_NULL | META_RETURN | META_BREAK | META_CONTINUE |
|
|
| META_THROW | META_TRY | META_CATCH | META_FINALLY |
|
|
|
|
|
|
|
|
| META_THROW | META_TRY | META_CATCH | META_FINALLY | META_NIL |
|
|
# | META_SYNTAX |
|
|
# | META_SYNTAX |
|
|
|
|
|
|
|
|
META_IDENT = !meta_keyword < [a-zA-Z_][a-zA-Z0-9_]* > -- { $$ = intern(yytext) } |
|
|
META_IDENT = !meta_keyword < [a-zA-Z_][a-zA-Z0-9_]* > -- { $$ = intern(yytext) } |
|
@ -2417,11 +2420,16 @@ 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_] -- |
|
|
|
|
|
|
|
|
MO_DECLARATION = 'declaration' ![(a-zA-Z0-9_] -- |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############################ |
|
|
############################ |
|
|
|
|
|
|
|
|
|
|
|
META_NIL = 'nil' ![a-zA-Z0-9_] -- |
|
|
|
|
|
META_FUNCMAP = 'map' ![a-zA-Z0-9_] -- |
|
|
|
|
|
META_DAT = '@@' ![a-zA-Z0-9_] -- |
|
|
|
|
|
META_APPEND = 'append' ![a-zA-Z0-9_] -- |
|
|
|
|
|
|
|
|
#META_FUN = 'fun' ![a-zA-Z0-9_] -- |
|
|
#META_FUN = 'fun' ![a-zA-Z0-9_] -- |
|
|
#META_SYNTAX = 'syntax' ![a-zA-Z0-9_] -- |
|
|
#META_SYNTAX = 'syntax' ![a-zA-Z0-9_] -- |
|
|
META_VAR = 'var' ![a-zA-Z0-9_] -- |
|
|
META_VAR = 'var' ![a-zA-Z0-9_] -- |
|
@ -2886,6 +2894,11 @@ oop eval(oop scope, oop ast) |
|
|
oop obj = map_get(ast, rhs_symbol); |
|
|
oop obj = map_get(ast, rhs_symbol); |
|
|
return obj; |
|
|
return obj; |
|
|
} |
|
|
} |
|
|
|
|
|
case t_Append: { |
|
|
|
|
|
oop obj = eval(scope, map_get(ast, rhs_symbol)); |
|
|
|
|
|
listAppend(obj); |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
#if 0 |
|
|
#if 0 |
|
|
case t_Quasiquote: { |
|
|
case t_Quasiquote: { |
|
|
oop obj = map_get(ast, rhs_symbol); |
|
|
oop obj = map_get(ast, rhs_symbol); |
|
|