deadlykingdx

flex.l

Jun 28th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. %{
  2. #include "y.tab.h"  
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. using namespace std;
  8. %}
  9.  
  10.  
  11.  
  12.  
  13. keywords "False" |"await" |"else" |"import" |"pass" |"None" |"break" |"except" |"in" |"raise" |"True" |"class" |"finally" |"is" |"return" |"and" |"continue" |"for" |"lambda" |"try" |"as" |"def" |"from" |"nonlocal" |"while" |"assert" |"del" |"global" |"not" |"with" |"async" |"elif" |"if" |"or" |"yield"
  14.  
  15. identifier [a-zA-Z_][a-zA-Z0-9_]*
  16.  
  17. letter = [a-zA-Z]
  18.  
  19. number = [0-9]+
  20.  
  21. alphanumeric = (letter | number)+
  22.  
  23. dquote  "\"[^"]*\""
  24.  
  25. squote  "\'[^']*\'"
  26.  
  27. %%
  28. \r|\n|\r\n {}
  29.  
  30. ":" {
  31.     return COLON;
  32. }
  33.  
  34. "." {
  35.     return DOT;
  36. }
  37.  
  38. "(" {
  39.     return LBRACE;
  40. }
  41.  
  42. ")" {
  43.     return RBRACE;
  44. }
  45.  
  46. {dquote} {
  47.     yylval == yytext;
  48.     return STRING;
  49. }
  50.  
  51. {squote} {
  52.     yylval == yytext;
  53.     return STRING;
  54. }
  55.  
  56. {identifier} {
  57.     yylval == yytext;
  58.     return IDENTIFIER;
  59. }
  60. def {
  61.         yylval = yytext;
  62.         return DEF;
  63. }
  64.  
  65. class {
  66.     yylval == yytext;
  67.     return CLASS;
  68. }
  69.  
  70.  
  71.  
  72. %%
Add Comment
Please, Sign In to add comment