Implementing dates clashes with simple equations [message #1798228] |
Wed, 14 November 2018 09:00  |
Eclipse User |
|
|
|
Good day! I just started learning Xtext a few days ago and am trying to create a grammar that can assign to variables both simple equations with round brackets and a calendar date.
My grammar for the date part is the following:
Group:
(BracketGroup | NonBracketGroup | Operand )
(operators+=Operator '('* operands+=Operand
(operators+=Operator operands+=Operand) ')'*)*
;
BracketGroup:
'('NonBracketGroup')' (operators+=Operator operands+=Operand)+
;
NonBracketGroup:
'('?
operands+=Operand
(operators+=Operator operands+=Operand)+ ')'?
Value:
STRING | '-'?INT | Decimal | Logical | DATA
;
DATA: MONTH'/'DAY'/'YEAR;
DAY: INT;
MONTH: INT;
YEAR: INT;
DataType:
'character' | 'integer' | 'decimal' | 'logical' | 'date'
;
Operator:
'+' | '-' | '*' | '/' | 'MODULO' | EQ | '>'| '<' | '=>' | '=<' | '<>' | GroupOperator
This leads to:
Decision can match input such as "RULE_INT '/' RULE_INT '/' {RULE_INT, '.'..'FALSE'}" using multiple alternatives: 2, 5
I think that making the '/' a fragment might fix the issue, but I don't really understand how it works (tried multiple sources online) nor how to implement it. If someone could show me the way to stop making the rules clash would help me a lot.
If what I wrote is not sufficient as info please don't hesitate to ask for more, I am a total beginner and might have omitted important stuff.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.12003 seconds