xtext syntax question [message #713615] |
Mon, 08 August 2011 12:50  |
Eclipse User |
|
|
|
Hi,
I'd like to create a rule having mix content of text and nested rules. a la:
Model[
text img text img text ...
]
So I've tried combining them by optional elements. But the grammar
parser always complains on multiple alternatives. How can I solve such
issue?
Here is a sample grammar:
grammar org.xtext.example.mydsl.MyDsl with
org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model: {Model} "Model";
Element: {Element} content+=Line*;
Line: (content+=Text | content+=Image) ;
Text: text=STRING;
Image: "img[" image=STRING "]";
The parser should be able distingushing between "text" and img[, but he
doesn't :-(
Sven
|
|
|
|
|
|
|
Re: xtext syntax question [message #713992 is a reply to message #713891] |
Tue, 09 August 2011 09:36  |
Eclipse User |
|
|
|
Hi Sven,
to begin with, you should either
a) allow only one element in your model rule between the brackets
or
b) make an element consist only of one MixedContent.
Both approaches will lead to a model that contains any number of
MixedContent instances but with a reduced complexity in the structure of
the model.
Does that make sense?
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
On 09.08.11 12:07, Sven Krause wrote:
> Am 09.08.2011 09:05, schrieb Sebastian Zarnekow:
>> Hi Sven,
>>
>> I'm surprised. Your solution should suffer from the same problems as
>> your first approach, e.g. rule Element may match the empty input and the
>> parser cannot decide, how often it should descend into Element coming
>> from rule Model.
>>
>> No, there is no difference between 'keyword' and "keyword".
>>
>> Regards,
>> Sebastian
>
> Ok Sebastian,
>
> but what is the proposed syntax model for such a construct >"text"
> something "text"< ?
>
> Sven
|
|
|
Powered by
FUDForum. Page generated in 0.11237 seconds