I'm following this: http://www.telenovela-world.com/~spa...C-HOWTO-4.html since I've always fancied writing my own programming language. I was hoping flex and yacc would relieve some stress... yeah right.
This grammar:
Doesn't compile:Code:%{ #include <stdio.h> #include <string.h> void yyerror(const char* str) { fprintf(stderr, "error: %s\n", str); } int yywrap() { return 1; } main() { yyparse(); } %} %token NUMBER TOKHEAT STATE TOKTARGET TOKTEMP commands: | commands command ; command: heat_switch | target_set ; heat_switch: TOKHEAT STATE { printf("\tHeat turned on or off\n"); } ; target_set: TOKTARGET TOKTEMP NUMBER { printf("\tTemperature set\n"); } ;
I was hoping somebody here might be able to help me - not sure how much this is used though.[lee@localhost c_cpp]$ yacc -d thermo.y
yacc: e - line 24 of "thermo.y", syntax error
commands:
^