Conditional check for String match #4172
|
Hi, Is there any possibility to do string match in antlr4 grammar. but it should not allow deletes table Persons; It should match first three characters and maximum equal to actual keyword. Without giving Hardcoded values , is there possibility to implement this? |
Replies: 1 comment 5 replies
|
Lexer rule should be (assuming case insensitivity (note formatted for readability, it does not need to be so many lines really): You will get the DELETE token for each of DEL DELE DELET DELETE Unless you feel that this is hard coded values? There is no syntactic sugar for doing this - you need to give the lexer enough information. Trivial to write a short program to write the lexer rules for you though. |
Lexer rule should be (assuming case insensitivity (note formatted for readability, it does not need to be so many lines really):
You will get the DELETE token for each of DEL DELE DELET DELETE
Unless you feel that this is hard coded values? There is no syntactic sugar for doing this - you need to give the lexer enough information. Trivial to write a short program to write the le…