antlr / antlr/antlr4

Mismatched and expecting the same token

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

Description

Hello, I have been testing in the [ANTLR LAB](http://lab.antlr.org/) and I cannot understand this error. The screenshot I attach below shows a simple grammar and an error indicating that the token it found is different from the one it was expecting, but it is the same, it doesn't make sense.
Why is it like this?
Thank you

![image](https://github.com/antlr/antlr4/assets/26380095/37c1b184-a7cd-4469-8ad1-a5d7e72bf37a)

The example grammar:
grammar Example;

class:
ABSTRACT 'class' IDENTIFIER;

IDENTIFIER: [A-Za-z_][A-Za-z0-9_]*;
ABSTRACT: 'abstract';

// Ignore
WS: [ \r\n\t]+ -> skip;

The example input:
abstract class Plane

Contributor guide

Open the contributing guide

Research direction

Reproduce the report in the ANTLR LAB using the Example grammar and input `abstract class Plane`. Inspect the generated token and parser output to determine whether the mismatch is an ANTLR defect or expected grammar behavior; done should be a confirmed explanation with a narrowly defined follow-up change if a defect is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.