/* Syntax Analyzer with Bison (3.8.1) */ /* (referenced Bison manual for file boilerplate [3.1]) */ // Prologue %{ #include #include "symbol_table.c" extern int yylex(void); void yyerror(const char *err); extern char* yytext; extern int yychar; SymbolTable * st; %} %token ID 101 %token T_INTEGER %token T_ADDRESS 202 %token T_BOOLEAN 203 %token T_CHARACTER 204 %token T_STRING 205 %token C_INTEGER 301 %token C_NULL 302 %token C_CHARACTER 303 %token C_STRING 304 %token C_TRUE 305 %token C_FALSE 306 %token WHILE 401 %token IF 402 %token THEN 403 %token ELSE 404 %token TYPE 405 %token FUNCTION 406 %token RETURN 407 %token EXTERNAL 408 %token AS 409 %token L_PAREN 501 %token R_PAREN 502 %token L_BRACKET 503 %token R_BRACKET 504 %token L_BRACE 505 %token R_BRACE 506 %token SEMI_COLON 507 %token COLON 508 %token COMMA 509 %token ARROW 510 %token ADD 601 %token SUB_OR_NEG 602 %token MUL 603 %token DIV 604 %token REM 605 %token LESS_THAN 606 %token EQUAL_TO 607 %token ASSIGN 608 %token NOT 609 %token AND 610 %token OR 611 %token DOT 612 %token RESERVE 613 %token RELEASE 614 %token COMMENT 700 %% start: /*empty for now*/ OPTIONAL; OPTIONAL: L_BRACKET {printf("success");}; // %% void yyerror(const char *err) { fprintf(stderr, "Error: %s\n", err); } int main() { st=CreateScope(NULL,1,1); int a; while ((a = yyparse()) != EOF){ printf("%d = a: yytext = %s: yychar = %d\n", a, yytext, yychar); if(yytext[0] == '!'){ print_symbol_table(getAncestor(st),stdout); break; } } return 0; }