|
|
@ -256,76 +256,10 @@ Symbol *intern(char *name){ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int binary_search(SymbolTable *st, char *c){ |
|
|
|
int start=0,end=st->length-1; |
|
|
|
int m=0; |
|
|
|
while(end-start>1){ |
|
|
|
|
|
|
|
m=(end+start)/2; //printf("char : %s\n %s",c,st->elements[m]->name); |
|
|
|
// printf("start : %i End : %i\n Compare : %i\n",start,end,strcmp(c,st->elements[m]->name));/**/ |
|
|
|
if(strcmp(c,st->elements[m]->name)==0){ |
|
|
|
return m; |
|
|
|
} |
|
|
|
else if(strcmp(c,st->elements[m]->name)<0){ |
|
|
|
end=m-1; |
|
|
|
} |
|
|
|
else{ |
|
|
|
start=m+1; |
|
|
|
} |
|
|
|
m=(end+start)/2; |
|
|
|
} |
|
|
|
// printf("Start : %i, m : %i, end : %i char : %s size :%i\n",start,m,end,c,st->length); |
|
|
|
if(strcmp(c,st->elements[m]->name)<0){ |
|
|
|
return start; |
|
|
|
} |
|
|
|
else{ |
|
|
|
return end; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void addSymbol(SymbolTable *symbolTable, Symbol *symbol) { |
|
|
|
|
|
|
|
if(symbolTable->length==0){ |
|
|
|
|
|
|
|
symbolTable->length++; |
|
|
|
symbolTable->elements= realloc(symbolTable->elements,sizeof(Symbol) * symbolTable->length); |
|
|
|
symbolTable->elements[0]=symbol;//printf("indice de %s = %i\n",symbolTable->elements[0]->name,0); |
|
|
|
return; |
|
|
|
} |
|
|
|
else{ |
|
|
|
|
|
|
|
|
|
|
|
symbolTable->length++; |
|
|
|
symbolTable->elements= realloc(symbolTable->elements,sizeof(Symbol*) * symbolTable->length); |
|
|
|
int indice=binary_search(symbolTable, symbol->name); |
|
|
|
|
|
|
|
for(int k=symbolTable->length-1;k>indice;k--){ |
|
|
|
symbolTable->elements[k]=symbolTable->elements[k-1]; |
|
|
|
} |
|
|
|
symbolTable->elements[indice]=symbol;//printf("indice de %s = %i\n",symbolTable->elements[indice]->name,indice); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void setRule(SymbolTable *symbolTable, char *name, Node *rule) { |
|
|
|
for (int i= 0; i < symbolTable->length;i++) { |
|
|
|
if (strcmp(symbolTable->elements[i]->name, name) == 0) { |
|
|
|
symbolTable->elements[i]->rule= rule; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
void setRule(char *name, Node *rule){ |
|
|
|
intern(name)->rule=rule; |
|
|
|
} |
|
|
|
|
|
|
|
void arrayAppend(Array *array, Node *statement) { |
|
|
|
array->length++; |
|
|
|
array->elements= realloc(array->elements,sizeof(Node*) * array->length); |
|
|
|
array->elements[array->length-1] = statement; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#define YYSTYPE Node * |
|
|
|
YYSTYPE yylval = 0; |
|
|
|
|
|
|
@ -607,11 +541,11 @@ YY_RULE(int) yy_atom(yycontext *yy); /* 10 */ |
|
|
|
YY_RULE(int) yy_postfix(yycontext *yy); /* 9 */ |
|
|
|
YY_RULE(int) yy_prefix(yycontext *yy); /* 8 */ |
|
|
|
YY_RULE(int) yy_and(yycontext *yy); /* 7 */ |
|
|
|
YY_RULE(int) yy_or(yycontext *yy); /* 6 */ |
|
|
|
YY_RULE(int) yy_expression(yycontext *yy); /* 5 */ |
|
|
|
YY_RULE(int) yy__(yycontext *yy); /* 4 */ |
|
|
|
YY_RULE(int) yy_id(yycontext *yy); /* 3 */ |
|
|
|
YY_RULE(int) yy_declaration(yycontext *yy); /* 2 */ |
|
|
|
YY_RULE(int) yy_expression(yycontext *yy); /* 6 */ |
|
|
|
YY_RULE(int) yy__(yycontext *yy); /* 5 */ |
|
|
|
YY_RULE(int) yy_id(yycontext *yy); /* 4 */ |
|
|
|
YY_RULE(int) yy_declaration(yycontext *yy); /* 3 */ |
|
|
|
YY_RULE(int) yy_or(yycontext *yy); /* 2 */ |
|
|
|
YY_RULE(int) yy_start(yycontext *yy); /* 1 */ |
|
|
|
|
|
|
|
YY_ACTION(void) yy_1_dot(yycontext *yy, char *yytext, int yyleng) |
|
|
@ -621,7 +555,7 @@ YY_ACTION(void) yy_1_dot(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_dot\n")); |
|
|
|
{ |
|
|
|
#line 355 |
|
|
|
#line 291 |
|
|
|
__=mkDot(); |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -635,7 +569,7 @@ YY_ACTION(void) yy_1_class(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_class\n")); |
|
|
|
{ |
|
|
|
#line 353 |
|
|
|
#line 289 |
|
|
|
__=mkClass(yytext) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -649,7 +583,7 @@ YY_ACTION(void) yy_1_string(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_string\n")); |
|
|
|
{ |
|
|
|
#line 351 |
|
|
|
#line 287 |
|
|
|
__ = mkString(yytext) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -663,7 +597,7 @@ YY_ACTION(void) yy_1_id(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_id\n")); |
|
|
|
{ |
|
|
|
#line 349 |
|
|
|
#line 285 |
|
|
|
__ = mkId(intern(yytext)) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -678,7 +612,7 @@ YY_ACTION(void) yy_1_rule(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_rule\n")); |
|
|
|
{ |
|
|
|
#line 347 |
|
|
|
#line 283 |
|
|
|
__ = mkId(intern(yytext)) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -694,7 +628,7 @@ YY_ACTION(void) yy_4_postfix(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_4_postfix\n")); |
|
|
|
{ |
|
|
|
#line 343 |
|
|
|
#line 279 |
|
|
|
__ = s; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -710,7 +644,7 @@ YY_ACTION(void) yy_3_postfix(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_3_postfix\n")); |
|
|
|
{ |
|
|
|
#line 342 |
|
|
|
#line 278 |
|
|
|
s = mkPlus(s) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -726,7 +660,7 @@ YY_ACTION(void) yy_2_postfix(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_2_postfix\n")); |
|
|
|
{ |
|
|
|
#line 341 |
|
|
|
#line 277 |
|
|
|
s = mkStar(s) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -742,7 +676,7 @@ YY_ACTION(void) yy_1_postfix(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_postfix\n")); |
|
|
|
{ |
|
|
|
#line 340 |
|
|
|
#line 276 |
|
|
|
s = mkQuery(s) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -758,7 +692,7 @@ YY_ACTION(void) yy_2_prefix(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_2_prefix\n")); |
|
|
|
{ |
|
|
|
#line 338 |
|
|
|
#line 274 |
|
|
|
__ = p; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -774,7 +708,7 @@ YY_ACTION(void) yy_1_prefix(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_prefix\n")); |
|
|
|
{ |
|
|
|
#line 337 |
|
|
|
#line 273 |
|
|
|
__ = mkExc(p); |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -791,7 +725,7 @@ YY_ACTION(void) yy_2_and(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_2_and\n")); |
|
|
|
{ |
|
|
|
#line 335 |
|
|
|
#line 271 |
|
|
|
__ = p ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -809,7 +743,7 @@ YY_ACTION(void) yy_1_and(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_and\n")); |
|
|
|
{ |
|
|
|
#line 334 |
|
|
|
#line 270 |
|
|
|
__ = mkAnd(p, a); ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -827,7 +761,7 @@ YY_ACTION(void) yy_2_or(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_2_or\n")); |
|
|
|
{ |
|
|
|
#line 332 |
|
|
|
#line 268 |
|
|
|
__ = a ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -845,7 +779,7 @@ YY_ACTION(void) yy_1_or(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_or\n")); |
|
|
|
{ |
|
|
|
#line 331 |
|
|
|
#line 267 |
|
|
|
__ = mkOr(o, a) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
@ -863,8 +797,8 @@ YY_ACTION(void) yy_1_declaration(yycontext *yy, char *yytext, int yyleng) |
|
|
|
#define yythunkpos yy->__thunkpos |
|
|
|
yyprintf((stderr, "do yy_1_declaration\n")); |
|
|
|
{ |
|
|
|
#line 329 |
|
|
|
setRule(&symbolTable,get(i, Id, symbol)->name, e) ; |
|
|
|
#line 263 |
|
|
|
setRule(get(i, Id, symbol)->name, e) ; |
|
|
|
} |
|
|
|
#undef yythunkpos |
|
|
|
#undef yypos |
|
|
@ -1028,25 +962,21 @@ YY_RULE(int) yy_and(yycontext *yy) |
|
|
|
yyprintf((stderr, " fail %s @ %s\n", "and", yy->__buf+yy->__pos)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
YY_RULE(int) yy_or(yycontext *yy) |
|
|
|
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); |
|
|
|
yyprintf((stderr, "%s\n", "or")); |
|
|
|
{ int yypos37= yy->__pos, yythunkpos37= yy->__thunkpos; if (!yy_and(yy)) goto l38; yyDo(yy, yySet, -2, 0); if (!yy__(yy)) goto l38; if (!yymatchChar(yy, '|')) goto l38; if (!yy__(yy)) goto l38; if (!yy_or(yy)) goto l38; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_1_or, yy->__begin, yy->__end); goto l37; |
|
|
|
l38:; yy->__pos= yypos37; yy->__thunkpos= yythunkpos37; if (!yy_and(yy)) goto l36; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_or, yy->__begin, yy->__end); |
|
|
|
} |
|
|
|
l37:; |
|
|
|
yyprintf((stderr, " ok %s @ %s\n", "or", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); |
|
|
|
YY_RULE(int) yy_expression(yycontext *yy) |
|
|
|
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; |
|
|
|
yyprintf((stderr, "%s\n", "expression")); if (!yy_or(yy)) goto l36; |
|
|
|
yyprintf((stderr, " ok %s @ %s\n", "expression", yy->__buf+yy->__pos)); |
|
|
|
return 1; |
|
|
|
l36:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
yyprintf((stderr, " fail %s @ %s\n", "or", yy->__buf+yy->__pos)); |
|
|
|
yyprintf((stderr, " fail %s @ %s\n", "expression", yy->__buf+yy->__pos)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
YY_RULE(int) yy__(yycontext *yy) |
|
|
|
{ |
|
|
|
yyprintf((stderr, "%s\n", "_")); |
|
|
|
l40:; |
|
|
|
{ int yypos41= yy->__pos, yythunkpos41= yy->__thunkpos; if (!yy_space(yy)) goto l41; goto l40; |
|
|
|
l41:; yy->__pos= yypos41; yy->__thunkpos= yythunkpos41; |
|
|
|
l38:; |
|
|
|
{ int yypos39= yy->__pos, yythunkpos39= yy->__thunkpos; if (!yy_space(yy)) goto l39; goto l38; |
|
|
|
l39:; yy->__pos= yypos39; yy->__thunkpos= yythunkpos39; |
|
|
|
} |
|
|
|
yyprintf((stderr, " ok %s @ %s\n", "_", yy->__buf+yy->__pos)); |
|
|
|
return 1; |
|
|
@ -1056,45 +986,62 @@ YY_RULE(int) yy_id(yycontext *yy) |
|
|
|
yyprintf((stderr, "%s\n", "id")); yyText(yy, yy->__begin, yy->__end); { |
|
|
|
#define yytext yy->__text |
|
|
|
#define yyleng yy->__textlen |
|
|
|
if (!(YY_BEGIN)) goto l42; |
|
|
|
if (!(YY_BEGIN)) goto l40; |
|
|
|
#undef yytext |
|
|
|
#undef yyleng |
|
|
|
} if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\377\377\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l42; |
|
|
|
l43:; |
|
|
|
{ int yypos44= yy->__pos, yythunkpos44= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\377\377\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l44; goto l43; |
|
|
|
l44:; yy->__pos= yypos44; yy->__thunkpos= yythunkpos44; |
|
|
|
} if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\377\377\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l40; |
|
|
|
l41:; |
|
|
|
{ int yypos42= yy->__pos, yythunkpos42= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\376\377\377\377\377\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l42; goto l41; |
|
|
|
l42:; yy->__pos= yypos42; yy->__thunkpos= yythunkpos42; |
|
|
|
} yyText(yy, yy->__begin, yy->__end); { |
|
|
|
#define yytext yy->__text |
|
|
|
#define yyleng yy->__textlen |
|
|
|
if (!(YY_END)) goto l42; |
|
|
|
if (!(YY_END)) goto l40; |
|
|
|
#undef yytext |
|
|
|
#undef yyleng |
|
|
|
} if (!yy__(yy)) goto l42; yyDo(yy, yy_1_id, yy->__begin, yy->__end); |
|
|
|
} if (!yy__(yy)) goto l40; yyDo(yy, yy_1_id, yy->__begin, yy->__end); |
|
|
|
yyprintf((stderr, " ok %s @ %s\n", "id", yy->__buf+yy->__pos)); |
|
|
|
return 1; |
|
|
|
l42:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
l40:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
yyprintf((stderr, " fail %s @ %s\n", "id", yy->__buf+yy->__pos)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
YY_RULE(int) yy_declaration(yycontext *yy) |
|
|
|
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); |
|
|
|
yyprintf((stderr, "%s\n", "declaration")); if (!yy_id(yy)) goto l45; yyDo(yy, yySet, -2, 0); if (!yymatchChar(yy, '=')) goto l45; if (!yy__(yy)) goto l45; if (!yy_expression(yy)) goto l45; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_1_declaration, yy->__begin, yy->__end); |
|
|
|
yyprintf((stderr, "%s\n", "declaration")); if (!yy_id(yy)) goto l43; yyDo(yy, yySet, -2, 0); if (!yymatchChar(yy, '=')) goto l43; if (!yy__(yy)) goto l43; if (!yy_expression(yy)) goto l43; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_1_declaration, yy->__begin, yy->__end); |
|
|
|
yyprintf((stderr, " ok %s @ %s\n", "declaration", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); |
|
|
|
return 1; |
|
|
|
l45:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
l43:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
yyprintf((stderr, " fail %s @ %s\n", "declaration", yy->__buf+yy->__pos)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
YY_RULE(int) yy_or(yycontext *yy) |
|
|
|
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; yyDo(yy, yyPush, 2, 0); |
|
|
|
yyprintf((stderr, "%s\n", "or")); |
|
|
|
{ int yypos45= yy->__pos, yythunkpos45= yy->__thunkpos; if (!yy_and(yy)) goto l46; yyDo(yy, yySet, -2, 0); if (!yy__(yy)) goto l46; if (!yymatchChar(yy, '|')) goto l46; if (!yy__(yy)) goto l46; if (!yy_or(yy)) goto l46; yyDo(yy, yySet, -1, 0); yyDo(yy, yy_1_or, yy->__begin, yy->__end); goto l45; |
|
|
|
l46:; yy->__pos= yypos45; yy->__thunkpos= yythunkpos45; if (!yy_and(yy)) goto l44; yyDo(yy, yySet, -2, 0); yyDo(yy, yy_2_or, yy->__begin, yy->__end); |
|
|
|
} |
|
|
|
l45:; |
|
|
|
yyprintf((stderr, " ok %s @ %s\n", "or", yy->__buf+yy->__pos)); yyDo(yy, yyPop, 2, 0); |
|
|
|
return 1; |
|
|
|
l44:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
yyprintf((stderr, " fail %s @ %s\n", "or", yy->__buf+yy->__pos)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
YY_RULE(int) yy_start(yycontext *yy) |
|
|
|
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos; |
|
|
|
yyprintf((stderr, "%s\n", "start")); if (!yy_declaration(yy)) goto l46; |
|
|
|
l47:; |
|
|
|
{ int yypos48= yy->__pos, yythunkpos48= yy->__thunkpos; if (!yy_declaration(yy)) goto l48; goto l47; |
|
|
|
l48:; yy->__pos= yypos48; yy->__thunkpos= yythunkpos48; |
|
|
|
yyprintf((stderr, "%s\n", "start")); |
|
|
|
{ int yypos48= yy->__pos, yythunkpos48= yy->__thunkpos; if (!yy_or(yy)) goto l49; goto l48; |
|
|
|
l49:; yy->__pos= yypos48; yy->__thunkpos= yythunkpos48; if (!yy_declaration(yy)) goto l47; |
|
|
|
l50:; |
|
|
|
{ int yypos51= yy->__pos, yythunkpos51= yy->__thunkpos; if (!yy_declaration(yy)) goto l51; goto l50; |
|
|
|
l51:; yy->__pos= yypos51; yy->__thunkpos= yythunkpos51; |
|
|
|
} |
|
|
|
} |
|
|
|
l48:; |
|
|
|
yyprintf((stderr, " ok %s @ %s\n", "start", yy->__buf+yy->__pos)); |
|
|
|
return 1; |
|
|
|
l46:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
l47:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0; |
|
|
|
yyprintf((stderr, " fail %s @ %s\n", "start", yy->__buf+yy->__pos)); |
|
|
|
return 0; |
|
|
|
} |
|
|
@ -1146,7 +1093,7 @@ YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx) |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
#line 362 "parse.leg" |
|
|
|
#line 298 "parse.leg" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1223,6 +1170,7 @@ int execute(Node *node, InputBuffer *in) |
|
|
|
} |
|
|
|
case Id: { |
|
|
|
Symbol *symbol= get(node, Id, symbol); |
|
|
|
if (0 == symbol->rule) { printf("undefined rule: %s\n", symbol->name); } |
|
|
|
return execute(symbol->rule, in); |
|
|
|
} |
|
|
|
} |
|
|
@ -1244,6 +1192,8 @@ int main(int argc, char **argv) |
|
|
|
char *line=0; |
|
|
|
size_t line_max=0; |
|
|
|
ssize_t line_len=0; |
|
|
|
Symbol *start= intern("start"); |
|
|
|
if (!start->rule) perror("no start rule"); |
|
|
|
while((line_len=getline(&line,&line_max,stdin))>=0){ |
|
|
|
if(line_len>0 && line[line_len-1]=='\n'){ |
|
|
|
line[line_len-1]=0; |
|
|
|