[Spirit] seeking help with AST tree generation

Hello, Using Boost Spirit, is it possible to write a grammar that, out of the box, generates the AST tree according to cases below: Case 1: ======= Input: 1 < 2 AND 3 < 4 OR 5 < 6 Resulting tree: OR / \ AND 5 < 6 / \ 1 < 2 3 < 4 Case 2: ======= Input: 1 < 2 AND (3 < 4 OR 5 < 6) Resulting tree: AND / \ 1 < 2 OR / \ 3 < 4 5 < 6 In other words, I want to honor the parenthesis for expression grouping. How would you recommend doing it? Thank you, Slaw

Hello,
Using Boost Spirit, is it possible to write a grammar that, out of the box, generates the AST tree according to cases below:
Case 1: =======
Input:
1 < 2 AND 3 < 4 OR 5 < 6
Resulting tree:
OR / \ AND 5 < 6 / \ 1 < 2 3 < 4
Case 2: =======
Input:
1 < 2 AND (3 < 4 OR 5 < 6)
Resulting tree:
AND / \ 1 < 2 OR / \ 3 < 4 5 < 6
In other words, I want to honor the parenthesis for expression grouping.
How would you recommend doing it?
Please refer to the spirit mailinglist:
Spirit General Mailing List

Jens Weller wrote:
Hello,
Using Boost Spirit, is it possible to write a grammar that, out of the box, generates the AST tree according to cases below:
[snip]
How would you recommend doing it?
Please refer to the spirit mailinglist: Spirit General Mailing List
Also you should take a look at the calc examples, also the AST XML generation is maybe valid for you.
I suggest going straight to Spirit2 for new uses. It's so much more powerful. See you in the mailing list. Lot's of nice people there can help you get started. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
participants (3)
-
Jens Weller
-
Joel de Guzman
-
Slawomir Lisznianski