Advertisement
Guest User

Untitled

a guest
Dec 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. %{
  2. #include "task.tab.h";
  3. %}
  4. %{
  5. int string_number = 1;
  6. %}
  7. UPDATE (?i:update)
  8. SET (?i:set)
  9. WHERE (?i:where)
  10. DIGIT [0-9]
  11. LETTER [A-Za-z]
  12. SPACING [\t ]+
  13. NEWLINE (\n)|(\r\n)
  14. EQUAL "="
  15. COMMA ","
  16. SEMICOLON ";"
  17. MINUS "-"
  18. SIGN {COMMA}|"?"|"!"|"."
  19. NUMBEROP {MINUS}|"+"|"*"|"/"
  20. COMPARISONOP {EQUAL}|(<>)|(<)|(>)|(<=)|(>=)
  21. BOOLOP (?i:AND)|(?i:OR)
  22. FULLNUMBER {MINUS}?{DIGIT}+(.{DIGIT}+)?
  23. IDEN {LETTER}({LETTER}|{DIGIT})*
  24. SYMBOL {DIGIT}|{LETTER}|{SIGN}
  25. STRING \"{SYMBOL}+\"
  26. %%
  27. {UPDATE} { printf("UPDATE\n"); }
  28. {SET} { printf("SET\n"); }
  29. {WHERE} { printf("WHERE\n"); }
  30. {BOOLOP} { printf("BOOLOP\n"); }
  31. {FULLNUMBER} { printf("FULLNUMBER\n"); }
  32. {NUMBEROP} { printf("NUMBEROP\n"); }
  33. {IDEN} { printf("IDEN\n"); }
  34. {COMMA} { printf("COMMA\n"); }
  35. {EQUAL} { printf("EQUAL\n"); }
  36. {STRING} { printf("STRING\n"); }
  37. {COMPARISONOP} { printf("COMPARISONOP\n"); }
  38. {SEMICOLON} { printf("SEMICOLON\n"); }
  39. {SPACING} { }
  40. {NEWLINE} { string_number++; }
  41. . {
  42. printf("Error: %d ", string_number);
  43. exit(1);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement