%{ #include extern FILE * yyin; void yyerror(const char * str) { fprintf(stderr, "error: %s\n", str); } int yywrap() { return 1; } int main(int argc, char * argv[]) { if (argc > 0) { yyin = fopen(argv[1], "r"); } yyparse(); } %} %token ASSIGN; %token EQUAL; %token LEQ; %token GEQ; %token LSHIFT; %token RSHIFT; %token AND; %token OR; %token NOT; %token BIT_AND; %token BIT_OR; %token BIT_XOR; %token BIT_NEG; %token INCREMENT; %token DECREMENT; %token PLUS; %token MINUS; %token TIMES; %token DIVIDE; %token MOD; %token SEMICOLON; %token COLON; %token QUESTION; %token DOLLAR; %token DOT; %token DQUOTE; %token SQUOTE; %token LCURLY; %token RCURLY; %token LBRACKET; %token RBRACKET; %token LPAREN; %token RPAREN; %token BIN_NUMBER; %token HEX_NUMBER; %token OCT_NUMBER; %token DEC_NUMBER; %token ALIAS; %token MODULE; %token RETURN; %token USE; %token ID; %% program: /* empty */ | number program { printf("Saw a number\n"); } | assignment program { printf("Saw an assignment\n"); } number: BIN_NUMBER | OCT_NUMBER | DEC_NUMBER | HEX_NUMBER ; assignment: ID ASSIGN number ;