How can I check if first character of a line is “*” in ANTLR4?
问题 I am trying to write a parser for a relatively simple but idiosyncratic language. Simply put, one of the rules is that comment lines are denoted by an asterisk only if that asterisk is the first character of the line. How might I go about formalising such a rule in ANTLR4? I thought about using: START_LINE_COMMENT: '\n*' .*? '\n' -> skip; But I am certain this won't work with more than one line comment in a row, as the newline at the end will be consumed as part of the START_LINE_COMMENT