%{ #include #include "proto-color.h" extern int yylex(); int yyerror (char const *message) { fprintf(stderr,RED("<%s>")"\n", message); return 0; } void Prompt(){ printf("yash> "); } /* Yet Another Shell */ %} %error-verbose %token HELLO THANKS FUCK BYE %token NEWLINE %% Shell : {} | Shell Line NEWLINE {} | Shell error NEWLINE {yyerrok; printf(BLUE("Ligne invalide")"\n");} ; Line : Command ; Command : | Builtin // | Others ; Builtin : HELLO {printf("Nice to meet you\n");} | THANKS {printf("You are welcome\n");} | FUCK {yyerror("Semantic Error : Censored !"); YYERROR;} | BYE {printf("See you\n"); return(0);} ; %% int main(void) { return yyparse(); }