我是xtext(antlr)的新手,并且不明白为什么IconType'}'之间存在歧义。和WindowType'}'。
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
这是我的语法
Ui:
guiTypes+=GuiTypes+;
GuiTypes:
windowType+=WindowType+
;
WindowType:
'windowType' '=' '{'
'name' '=' name=STRING
iconType+=IconType*
'}'
;
IconType:
'iconType' '=' '{'
'name' '=' name=STRING
'spriteType' '=' spriteType=STRING
'Orientation' '=' Orientation=STRING
'}'
;
答案 0 :(得分:1)
语法片段有多种方式重复WindowType
:
Ui
到GuiTypes
派生到多个WindowType
个实例,或Ui
派生到多个GuiTypes
个实例,其中每个实例都派生为WindowType
或因此给定的输入对应于多个不同的解析树。语法因此含糊不清。