In the language I work with, some keywords must be at the start of the line. This is mainly because string values within the language can go over multiple lines, and strings could easily contain these keywords.
The old yacc/lex grammar implementation I have easily deals with this because the lexer uses normal regexes to match text patterns, e.g.
^description { actions }
matches 'description
' at the start of a line and then does actions.
How can I do this in Antlr4? It does not appear to support proper regex for lexical matching. I'm using the IntelliJ plugin, and it complains when I use the '^
' character on any lexer rule RHS.
DescKeyWord : BOL [ \t]* 'description' ;
. – Selfcontent