Rule needs a delimiter? [message #1069300] |
Mon, 15 July 2013 16:15 |
Tobias Freudenreich Messages: 19 Registered: July 2013 |
Junior Member |
|
|
Hi,
I have a (at least for me strange) problem with my grammar/the JUnit parser.
Here are the relevant rules from the grammar:
Policy:
'concepts'
(concepts+=Concept)+
'conditions'
(conditions+=Condition)+
'actions'
(actions+=Action)+
Concept:
name=ID
alias=Alias
selection=Selection
;
Condition:
leftSide=[Alias] operation=ConditionOperationDebug rightSide=[Alias]
;
Alias:
name=ID
;
When I feed the parser with the following input:
concepts
person A (status='unknown')
person B (status='known')
room R (security='restricted')
conditions
A within B
A insideof R
actions
raiseAlarm IN R.building
it identifies 3 conditions ("A within B", "A insideof null", "null R null"). When I add another condition, it identifies 4 conditions, first 2 are correct, the last one is split in a similar fashion is in the shown case.
What's strange to me is that the generated editor works totally fine. It is even able to do correct highlighting (so if I click R in the actions part, it highlights R in the concepts part). Which makes me assume the thing is working in principle.
If I change the grammar to enforce a delimiter (i.e., ';') after each condition, the parser works as expected, which makes me assume there is some issue with my grammar which prevents the parser from correctly delimiting the last condition.
Does anyone have any helpful thoughts on this? Thanks.
|
|
|
Re: Rule needs a delimiter? [message #1069348 is a reply to message #1069300] |
Mon, 15 July 2013 18:09 |
|
Hi,
this confuses me a lot. imho the actual problem is that Xtext uses QualifiedNames out of the box.
thus the Aliases have the qualifed name <concept.name>.<alias.name>
if you want to reference to the you have following options
(1) Fix the naming problem by binding a custom subclass of DefaultDeclarativeNameProvider or binding SimpleNameProvider
(2) change syntax and grammar to ref=[Alias|FQN] with FQN: ID ("." ID)*; (then of course you have to change the model file too.
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03757 seconds