Parameterized parser rule [message #991177] |
Mon, 17 December 2012 10:39  |
Eclipse User |
|
|
|
I have a following grammar snippet. It describes a list item. Please note that the DSL is whitespace sensitive and TextLine ends with a line delimiter and may not contain '\t'.
UnorderedItem:
'• ' TextLine
('\t' TextLine)*;
What I'm not able to do is defining nesting. One approach is to define a second level list as shown below (pseudocode for simplicity):
UnorderedItem0:
'• ' TextLine
('\t' TextLine)*
UnorderedItem1*;
UnorderedItem1:
'\t• ' TextLine
('\t\t' TextLine)*
UnorderedItem2*;
UnorderedItem2:
'\t\t• ' TextLine
('\t\t\t' TextLine)*
UnorderedItem3*;
But this is not scalable. What I need is actually something like a parametrized parser rule:
UnorderedItem (prefix):
prefix '• ' TextLine
(prefix '\t' TextLine)*
UnorderedItem(prefix + '\t')*;
Is there anything like it in xtext? Or maybe there's some other solution that fits better.
Cheers,
Pawel
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04792 seconds