Table of Contents

Antlr - Lexer Grammar

About

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.

Characteristics

Only lexer grammars can contain:

Syntax

lexer grammar Name;
...

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

parser grammar MarkupParser;

options { tokenVocab=MarkupLexer; }