Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCross-referencing two different rules?
https://www.eclipse.org/forums/index.php/mv/msg/1108061/1841696/#msg_1841696
ReferenceDataType:
'{'
'"column"' ':' column = INT ','
'"row"' ':' row = INT ','
'"type"' ':' '"reference"' ','
// '"value"' ':' (value = [Object|STRING_WITH_TOKENS] | value = [Array|STRING_WITH_TOKENS])
'}'
;
This, however, gives: Decision can match input such as "RULE_STRING_WITH_TOKENS" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
The following alternatives can never be matched: 2
Don't really see the problem, as both Object and Array differs. Backtrack lexer is set to true.
The grammar is here:
Element:
Object | Array | Alternative | Attribute
;
Object:
'{'
'"column"' ':' column = INT ','
'"row"' ':' row = INT ','
'"name"' ':' name = STRING_WITH_TOKENS ','
'"type"' ':' '"object"' ','
'"isOptional"' ':' isOptional = BOOLEAN ','
'"children"' ':' '[' elements += Element? (',' elements += Element)* ']' ','
'"dataTypes"' ':' '[' ']'
'}'
;
Array:
'{'
'"column"' ':' column = INT ','
'"row"' ':' row = INT ','
'"name"' ':' name = STRING_WITH_TOKENS ','
'"type"' ':' '"array"' ','
'"isOptional"' ':' isOptional = BOOLEAN ','
'"children"' ':' '[' elements += Element? (',' elements += Element)* ']' ','
'"dataTypes"' ':' '[' ']'
'}'
;
CustomDataType:
'{'
'"column"' ':' column = INT ','
'"row"' ':' row = INT ','
'"type"' ':' '"custom"' ','
'"value"' ':' value = [Rule|STRING_WITH_TOKENS]
'}'
;
PredefinedDataType:
'{'
'"column"' ':' column = INT ','
'"row"' ':' row = INT ','
'"type"' ':' '"predefined"' ','
'"value"' ':' value = PREDEFINED_TYPE
'}'
;
ReferenceDataType:
'{'
'"column"' ':' column = INT ','
'"row"' ':' row = INT ','
'"type"' ':' '"reference"' ','
'"value"' ':' (value = [Object|STRING_WITH_TOKENS] | value = [Array|STRING_WITH_TOKENS])
'}'
;]]>M D2021-05-25T21:31:39-00:00Re: Cross-referencing two different rules?
https://www.eclipse.org/forums/index.php/mv/msg/1108061/1841699/#msg_1841699
// '"value"' ':' (value = [Object|STRING_WITH_TOKENS] | value = [Array|STRING_WITH_TOKENS])
Is the same as
// '"value"' ':' (value =STRING_WITH_TOKENS | value = STRING_WITH_TOKENS
Which should give you an idea why it is ambiguous
So you have basically two options
(A) have different syntaxes for both refs
(B) have only on ref
ArrayOrObject: Array|Object; //new rule , uncalled , to introduce common supertype
':' (value = [ArrayOrObject|STRING_WITH_TOKENS]
]]>Christian Dietrich2021-05-26T04:21:47-00:00Re: Cross-referencing two different rules?
https://www.eclipse.org/forums/index.php/mv/msg/1108061/1841796/#msg_1841796
M D2021-05-30T09:13:27-00:00