Antlr - Lexer Grammar


The grammar file of the lexer is composed of lexer rule, optionally broken into multiple lexical modes

The most common approach is to combine combined in in one grammar file, the lexer and parser grammar.


Only lexer grammars can contain:

  • mode specifications.
  • custom channels specifications


lexer grammar Name;

In the parser grammar, you define the lexer with the tokenVocab option.

parser grammar MarkupParser;

options { tokenVocab=MarkupLexer; }

Powered by ComboStrap