updated testing for parser
This commit is contained in:
16
grammar.y
16
grammar.y
@ -7,6 +7,8 @@
|
|||||||
#include "symbol_table.c"
|
#include "symbol_table.c"
|
||||||
extern int yylex(void);
|
extern int yylex(void);
|
||||||
void yyerror(const char *err);
|
void yyerror(const char *err);
|
||||||
|
extern char* yytext;
|
||||||
|
extern int yychar;
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%token ID 101
|
%token ID 101
|
||||||
@ -59,15 +61,9 @@
|
|||||||
|
|
||||||
input: /*empty for now*/
|
input: /*empty for now*/
|
||||||
OPTIONAL;
|
OPTIONAL;
|
||||||
|
|
||||||
OPTIONAL_OPTIONAL:
|
|
||||||
OPTIONAL
|
|
||||||
| OPTIONAL_OPTIONAL OPTIONAL {printf("expansion\n");};
|
|
||||||
|
|
||||||
OPTIONAL:
|
OPTIONAL:
|
||||||
'[' {printf("success");}
|
'[' {printf("success");};
|
||||||
|%empty
|
|
||||||
;
|
|
||||||
// B : '{'{CreateScope(cur,line,column)} E '}'; //Braced Expressions can have braces removed to get regular expressions
|
// B : '{'{CreateScope(cur,line,column)} E '}'; //Braced Expressions can have braces removed to get regular expressions
|
||||||
// D : '[' l ']'; //Declaration Lists Brackets can be taken out to get a list of Declarations
|
// D : '[' l ']'; //Declaration Lists Brackets can be taken out to get a list of Declarations
|
||||||
// E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment
|
// E : Maybe_D U; //An expression can start with an optional D followed by an undeclared segment
|
||||||
@ -82,5 +78,9 @@ void yyerror(const char *err) {
|
|||||||
fprintf(stderr, "Error: %s\n", err);
|
fprintf(stderr, "Error: %s\n", err);
|
||||||
}
|
}
|
||||||
int main() {
|
int main() {
|
||||||
return yyparse();
|
int a;
|
||||||
|
while (a = yyparse()){
|
||||||
|
printf("%d = a: yytext = %s: yychar = %d\n", a, yytext, yychar);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user