I wrote a small library that helps in this case: antlr-denter .
In short, you define the INDENT and DEDENT tokens in your grammar, do some template details to anchor the antlr-denter in the antlr created by lexer, and off you go. For example, the code is as follows:
hello: world <eof>
It is possible to create a WORD COLON INDENT WORD DEDENT .
source share