Ver a proveniência

fixed output

master
Nathan R há 3 anos
ascendente
cometimento
6261f1e872
1 ficheiros alterados com 14 adições e 31 eliminações
  1. +14
    -31
      ccmeta.leg

+ 14
- 31
ccmeta.leg Ver ficheiro

@ -2101,19 +2101,6 @@ __INLINE = '__inline' !IDREST &{gnu} { $$= newToken("__inlin
_FLOAT128 = '_Float128' !IDREST &{gnu} { $$= newToken("_Float128" ) } -
#--------------------------------------------- Common rules ----------------------------------------------#
- = (blank | comment)*
blank = space | eol
space = [ \t]
eol = ( "\n""\r"*
| "\r""\n"*
) { inputStack->lineNumber++ }
comment = "//" ( ![\n\r] . )*
| "/*" ( !"*/" (eol | .) )* "*/"
#--------------------------------------------- Meta grammar ----------------------------------------------#
# the semicolon has to be explicit with no space eaten afterwards to prevent the
@ -3432,7 +3419,8 @@ void readEvalPrint(oop scope, char *fileName)
proto_t proto_number = get(map_get(proto, __name___symbol), Symbol, prototype);
if (proto_number > META_PROTO_MAX) {
if (opt_v > 1) println(yylval);
map_append(outputProgram, yylval);
outputNode(yylval);
//map_append(outputProgram, yylval);
continue;
}
if (opt_v > 1) printf("%s:%i: ", get(inputStack->name, String, value), inputStack->lineNumber);
@ -3904,6 +3892,8 @@ void outputTree(oop node, int depth)
#undef CASE
#undef OUT
/** C nodes */
#define CASE(NAME) case t_C_##NAME:printf("%s:\n", #NAME);
#define OUT(NAME) printSpace(depth+DELTA) ; outputValue(map_get(node, NAME##_symbol));
CASE(int)
@ -4208,6 +4198,9 @@ void outputTree(oop node, int depth)
OUT(attributeL);
OUT(expression);
break;
/** Meta nodes */
default:
printf("I cannot print a node with proto_number %i\n", proto_number);
exit(0);
@ -4216,8 +4209,8 @@ void outputTree(oop node, int depth)
#undef OUT
}
void printTree() {
outputTree(yylval, 0);
void printTree(oop element) {
outputTree(element, 0);
printf("\n");
}
@ -4297,13 +4290,16 @@ int main(int argc, char **argv)
repled= 1;
}
}
if (!repled) {
readEvalPrint(globals, NULL);
}
for (size_t i= 0; i < map_size(outputProgram); ++i) {
oop element= get(outputProgram, Map, elements)[i].value;
outputNode(element);
if (toPrint) printTree(element);
//else outputNode(element);
}
if (opt_g) {
@ -4313,25 +4309,12 @@ int main(int argc, char **argv)
else printf("[GC: %.2f GB allocated]\n", (double)nalloc / (1024*1024*1024));
}
popScope();
assert(!actualScope);
return 0;
(void)yyAccept;
/**/
inputStackPush(NULL);
while (yyparse()) {
if (toPrint) printTree();
else outputNode(yylval);
}
popScope();
assert(!actualScope);
return 0;
/**/
(void)yyAccept;
}
// Local Variables:

Carregando…
Cancelar
Guardar