On May 6, 9:11 am, Miles Sabin <
mi...@milessabin.com> wrote:
> Do we really need to keep track of the nesting level?
I believe so, although I'd be delighted to be wrong. For example,
<bar> <foo>{ 3 + 2 }</foo> + "wibble" </bar> + "wobble"
XXXXXXXXXXXSSSSSSSSSXXXXXXXXXXXXXXXXXXXXXXXXSSSSSSSSSSS
(Fixed width font useful here!)
Say, for simplicity, we had just two rules for two partitions, Scala
and XML. The XML rule could happily consume up to "{" and identify the
first partition as XML. Then, a Scala rule could consume to "}" and
identify that partition as Scala. At that point, the XML rule could
start reading XML again, but how would it know when to stop and switch
back to Scala? The only real indicator, as I see it, is that the XML
nesting bottoms out, but that requires remembering information from a
previous run of the XML rule.
-- Matt