Xtext grammar [message #1731328] |
Wed, 04 May 2016 06:43  |
Eclipse User |
|
|
|
Hi,
I have syntax like
def a, a[10](10), a(10)[10], a{10}[10](10), a(10)[10){10}, a[10]{10}(10)
No guarantee of order of declaration for [10] or {10} or (10).
I have written grammar like this
Decl : 'def' name+=ID
(isArray?='[' (maxOccurs+=NUMBER) ']')?
(isRange?='[' (range+=RANGE) ']')?
(isChar?='[' (Id+=ID) ']')?
(hasSize ?= '(' varsize=NUMBER ')')?
('=' Id+=ID ('(' Id+=ID (','? Id+=ID)* ')')?)?
('=' const=Constant)?
('=' string=STRING)? ','?
;
I know here my grammar follows the order of definition. How can I handle this which allows me all the orders?
|
|
|
|
|
|
|
|
|
Re: Xtext grammar [message #1731526 is a reply to message #1731523] |
Fri, 06 May 2016 09:29  |
Eclipse User |
|
|
|
well i had hoped for a minimal reproducable example not 200 lines of grammar.
the there is a question you have to answer: a assignment can start with a assignment?
Assignment: ('math')? (expression+=Expression '=' expression+=Expression) (',' expression+=Expression'=' expression+=Expression)*;
Expression:
Primary
;
Primary returns Expression: value+=NUMBER |assignment+=Assignment
;
i dont know if that is intended
thats the point of the left recusion.
what should happen here ?!?
and it makes no sense to me since this is already handled on assignmentlevel ?!?
|
|
|
Powered by
FUDForum. Page generated in 0.04704 seconds