Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. %{
  2.  
  3. #include "scanner.h"
  4.  
  5. /* --- Your code here ---
  6. *
  7. * This is where C declarations go. If you need to include
  8. * files for the actions below, this is where you do it.
  9. */
  10.  
  11. /* --- End your code --- */
  12.  
  13. extern void yyerror(char *);
  14. %}
  15.  
  16. %option yylineno
  17. %option noyywrap
  18. %option 8bit
  19. %option caseless
  20. %option nodefault
  21. %option outfile="scanner.cc"
  22.  
  23. /* --- Your code here ---
  24. *
  25. * This is where Flex declarations go. If you need to include
  26. * any such declarations, this is where you do it.
  27. */
  28.  
  29. /* --- End your code --- */
  30. DIGIT [0-9]
  31. INTEGER ("-"|[1-9]){DIGIT}*
  32. REAL ({INTEGER}|"."){DIGIT}*(("E"|"E-"){DIGIT}+|{DIGIT}*)
  33. LITERAL ([a-z]|[A-Z])
  34. IDENTIFIER {LITERAL}+({LITERAL}|{DIGIT}|"_")*
  35.  
  36. BADCOMMENT "//"[^"\n""/*"]*"/*"
  37. COMMENT "//"[^"\n"]*
  38. temp "*/"
  39. MCOMMENT "/*"[^("*\//)"]*"*/"
  40.  
  41. %%
  42.  
  43. if return IF;
  44. then return THEN;
  45. elseif return ELSEIF;
  46. else return ELSE;
  47. begin return XBEGIN;
  48. end return XEND;
  49. while return WHILE;
  50. function return FUNCTION;
  51. program return PROGRAM;
  52. return return RETURN;
  53. declare return DECLARE;
  54. do return DO;
  55. and return AND;
  56. or return OR;
  57. not return NOT;
  58. := return ASSIGN;
  59. ">=" return GE;
  60. "<=" return LE;
  61. == return EQ;
  62. "<>" return NE;
  63. array return ARRAY;
  64. of return OF;
  65.  
  66.  
  67. {INTEGER} return INTEGER;
  68. {REAL} return REAL;
  69. {IDENTIFIER} return ID;
  70. "\n" ;
  71. {BADCOMMENT} printf("\nWARNING: Multiline comment inside single line comment\n");
  72. {COMMENT} ;
  73. {MCOMMENT} ;
  74. <<EOF>> yyterminate();
  75. . return yytext[0];
  76.  
  77. %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement