Boost logo

Boost Users :

Subject: [Boost-users] [Spirit 2] Questions related to generating grammars meta-dynamically
From: Max Motovilov (max_at_[hidden])
Date: 2010-11-29 16:15:30


I'm trying to create a serialization facility that builds the underlying
Spirit grammars based on a data model extracted from user-supplied types
(I guess meta-dynamically ought to be the right word :) ). In doing so,
I seem to quickly run out of documentation coverage and accumulate
questions that are not easily answered by perusing the source code. Here
are the more painful members of that collection, posted in the hopes
that someone more informed might answer them for me:

- What are the respective scopes of the rule and the grammar?
Specifically, within a parser expression (situated within a grammar's
constructor, according to the pattern established in the examples) which
of the locals<> can I refer to in the sub-expressions specifying
explicit parser parameters and semantic actions?

- I'd like to write a functor that selects one of the grammars from a
list (Fusion sequence), and passes an argument (inherited attribute) to
it; the [parser-like] result returned by this functor would then be used
in an enclosing parser expression. Is there an easily computable type
that such a functor can return? I have noticed that the implementations
of grammar<>::operator() return a very intricate construct that would be
hard to replicate outside Spirit code --

   proto::terminal<
     spirit::qi::parameterized_nonterminal<
       start_type, supplied-argument-types...
>
>

-- but maybe there is a simpler front-end type the above is convertible
to and that will still work as a component of parser expression?

Thanks in advance,
...Max...


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net