I'm trying to implement a rule in my boost spirit qi grammar that will behave like QUOTE in a Lisp-like language.
Something like: QUOTE(a b c)
The idea is that anything between QUOTE's opening and closing parenthesis will be captured into a string literal, rather than being parsed any further.
Since the '(' or ')' character may be present inside of a QUOTE, I can't use: '\"' >> *~char_('\"') >> '\"' and instead need to keep track of parenthesis to determine the end-of-quote.
For example: QUOTE(a ( b c ) d) Here, I would want to parse the contents "a ( b c ) d" as a string literal.
I can think of a few ways to do this, the general idea being to keep a local variable to increment/decrement the parenthesis depth, etc.
Due to the inefficiency of semantic actions, I was hoping someone might comment an efficient way to approach this problem.
Thanks!