antlr / antlr/antlr4

Consistent naming for combined and separated grammars

Open
#37 1 comment 1 reaction 0 assignees View on GitHub
code-gen grammars type:feature
Dominant language
Java
Stars
19k
Forks
3.5k
PR merge metrics
No merged PRs in 30d

Description

Here is the current naming:
### Combined

```
grammar Foo;
```
- `FooLexer`, `FooParser`
- `FooListener`, `FooBaseListener`
- `FooParseListener`, `FooBaseParseListener`
- `FooVisitor`, `FooBaseVisitor`
### Separated

```
lexer grammar FooLexer;
parser grammar FooParser;
```
- `FooLexer`, `FooParser`
- `FooParserListener`, `FooParserBaseListener`
- `FooParserParseListener`, `FooParserBaseParseListener`
- `FooParserVisitor`, `FooParserBaseVisitor`
### Request

I find that in ANTLR 4 I'm more likely to use separated grammars than combined grammars. However, I wish the names of listeners/visitors generated by the separated grammars to match those of the combined grammar. In particular, if (and only if) a parser grammar is named `*Parser`, I'd like to drop the `Parser` suffix as part of deriving the generated file names.

Contributor guide

Open the contributing guide

Research direction

No files or tests are named in the issue. Start by locating how grammar names derive generated listener and visitor filenames; done means a separated parser grammar named with a Parser suffix produces the same listener and visitor names as the equivalent combined grammar, without changing other naming cases.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.