YY_RULE(int) yy_end_of_file() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "end_of_file")); { int yypos95= yypos, yythunkpos95= yythunkpos; if (!yymatchDot()) goto l95; goto l94; l95:; yypos= yypos95; yythunkpos= yythunkpos95; } yyprintf((stderr, " ok %s @ %s\n", "end_of_file", yybuf+yypos)); return 1; l94:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "end_of_file", yybuf+yypos)); return 0; }
YY_RULE(int) yy_end_of_file(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "end_of_file")); { int yypos100= G->pos, yythunkpos100= G->thunkpos; if (!yymatchDot(G)) goto l100; goto l99; l100:; G->pos= yypos100; G->thunkpos= yythunkpos100; } yyprintf((stderr, " ok %s @ %s\n", "end_of_file", G->buf+G->pos)); return 1; l99:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "end_of_file", G->buf+G->pos)); return 0; }
YY_RULE(int) yy_eof() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "eof")); { int yypos25= yypos, yythunkpos25= yythunkpos; if (!yymatchDot()) goto l25; goto l24; l25:; yypos= yypos25; yythunkpos= yythunkpos25; } yyprintf((stderr, " ok %s @ %s\n", "eof", yybuf+yypos)); return 1; l24:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "eof", yybuf+yypos)); return 0; }
YY_RULE(int) yy_trailer() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString("%%")) goto l96; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l96; l97:; { int yypos98= yypos, yythunkpos98= yythunkpos; if (!yymatchDot()) goto l98; goto l97; l98:; yypos= yypos98; yythunkpos= yythunkpos98; } yyText(yybegin, yyend); if (!(YY_END)) goto l96; yyDo(yy_1_trailer, yybegin, yyend); yyprintf((stderr, " ok %s @ %s\n", "trailer", yybuf+yypos)); return 1; l96:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "trailer", yybuf+yypos)); return 0; }
YY_RULE(int) yy_trailer(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "trailer")); if (!yymatchString(G, "%%")) goto l101; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l101; l102:; { int yypos103= G->pos, yythunkpos103= G->thunkpos; if (!yymatchDot(G)) goto l103; goto l102; l103:; G->pos= yypos103; G->thunkpos= yythunkpos103; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l101; yyDo(G, yy_1_trailer, G->begin, G->end); yyprintf((stderr, " ok %s @ %s\n", "trailer", G->buf+G->pos)); return 1; l101:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "trailer", G->buf+G->pos)); return 0; }
int main(int argc, char **argv) { ast_node *tree = NULL; VM vm; CTX ctx; char *bytecode; size_t len; IP ip; VALUE closure, result; int parse_ok; char *bootstrap_file_name; char *source_file_name; METHOD_RESULT mr; // Silence GCC -Wunused-function if(0) { yymatchDot(NULL); yyAccept(NULL, 0); } NGS_GC_INIT(); // (causes warning) // NGS_GC_THR_INIT(); yycontext yyctx; memset(&yyctx, 0, sizeof(yycontext)); yyctx.fail_pos = -1; yyctx.fail_rule = "(unknown)"; yyctx.lines = 0; yyctx.lines_postions[0] = 0; bootstrap_file_name = find_bootstrap_file(); if(!bootstrap_file_name) { fprintf(stderr, "Cold not find bootstrap file\n"); exit(100); } if(!strcmp(bootstrap_file_name, "-")) { source_file_name = ngs_strdup("<stdin>"); yyctx.input_file = stdin; } else { source_file_name = bootstrap_file_name; yyctx.input_file = fopen(bootstrap_file_name, "r"); } if(!yyctx.input_file) { fprintf(stderr, "Error while opening bootstrap file '%s': %d - %s\n", bootstrap_file_name, errno, strerror(errno)); exit(101); } parse_ok = yyparse(&yyctx); // printf("parse_ok %d\n", parse_ok); if(!parse_ok) { fprintf(stderr, "NGS: Failed to parse at position %d (%s), rule %s. Exiting.\n", yyctx.fail_pos, sprintf_position(&yyctx, yyctx.fail_pos), yyctx.fail_rule); exit(2); } tree = yyctx.__; IF_DEBUG(COMPILER, print_ast(tree, 0);)
YY_RULE(int) yy_braces() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "braces")); { int yypos14= yypos, yythunkpos14= yythunkpos; if (!yymatchChar('{')) goto l15; l16:; { int yypos17= yypos, yythunkpos17= yythunkpos; { int yypos18= yypos, yythunkpos18= yythunkpos; if (!yymatchChar('}')) goto l18; goto l17; l18:; yypos= yypos18; yythunkpos= yythunkpos18; } if (!yymatchDot()) goto l17; goto l16; l17:; yypos= yypos17; yythunkpos= yythunkpos17; } if (!yymatchChar('}')) goto l15; goto l14; l15:; yypos= yypos14; yythunkpos= yythunkpos14; { int yypos19= yypos, yythunkpos19= yythunkpos; if (!yymatchChar('}')) goto l19; goto l13; l19:; yypos= yypos19; yythunkpos= yythunkpos19; } if (!yymatchDot()) goto l13; } l14:; yyprintf((stderr, " ok %s @ %s\n", "braces", yybuf+yypos)); return 1; l13:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "braces", yybuf+yypos)); return 0; }
YY_RULE(int) yy_braces(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "braces")); { int yypos14= G->pos, yythunkpos14= G->thunkpos; if (!yymatchChar(G, '{')) goto l15; l16:; { int yypos17= G->pos, yythunkpos17= G->thunkpos; { int yypos18= G->pos, yythunkpos18= G->thunkpos; if (!yymatchChar(G, '}')) goto l18; goto l17; l18:; G->pos= yypos18; G->thunkpos= yythunkpos18; } if (!yymatchDot(G)) goto l17; goto l16; l17:; G->pos= yypos17; G->thunkpos= yythunkpos17; } if (!yymatchChar(G, '}')) goto l15; goto l14; l15:; G->pos= yypos14; G->thunkpos= yythunkpos14; { int yypos19= G->pos, yythunkpos19= G->thunkpos; if (!yymatchChar(G, '}')) goto l19; goto l13; l19:; G->pos= yypos19; G->thunkpos= yythunkpos19; } if (!yymatchDot(G)) goto l13; } l14:; yyprintf((stderr, " ok %s @ %s\n", "braces", G->buf+G->pos)); return 1; l13:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "braces", G->buf+G->pos)); return 0; }
YY_RULE(int) yy_declaration() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString("%{")) goto l102; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l102; l103:; { int yypos104= yypos, yythunkpos104= yythunkpos; { int yypos105= yypos, yythunkpos105= yythunkpos; if (!yymatchString("%}")) goto l105; goto l104; l105:; yypos= yypos105; yythunkpos= yythunkpos105; } if (!yymatchDot()) goto l104; goto l103; l104:; yypos= yypos104; yythunkpos= yythunkpos104; } yyText(yybegin, yyend); if (!(YY_END)) goto l102; if (!yy_RPERCENT()) goto l102; yyDo(yy_1_declaration, yybegin, yyend); yyprintf((stderr, " ok %s @ %s\n", "declaration", yybuf+yypos)); return 1; l102:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "declaration", yybuf+yypos)); return 0; }
YY_RULE(int) yy_comment() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar('#')) goto l5; l6:; { int yypos7= yypos, yythunkpos7= yythunkpos; { int yypos8= yypos, yythunkpos8= yythunkpos; if (!yy_end_of_line()) goto l8; goto l7; l8:; yypos= yypos8; yythunkpos= yythunkpos8; } if (!yymatchDot()) goto l7; goto l6; l7:; yypos= yypos7; yythunkpos= yythunkpos7; } if (!yy_end_of_line()) goto l5; yyprintf((stderr, " ok %s @ %s\n", "comment", yybuf+yypos)); return 1; l5:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "comment", yybuf+yypos)); return 0; }
YY_RULE(int) yy_declaration(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "declaration")); if (!yymatchString(G, "%{")) goto l107; yyText(G, G->begin, G->end); if (!(YY_BEGIN)) goto l107; l108:; { int yypos109= G->pos, yythunkpos109= G->thunkpos; { int yypos110= G->pos, yythunkpos110= G->thunkpos; if (!yymatchString(G, "%}")) goto l110; goto l109; l110:; G->pos= yypos110; G->thunkpos= yythunkpos110; } if (!yymatchDot(G)) goto l109; goto l108; l109:; G->pos= yypos109; G->thunkpos= yythunkpos109; } yyText(G, G->begin, G->end); if (!(YY_END)) goto l107; if (!yy_RPERCENT(G)) { goto l107; } yyDo(G, yy_1_declaration, G->begin, G->end); yyprintf((stderr, " ok %s @ %s\n", "declaration", G->buf+G->pos)); return 1; l107:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "declaration", G->buf+G->pos)); return 0; }
YY_RULE(int) yy_comment(GREG *G) { int yypos0= G->pos, yythunkpos0= G->thunkpos; yyprintf((stderr, "%s\n", "comment")); if (!yymatchChar(G, '#')) goto l5; l6:; { int yypos7= G->pos, yythunkpos7= G->thunkpos; { int yypos8= G->pos, yythunkpos8= G->thunkpos; if (!yy_end_of_line(G)) { goto l8; } goto l7; l8:; G->pos= yypos8; G->thunkpos= yythunkpos8; } if (!yymatchDot(G)) goto l7; goto l6; l7:; G->pos= yypos7; G->thunkpos= yythunkpos7; } if (!yy_end_of_line(G)) { goto l5; } yyprintf((stderr, " ok %s @ %s\n", "comment", G->buf+G->pos)); return 1; l5:; G->pos= yypos0; G->thunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "comment", G->buf+G->pos)); return 0; }
YY_RULE(int) yy_pin() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "pin")); { int yypos31= yypos, yythunkpos31= yythunkpos; if (!yy_word()) goto l32; l33:; { int yypos34= yypos, yythunkpos34= yythunkpos; if (!yy_word()) goto l34; goto l33; l34:; yypos= yypos34; yythunkpos= yythunkpos34; } if (!yy_eof()) goto l32; yyDo(yy_1_pin, yybegin, yyend); goto l31; l32:; yypos= yypos31; yythunkpos= yythunkpos31; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l30; if (!yymatchDot()) goto l30; l35:; { int yypos36= yypos, yythunkpos36= yythunkpos; if (!yymatchDot()) goto l36; goto l35; l36:; yypos= yypos36; yythunkpos= yythunkpos36; } yyText(yybegin, yyend); if (!(YY_END)) goto l30; yyDo(yy_2_pin, yybegin, yyend); } l31:; yyprintf((stderr, " ok %s @ %s\n", "pin", yybuf+yypos)); return 1; l30:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "pin", yybuf+yypos)); return 0; }
YY_RULE(int) yy_char() { int yypos0= yypos, yythunkpos0= yythunkpos; yyprintf((stderr, "%s\n", "char")); { int yypos24= yypos, yythunkpos24= yythunkpos; if (!yymatchChar('\\')) goto l25; if (!yymatchClass((unsigned char *)"\000\000\000\000\204\000\000\000\000\000\000\070\146\100\124\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l25; goto l24; l25:; yypos= yypos24; yythunkpos= yythunkpos24; if (!yymatchChar('\\')) goto l26; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\017\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l26; goto l24; l26:; yypos= yypos24; yythunkpos= yythunkpos24; if (!yymatchChar('\\')) goto l27; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l27; { int yypos28= yypos, yythunkpos28= yythunkpos; if (!yymatchClass((unsigned char *)"\000\000\000\000\000\000\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l28; goto l29; l28:; yypos= yypos28; yythunkpos= yythunkpos28; } l29:; goto l24; l27:; yypos= yypos24; yythunkpos= yythunkpos24; { int yypos30= yypos, yythunkpos30= yythunkpos; if (!yymatchChar('\\')) goto l30; goto l23; l30:; yypos= yypos30; yythunkpos= yythunkpos30; } if (!yymatchDot()) goto l23; } l24:; yyprintf((stderr, " ok %s @ %s\n", "char", yybuf+yypos)); return 1; l23:; yypos= yypos0; yythunkpos= yythunkpos0; yyprintf((stderr, " fail %s @ %s\n", "char", yybuf+yypos)); return 0; }