Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include <string>
- #include "node.h"
- #include "parser.hpp"
- #define SAVE_TOKEN yylval.string = new std::string(yytext, yyleng)
- #define TOKEN(t) (yylval.token = t)
- extern "C" int yywrap() { }
- %}
- %%
- [ \t\n] ;
- "str" return TOKEN(STRINGIDENTIFIER);
- "num" return TOKEN(INTIDENTIFIER);
- "if" return TOKEN(IF);
- "next" return TOKEN(NEXT);
- "for" return TOKEN(FOR);
- "fnc" return TOKEN(FUNC);
- [a-zA-Z_][a-zA-Z0-9_]* SAVE_TOKEN; return TIDENTIFIER;
- [0-9]+ SAVE_TOKEN; return TINTEGER;
- (\".*\") SAVE_TOKEN; return TSTRING
- "+" return TOKEN(TPLUS);
- "=" return TOKEN(TEQUAL);
- "-" return TOKEN(TMINUS);
- "(" return TOKEN(LEFTPARENTHESIS);
- ")" return TOKEN(RIGHTPARENTHESIS);
- "{" return TOKEN(LEFTBRACE);
- "{" return TOKEN(RIGHTBRACE);
- "," return TOKEN(COMMA);
- . printf("Unknown token!n"); yyterminate();
- %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement