Parse arbitrary delimiter character using Antlr4
问题 I try to create a grammar in Antlr4 that accepts regular expressions delimited by an arbitrary character (similar as in Perl). How can I achieve this? To be clear: My problem is not the regular expression itself (which I actually do not handle in Antlr, but in the visitor), but the delimiter characters. I can easily define the following rules to the lexer: REGEXP: '/' (ESC_SEQ | ~('\\' | '/'))+ '/' ; fragment ESC_SEQ: '\\' . ; This will use the forward slash as the delimiter (like it is