
locals<> are - well - local to the rule they are defined for. Each invocation of that rule creates a new instance of the local variables, very much like local vaiables in functions.
So if I have something like this (a very much contrived example): struct myGrammar: grammar< .... > { rule< .... locals< types > .... > some_rule; myGrammar() : base_type( .... ) { some_rule = parser_1[ _a = _1 ] << parser_2( _a ); } }; then "_a" would indeed refer to "some_rule"'s local variable? Are the grammar's local variables effectively identical to its start rule's local variables? Ditto _val and _rN?
I must admit I don't fully understand what you're trying to achieve. But one thing I do know for sure: you shouldn't need to even look at proto, not even talking about using it. Everything should be accessible by utilizing Spirit's own facilities.
And so I was hoping too :) Let me try and elaborate, perhaps I am not even approaching the problem from the right side. Basically, I'd like to map a subset of JSON schema specification (http://tools.ietf.org/html/draft-zyp-json-schema-03; http://www.json-schema.org) to a set of type declarations (that can be compiled from the actual schema) and have the serializers/deserializers for these types build their grammars automatically. I realize that the alternative is to use a fixed grammar and customized attribute conversion but this seems to require temporary dynamic data structures that will be built by the Kleene star and such. I was hoping to have my parsers push the data directly into user-defined objects.
If you need to invoke an arbitrary parser at runtime, try to look at the lazy() construct, which takes whatever is passed to it and evaluates it as a parser expression. See here for an example: http://boost-spirit.com/home/articles/qi-example/nabialek-trick/
This looks very similar to what I'm trying to do, thank you very much! Unfortunately I have next to no experience with Spirit (or Fusion... or Phoenix... :) ) even though I've been using many other Boost libraries for ages, so once I can't resolve something by looking in the docs I don't really know what to google for... Thanks again for your help! ...Max...