Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %{
- #include "task.tab.h";
- %}
- %{
- int string_number = 1;
- %}
- UPDATE (?i:update)
- SET (?i:set)
- WHERE (?i:where)
- DIGIT [0-9]
- LETTER [A-Za-z]
- SPACING [\t ]+
- NEWLINE (\n)|(\r\n)
- EQUAL "="
- COMMA ","
- SEMICOLON ";"
- MINUS "-"
- SIGN {COMMA}|"?"|"!"|"."
- NUMBEROP {MINUS}|"+"|"*"|"/"
- COMPARISONOP {EQUAL}|(<>)|(<)|(>)|(<=)|(>=)
- BOOLOP (?i:AND)|(?i:OR)
- FULLNUMBER {MINUS}?{DIGIT}+(.{DIGIT}+)?
- IDEN {LETTER}({LETTER}|{DIGIT})*
- SYMBOL {DIGIT}|{LETTER}|{SIGN}
- STRING \"{SYMBOL}+\"
- %%
- {UPDATE} { printf("UPDATE\n"); }
- {SET} { printf("SET\n"); }
- {WHERE} { printf("WHERE\n"); }
- {BOOLOP} { printf("BOOLOP\n"); }
- {FULLNUMBER} { printf("FULLNUMBER\n"); }
- {NUMBEROP} { printf("NUMBEROP\n"); }
- {IDEN} { printf("IDEN\n"); }
- {COMMA} { printf("COMMA\n"); }
- {EQUAL} { printf("EQUAL\n"); }
- {STRING} { printf("STRING\n"); }
- {COMPARISONOP} { printf("COMPARISONOP\n"); }
- {SEMICOLON} { printf("SEMICOLON\n"); }
- {SPACING} { }
- {NEWLINE} { string_number++; }
- . {
- printf("Error: %d ", string_number);
- exit(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement