multiple alternatives error during the generation of the artifacts [message #1800361] |
Tue, 25 December 2018 22:09 |
kozhaev Vladimir Messages: 108 Registered: July 2009 |
Senior Member |
|
|
Hi all
When I try to generate the grammar have the error.
It happens because of the question in the rule
Atomic returns Expression:
{IntConstant} value=INT |
{StringConstant} value=STRING |
{BoolConstant} value=('true' | 'false') |
{VariableRef} "."? value=VariableDeclarationRef | //Error because of this string
{SelectOp} value=AtOperator |
{MemberDefinition} value=ClassMemberDefinition|
{CreateAtom} value=Create;
But, when I remove the question everything is fine. I know why this error is happening in main but don't understand this particular case.
My grammar is
grammar org.blockchain.rell.Rell with org.eclipse.xtext.common.Terminals
generate rell "http://www.blockchain.org/rell/Rell"
Model:
entities+=ClassDefinition*
operations+=Operation*;
ClassDefinition:
'class' name=ID ('extends' superType=[ClassDefinition])? '{'
attributeListField+=AttributeListField*
'}';
AttributeListField:
mutable=Mutable? key=Key? index=Index? attributeList+=RelAttrubutesList ';';
Operation:
"operation" name=ID "(" parameters=RelAttrubutesList? ")" "{" statements+=Statement* "}";
Statement:
(relation=Relational | variable=OperationVariable) ';';
OperationVariable:
assessModificator=(Var | Val) variable=Variable;
Variable:
name=VariableDeclaration (('=' expression=Expression)?);
Relational:
Update | Delete | Create | AtOperator;
Update:
'update' entity=[ClassDefinition] '(' conditions+=Expression* ')' '{' variableList+=VariableInit
(',' variableList+=VariableInit*)? '}';
Delete:
'delete' entity=[ClassDefinition] '(' conditions+=Expression (',' conditions+=Expression)* ')';
Create:
'create' (entity=[ClassDefinition]) '(' (createWhatPart+=CreateWhatPart (','
createWhatPart+=CreateWhatPart)*)? ')';
CreateWhatPart:
(varDeclRef=VariableDeclarationRef '=')?
condition+=Expression;
AtOperator:
(tableNameWithAlias+=TableNameWithAlias | '(' tableNameWithAlias+=TableNameWithAlias (','
tableNameWithAlias+=TableNameWithAlias)* ')') Ampersand ampersandModificator=AmpersandModificator? '{'
conditions+=Expression (',' conditions+=Expression)* '}';
ClassMemberDefinition:
classRef=ClassRef "." variableDeclarationRef=VariableDeclarationRef;
ClassRef:
value=[TableNameWithAlias];
TableNameWithAlias:
{ClassRefDecl} (name=ID ':' classDef=[ClassDefinition]) |
{JustNameDecl} name=[ClassDefinition];
VariableDeclarationRef:
decl=[VariableDeclaration|ValuableID];
VariableInit:
name=[VariableDeclaration] '=' expression=Expression;
Expression:
or=Or;
Or returns Expression:
And ({Or.left=current} "or" right=And)*;
And returns Expression:
Equality ({And.left=current} "and" right=Equality)*;
Equality returns Expression:
Comparison ({Equality.left=current} op=("==" | "!=")
right=Comparison)*;
Comparison returns Expression:
PlusOrMinus ({Comparison.left=current} op=(">=" | "<=" | ">" | "<")
right=PlusOrMinus)*;
PlusOrMinus returns Expression:
MulOrDiv (({Plus.left=current} PlusChar | {Minus.left=current} MinusChar)
right=MulOrDiv)*;
MulOrDiv returns Expression:
Primary ({MulOrDiv.left=current} op=(MulChar | DivChar)
right=Primary)*;
Primary returns Expression:
'(' Expression ')' |
{Not} "not" expression=Primary |
Atomic;
Atomic returns Expression:
{IntConstant} value=INT |
{StringConstant} value=STRING |
{BoolConstant} value=('true' | 'false') |
{VariableRef} "."? value=VariableDeclarationRef | //Error because of this string
{SelectOp} value=AtOperator |
{MemberDefinition} value=ClassMemberDefinition|
{CreateAtom} value=Create;
RelAttrubutesList:
value+=Variable (',' value+=Variable)*;
VariableDeclaration:
name=ValuableID ((':' type=TypeReference)?);
TypeReference:
primitive=PrimitiveType | entityType=ClassType;
ClassType:
type=[ClassDefinition];
PrimitiveType:
Text | Tuid | Pubkey | Name | Timestamp | Integer | Json | ByteArray | Boolean;
ValuableID:
PrimitiveType | ID;
AmpersandModificator:
PlusChar | MulChar | QuestionChar;
Name:
'name';
Pubkey:
'pubkey';
Timestamp:
'timestamp';
Tuid:
'tuid';
Boolean:
'bool';
Json:
'json';
Integer:
'integer';
Text:
'text';
ByteArray:
'byte_array';
List:
'list';
Key:
'key';
Index:
'index';
Mutable:
'mutable';
Var:
'var';
Val:
'val';
Ampersand:
'@';
QuestionChar:
'?';
PlusChar:
'+';
MinusChar:
'-';
MulChar:
'*';
DivChar:
'/';
Error log is
Quote:
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'name'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'byte_array'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'bool'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'text'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'tuid'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'timestamp'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'integer'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'pubkey'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' 'json'" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
warning(200): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: Decision can match input such as "RULE_ID '.' RULE_ID" using multiple alternatives: 4, 6
As a result, alternative(s) 6 were disabled for that input
error(201): ../org.blockchain.rell/src-gen/org/blockchain/rell/parser/antlr/internal/InternalRell.g:2062:2: The following alternatives can never be matched: 6
p.s. Sorry for the too long grammar, but I'm not sure how to simplify it
|
|
|
Re: multiple alternatives error during the generation of the artifacts [message #1800380 is a reply to message #1800361] |
Wed, 26 December 2018 08:42 |
|
did you try to create a debug grammar
parserGenerator={debugGrammar=true}
an analyze with antlrworks?
here is at least one minimal grammar that shows at least one of the problems
Model:
'update' entity=ID '(' conditions+=Atomic* ')' '{' '}';
Atomic returns Expression:
{VariableRef} "."? value=ValuableID | //Error because of this string
{MemberDefinition} value=ClassMemberDefinition
;
ValuableID:ID;
ClassMemberDefinition:
classRef=ClassRef "." variableDeclarationRef=ValuableID;
ClassRef:
value=ID;
is update x (a .b) a ClassMemberDefinition or two VariableRefs?
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03653 seconds