Whitespace issue with nested blocks [message #1849836] |
Fri, 04 February 2022 06:53 |
Axel Guckelsberger Messages: 354 Registered: July 2009 |
Senior Member |
|
|
Hello,
I am trying to build a rather small grammar that allows nested segments. First I tried to do it with BEGIN...AND to make it whitespace-aware, but failed to get it working in the first attempt. Hence, I switched back to brackets.
This works fine except that the closing bracket of a nested block does not allow whitespace / indentation.
Here is the relevant part of the grammar:
Segment:
'segment' subject=Subject
'{'
body=SegmentBody
NL+
WS* '}'
;
SegmentBody: {SegmentBody}
(rules+=Rule (NL+ rules+=Rule)*)+
(segments+=Segment (segments+=Segment)*)?
;
This works fine:
segment Element {
Abc is Def
segment ChildElement {
Abc is Def
}
}
But this does not:
segment Element {
Abc is Def
segment ChildElement {
Abc is Def
} <-- no viable input at '}'
}
Can't understand why it does not allow the space chars since I explicitly allowed them using
What am I missing?
Thanks for your assistance.
[Updated on: Fri, 04 February 2022 06:54] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04218 seconds