eclipse-xtext / eclipse-xtext/xtext
Generated internal parser contains java syntax error
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
I'm seeing a syntax error in the generated InternalMyDslParser.java file:
// InternalMyDsl.g:139:7: ( ( ( ',' ( ( ruleSwitchCaseOrDefault ) ) ) )=> ( ',' ( ( ruleSwitchCaseOrDefault ) ) ) )*
loop:
do {
int alt=; // SEE THIS LINE
switch (alt) {
case 1 :
...
break;
default :
break loop;
}
} while (true);
Minimal repro grammar file:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Expression:
expression=SwitchOperation;
SwitchOperation returns Expression:
Integer
(
=>({SwitchOperation.argument=current} operator='switch' =>(cases+=SwitchCaseOrDefault =>(',' cases+=SwitchCaseOrDefault)*)?)
)*
;
SwitchCaseOrDefault:
'default' expression=Expression
| guard=Integer 'then' expression=Expression
;
Integer returns Expression:
value=INT
;
Is there any workaround for this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the minimal repro grammar and regenerate InternalMyDslParser.java, confirming the invalid int alt=; output. Trace the parser-generation path responsible for the switch loop and consider the issue complete when the generated Java is syntactically valid for this grammar and the reproduction no longer fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100