Skip to content

Conditional check for String match #4172

Answered by jimidle
techpranav asked this question in Q&A
Discussion options

You must be logged in to vote

Lexer rule should be (assuming case insensitivity (note formatted for readability, it does not need to be so many lines really):

DELETE: ('D'|d')('E'|'e')('L'|'l')   // DEL always required
                ( 
                    ('E'|'e')    // DELE
                         ( 
                             ('T'|'t')   // DELET
                                     ('E'|'e')?  // DELETE 
                         )? 
                )? 
      ;

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…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@techpranav
Comment options

@KvanTTT
Comment options

@jimidle
Comment options

@jimidle
Comment options

@KvanTTT
Comment options

Answer selected by techpranav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants