antlr / antlr/antlr4

How can we write multiple parsers to use the same lexer?

Open
#4,580 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
19k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

Looking at class org.antlr.v4.gui.TestRig method process() starting at line 123 I noticed that Lexer classname has to be the same as parser classname.
line 125: ```String lexerName = grammarName+"Lexer";```
How is it possible to use multiple different parsers to use the same lexer?

Contributor guide

Open the contributing guide

Research direction

Start in org.antlr.v4.gui.TestRig.process() around line 123 and inspect how line 125 derives the lexer class name from the grammar name. Trace the TestRig entry point and related argument handling to determine whether multiple parser grammars can share one lexer; done means establishing and documenting a supported way to do so, or clearly identifying the limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.