|Same optional Modifiers at multiple alternatives [message #987230]
||Sat, 24 November 2012 14:41
| Daniel Missing name
Registered: July 2011
Hi community. |
It's been a long time I was here but I just started to play around with Xtext again. In my language I can declare fields and method signatures. Both elements start with some optional modifiers, continue with a type and a name. Then the two elements have different parts. The field has an assignment and the method declares parameters. In short, this grammar rule:
Member returns PhaseMember:
('=' initializer=XExpression)? ';'
// field end
('<' typeParameters+=JvmTypeParameter (',' typeParameters+=JvmTypeParameter)* '>')?
(parameters+=Parameter (',' parameters+=Parameter)*)?
('throws' exceptions+=JvmTypeReference (',' exceptions+=JvmTypeReference)* )?
// method end
Experienced grammar writers will see immediatly: Without backtracking this leads to a non-LL(*) decision because of the modifiers.
I want to keep my grammar free of unneeded keywords and therefore I don't want to place a mandatory keyword (e.g. 'fun', 'def', 'var') in front of any element.
Does anybody of you know how I can get this grammar working without enabling (the evil) backtracking? I tried several combinations with predicates (=>) but nothing worked.
Looking forward to your suggestions.
[Updated on: Sat, 24 November 2012 14:44]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.07606 seconds