Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include "y.tab.h"
- void yyerror (char *s);
- int yylex();
- %}
- %%
- /* Whitespace */
- [ \t\n] ;
- "print" return print;
- "exit" return exit_cmd;
- [a-zA-Z\_][a-zA-Z0-9\_]* {yylval.str = yytext; printf("Identifier `%s` found\n", yytext); return identifier;}
- [\'\"].*?[\'\"] {yylval.str = yytext; return string;}
- [0-9]+ {yylval.num = atoi(yytext); return number;}
- [\=\-\+\/\*\^] return yytext[0];
- . {fprintf(stderr, "Unexpected character `%s` \n", yytext);}
- %%
- int yywrap(void) {return 1;}
Add Comment
Please, Sign In to add comment