A Hugo incarnation of the blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scanner.l 974B

1234567891011121314151617181920212223242526272829303132333435
  1. %option noyywrap
  2. %{
  3. #include <iostream>
  4. #include "ast.hpp"
  5. #include "definition.hpp"
  6. #include "parser.hpp"
  7. #define YY_DECL yy::parser::symbol_type yylex()
  8. %}
  9. %%
  10. [ \n]+ {}
  11. \+ { return yy::parser::make_PLUS(); }
  12. \* { return yy::parser::make_TIMES(); }
  13. - { return yy::parser::make_MINUS(); }
  14. \/ { return yy::parser::make_DIVIDE(); }
  15. [0-9]+ { return yy::parser::make_INT(atoi(yytext)); }
  16. defn { return yy::parser::make_DEFN(); }
  17. data { return yy::parser::make_DATA(); }
  18. case { return yy::parser::make_CASE(); }
  19. of { return yy::parser::make_OF(); }
  20. \{ { return yy::parser::make_OCURLY(); }
  21. \} { return yy::parser::make_CCURLY(); }
  22. \( { return yy::parser::make_OPAREN(); }
  23. \) { return yy::parser::make_CPAREN(); }
  24. , { return yy::parser::make_COMMA(); }
  25. -> { return yy::parser::make_ARROW(); }
  26. = { return yy::parser::make_EQUAL(); }
  27. [a-z][a-zA-Z]* { return yy::parser::make_LID(std::string(yytext)); }
  28. [A-Z][a-zA-Z]* { return yy::parser::make_UID(std::string(yytext)); }
  29. %%