Reputation: 23
I am new to xtext (antlr), and don't understand why there is ambiguity between IconType '}' and WindowType '}'.
I get the
warning(200): ../org.simsulla.tools.ui.gui/src-gen/org/simsulla/tools/ui/gui/parser/antlr/internal/InternalGui.g:137:1: Decision can match input such as "'windowType'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../org.simsulla.tools.ui.gui.ui/src-gen/org/simsulla/tools/ui/gui/ui/contentassist/antlr/internal/InternalGui.g:117:38: Decision can match input such as "'windowType' '=' '{' 'name' '=' RULE_ID 'iconType' '=' '{' 'name' '=' RULE_ID 'spriteType' '=' RULE_STRING 'Orientation' '=' RULE_STRING '}' '}'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
This is my grammar
Ui:
guiTypes+=GuiTypes+;
GuiTypes:
windowType+=WindowType+
;
WindowType:
'windowType' '=' '{'
'name' '=' name=STRING
iconType+=IconType*
'}'
;
IconType:
'iconType' '=' '{'
'name' '=' name=STRING
'spriteType' '=' spriteType=STRING
'Orientation' '=' Orientation=STRING
'}'
;
Upvotes: 0
Views: 663
Reputation: 5256
The grammar fragment has multiple ways of repeating WindowType
:
Ui
to GuiTypes
to multiple WindowType
instances, orUi
to multiple GuiTypes
instances where each derives to a WindowType
, orSo a given input corresponds to multiple different parse trees. The grammar is thus ambiguous.
Upvotes: 1