How can I track my input position with multiple inputs using Boost::Spirit::Qi?

I'd like to support something like C++'s #include mechanism in a boost spirit parser. Essentially, I have a script command that asks my parser to load a sub script from a file. I'd like to be able to report error messages as described in the tracking input position while parsing post, but they don't cover parsing for multiple inputs.

Can this be reasonably accomplished using boost::spirit::qi?

I've worked around getting the differing inputs in using a smarter iterator type. I'd still like to see accurate positioning though.

Answers


IMHO, using a smart iterator is the way to go. What needs to be done is to have a stack of input contexts maintained by the iterator. Each input context stores the information related to a specific file.

Whenever a new file needs to be read (i.e. after seeing an #include statement) a new input context is created. The current input context gets pushed onto the stack, while the new context gets to be the active one. On EOF you pop the next input context from the stack, returning to the point right after the #include. If the stack is empty you reached the EOF of the main file.

In any case, the iterator only gets its input from the active input context.


Need Your Help

SVN error while taking checkout using script

bash shell svn jenkins

I am getting below error when taking checkout from svn using a script.

MarkerManager visible markers

jquery google-maps google-maps-api-3 markermanager

i'm using MarkerManager v3 and google maps to display with a lot of markers. Now everything works perfect, but I can't seem to find a way to show only the markers that the markermanager is showing....