tags:

views:

26

answers:

0

I'm writing my first DSL with Oslo and I am having a problem with a recursive syntax definition.

The input has sections which can contain questions or other sections recursively (composite pattern) like this:

Section: A
  Question: 1
  Question: 2

  Section: B
    Question: 1
  End
End  

My definition for a Section looks like this

syntax Section = "Section:"  id:Text
                   body:(SectionBody)*
                 "End Section";

Which works (but doesn't handle recursive sections) if I define SectionBody like this

    syntax SectionBody = (Question);

but doesn't work with a recursive definition like this

    syntax SectionBody = (Question | Section);

What am I missing?