How to push the default mode in antlr4

Viewed 570

I am currently writing an antrl4 grammar with multiple lexical modes. And it is easy to push modes that have an explicit name and then return to the default mode by popping the current mode.

OPEN_PARENTHESIS : '(' -> pushMode(IN_PARENTHESES);

mode IN_PARENTHESES;

CLOSE_PARENTHESIS : ')' -> popMode;

But now I am in a situation where there are several modes on the stack, and I still want to return to the default mode without popping everything that is on the stack. So my question is, is it possible to return to the default mode by doing something along the lines of pushMode(DEFAULT)?

1 Answers
Related