Skip to content

Adding a literal token to a grammar file when it had already been defined in the lexer file - is this legal? #4845

Open
@The-Futurist

Description

@The-Futurist

If I have a grammar g4 file and a lexer g4 file.

Then inadvertently insert a literal token like { into the grammar (when that same token has actually been defined in the lexer already) then is that legal or not?

I did this by mistake and it causes all sorts of weiredness in the antlr VS Code extension (which I just reported) but antlr itself doesn't complain, it process these files with that kind of change and generates .tokens files and does not report any error.

So in my lexer I had this (which I'd forgotten about):

Image

Which I'd totally forgotten about. But in my grammar g4 I simply changed this:

Image

to this

Image

then saved the change and then reran antlr and it ran fine but the antlr GUI tool does not, it gets very upset!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions