0

In boost spirit there are parantheses which can be used to indicate that a part of grammar is going to be repeated

    A>>(B>>C)*

I want to use this concept to write a generic scenario controller but I have no idea how they implemented that the parantheses are implicitly creating some object around B and C

Martin Kosicky
  • 471
  • 4
  • 12

1 Answers1

2

Well, it seems you're asking about the attributes of rules. Spirit can propagate the parsed content automatically to data types. Each parser, also *(...), defines rules how those data types should look like. You'll find it as "attribute propagation" in the documantation.

Here are two interesting links for this subject:

http://boost-spirit.com/home/articles/attribute_handling/attribute-propagation-and-attribute-compatibility/ http://www.boost.org/doc/libs/1_55_0/libs/spirit/doc/html/spirit/abstracts/attributes.html

Mike M
  • 2,263
  • 3
  • 17
  • 31
  • Actually i meant how did they implement the handling of operators. Like the *, + , | , >> operators while some were in parantheses and some not – Martin Kosicky Nov 21 '13 at 08:47
  • 1
    Usually you have to parse the expression and get an abstract syntax tree from it. Then you have everything encoded in that tree and you can work with that. Now you can add your logic to operators, parenthesis and combinations of such... As far as I know Spirit uses Boost Proto for the embedded grammar language but to be really sure you have to look at the code. I think what you are really asking is, how to implement a parser and an interpreter for the resulting abstract syntax tree; there is literature and plenty to read on the web for that. – Mike M Nov 21 '13 at 09:46