Skip to content

Wrong grammarFileName in generated code #3937

Closed

Description

@parrt

Somehow the grammarFileName is now messed up. We always get:

// Generated from java-escape by ANTLR 4.11.1
...
       @Override
        public String getGrammarFileName() { return "java-escape"; }

no matter what the grammar file name is. Tool code gen is messed up.

Seems to be from the templates. E.g.,

fileHeader(grammarFileName, ANTLRVersion, header) ::= <<
<header>

// Generated from <grammarFileName> by ANTLR <ANTLRVersion>
>>

LexerFileHeader(file, lexer, namedActions) ::= <<
<fileHeader(file.grammarFileName, file.ANTLRVersion, namedActions.header)>

file.grammarFileName isn't right. Could it be an error in the template engine or object we pass in?

static grammarFileName = "<parser.grammarFileName; format="java-escape">";  <=============

Activity

  1. added this to the 4.11.2 milestone on Oct 23, 2022
  2. parrt commented on Oct 23, 2022

    @parrt
    MemberAuthor

    @KvanTTT Looks like you killed java-escape in your refactoring (another reason not to resist refactoring).

    6a7e651

  3. parrt commented on Oct 23, 2022

    @parrt
    MemberAuthor

    Solution is maybe to remove java-escape from templates

  4. added a commit that references this issue on Oct 23, 2022
    263cd10
  5. KvanTTT commented on Oct 23, 2022

    @KvanTTT
    Member

    Is it just an error during template rendering? Does it cause any user bug on grammar?

  6. parrt commented on Oct 24, 2022

    @parrt
    MemberAuthor

    getGrammarFileName() functions fail for multiple targets; returns "java-escape" not T.g4 or whatever. parsing is unaffected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions