Quellcode durchsuchen

Total independence of parsimony

Add a file containing the order of the _DO
develop-theo
Theo Souchon vor 2 Jahren
Ursprung
Commit
950d511a1a
3 geänderte Dateien mit 147 neuen und 24 gelöschten Zeilen
  1. +15
    -22
      ccmeta.leg
  2. +117
    -0
      protoNumber.txt
  3. +15
    -2
      tests-parsimony/003.c

+ 15
- 22
ccmeta.leg Datei anzeigen

@ -1295,12 +1295,6 @@ typedef enum {
language lang = C, printLang = C;
// Part of creation of meta object for C
void createMetaInteger() {
}
%}
@ -1309,7 +1303,7 @@ language lang = C, printLang = C;
# yylval == null => "pseudo" op, e.g., change language -- ignored by REPL
# yylval == 0 => end of input file while in META mode only
start = m:metaCatch { yylval = m }
start = m:metaCatch { yylval = null }
| s:externalDeclaration { yylval= s }
error = EOL* < (!EOL .)* EOL* (!EOL .)* > &{ error(yytext), 1 }
@ -1446,12 +1440,12 @@ sCharSequence = ( escapeSequence | !EOL [^\"\\] )*
# 6.5.1
primaryExpression = stringLiteral | constant | id
| META_AT ( META_LCB x:mstmt
| META_OPERATORS META_LPAREN x:mexp
| META_LPAREN x:mexp
) { $$ = 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) }
| 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) }
)
| 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) }
# 6.5.2
@ -2158,19 +2152,18 @@ _FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float1
# 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
metaCatch = META_AT ( META_OPERATORS META_LPAREN m:mexp { $$ = m }
| META_LPAREN m:mexp { $$ = m }
| META_IMPORT s:META_STRING ";" { $$ = null; inputStackPush(get(s, String, value)) }
| META_LCB { $$ = null; lang= META }
)
| &{ lang == META } - ( META_RCB { $$ = null; lang = C }
| s:meta_stmt { $$ = s }
)
metaCatch = META_AT @{ lang= META } ( META_OPERATORS META_LPAREN m:mexp { eval(globals, m) }
| META_LPAREN m:mexp { eval(globals, m) }
| META_IMPORT s:META_STRING ";" { inputStackPush(get(s, String, value)) }
| META_LCB - (s:meta_stmt { eval(globals, s) })* META_RCB { lang = C }
)
mexp = @{ lang = META } s:meta_exp META_RPAREN @{ lang = C } { $$= s }
| @{ lang = C } &{ 0 }
mstmt = @{ lang = META } s:meta_stmt META_RCB @{ lang = C } { $$= s }
mstmt = @{ lang = META } - (s:meta_stmt { eval(globals, s) })* META_RCB { lang = C; $$ = s } # The last one must be a C operator
| @{ lang = C } &{ 0 }
meta_stmt = s:meta_block { $$ = s }

+ 117
- 0
protoNumber.txt Datei anzeigen

@ -0,0 +1,117 @@
_DO(Undefined)
_DO(Integer)
_DO(Float)
_DO(String)
_DO(Symbol)
_DO(Function)
_DO(Map)
_DO(If)
_DO(While)
_DO(Do)
_DO(For)
_DO(ForIn)
_DO(Switch)
_DO(Call)
_DO(Invoke)
_DO(Func)
_DO(Block)
_DO(Declaration)
_DO(Assign)
_DO(Logor)
_DO(Logand)
_DO(Bitor)
_DO(Bitxor)
_DO(Bitand)
_DO(Equal)
_DO(Noteq)
_DO(Less)
_DO(Lesseq)
_DO(Greater)
_DO(Greatereq)
_DO(Shleft)
_DO(Shright)
_DO(Add)
_DO(Sub)
_DO(Mul)
_DO(Div)
_DO(Mod)
_DO(Not)
_DO(Neg)
_DO(Com)
_DO(PreIncVariable)
_DO(PreIncMember)
_DO(PreIncIndex)
_DO(PostIncVariable)
_DO(PostIncMember)
_DO(PostIncIndex)
_DO(PreDecVariable)
_DO(PreDecMember)
_DO(PreDecIndex)
_DO(PostDecVariable)
_DO(PostDecMember)
_DO(PostDecIndex)
_DO(GetVariable)
_DO(GetMember)
_DO(SetMember)
_DO(GetIndex)
_DO(SetIndex)
_DO(Return)
_DO(Break)
_DO(Continue)
_DO(Throw)
_DO(Try)
_DO(Quote)
_DO(Comment)
_DO(Token)
_DO(C_declaration)
_DO(C_string)
_DO(C_if)
_DO(C_int)
_DO(C_float)
_DO(C_char)
_DO(C_id)
_DO(C_while)
_DO(C_do)
_DO(C_for)
_DO(C_binary)
_DO(C_initializer)
_DO(C_range)
_DO(C_conditional)
_DO(C_index)
_DO(C_designation)
_DO(C_attribution)
_DO(C_deref)
_DO(C_block)
_DO(C_call)
_DO(C_subexpr)
_DO(C_array)
_DO(C_parameter)
_DO(C_typeOf)
_DO(C_unary)
_DO(C_prefix)
_DO(C_alignOf)
_DO(C_sizeOf)
_DO(C_cast)
_DO(C_attributeSpec)
_DO(C_asm)
_DO(C_asmExpr)
_DO(C_asmExprArg)
_DO(C_aggregate)
_DO(C_attribute)
_DO(C_postfix)
_DO(C_compound)
_DO(C_functionDef)
_DO(C_exprStatement)
_DO(C_switch)
_DO(C_goto)
_DO(C_continue)
_DO(C_break)
_DO(C_return)
_DO(C_case)
_DO(C_default)
_DO(C_label)
_DO(C_labelDeclaration)
_DO(C_structSpec)
_DO(C_structDeclarator)
_DO(C_enumSpec)
_DO(C_enum)

+ 15
- 2
tests-parsimony/003.c Datei anzeigen

@ -10,7 +10,13 @@
@{forLoop = `statement for (int i = 0; i < 10; ++i) printf("%d\n", i);;}
@{if (useForLoop) { x = forLoop;} else { x = whileLoop; } }
@{
if (useForLoop) {
x = forLoop;
} else {
x = whileLoop;
}
}
int main()
@ -19,7 +25,14 @@ int main()
@(`statement for (int i = 0; i < @(nTimes); ++i) printf("%d\n", i););
@{if (useForLoop) {forLoop;} else {whileLoop;}}; // Impossible to modify useForLoop in a function
@{
useForLoop = 0;
if (useForLoop) {
forLoop;
} else {
whileLoop;
}
};
return 0;
}

Laden…
Abbrechen
Speichern