%{ #include #include using namespace std; extern "C" { int yylex(void); } extern FILE * yyin; void yyerror(const char * str) { fprintf(stderr, "error: %s\n", str); } int yywrap() { return 1; } %} %token PLUS; %token MINUS; %token STAR; %token DIVIDE; %token MOD; %token SEMICOLON; %token COLON; %token QUESTION; %token DOLLAR; %token DOT; %token DQUOTE; %token SQUOTE; %token COMMA; %token LCURLY; %token RCURLY; %token LBRACKET; %token RBRACKET; %token LPAREN; %token RPAREN; %token LESS; %token GREATER; %token DEC_NUMBER; %token REAL_NUMBER; %token CAMERA; %token COLOR; %token POSITION; %token SCENE; %% scene: /* empty */ | scene_spec { printf("Saw a number\n"); } ; number: DEC_NUMBER | REAL_NUMBER ; %% int parse(const char * fileName) { yyin = fopen(fileName, "r"); if (yyin == NULL) { cerr << "Failed to open file '" << fileName << "'" << endl; return -1; } yyparse(); }