-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Boost Spirit X3 Parser recursive #749
Comments
Study the examples. There are lots of examples with such recursion. You might also want to break things up in smaller units in separate TUs. Again, there are examples you can study. |
Ty for the reply,I've read and try examples in past few days. In X3 examples, parser can be cut in to 3 parts, so reference chain can be A -> B ->C ->A. I thingk that's why the example won't trigger this problem. But in my case, In order to match end tag and begin tag, I have to use with to provide a context so I can do the match later, so I can't cut the parser. That's cause my reference chain like A -> B -> A. I think this is the reason makes templates too complex(if I'm right) . But In my case I don't know how to break it? |
Take a look at the |
This question was also posted on stack overflow where sehe gave his usual excellent answer using the context to store a stack of strings for the tags. |
Wonderful! I was about to give a follow answer on that. You beat me to the punch. |
Yeah, thanks to sehe on this part, and you may noticed that semantic actions may broke attribute propagation. Does it designed to be like that or it's a bug? |
I have to confess I did not try to compile the code, but when I did today, I got a compile error:
@Hackman1993, were you able to successfully compile sehe's code? |
OOPS, never mind. I was using wrong include flags. Sorry for noise :( |
Aha, that's always happens.spirit's variant and boost's variant is not equal. |
Hi Hackman1993, The problem with my code was more involved than just #include'ing the Nevertheless, I've attached a much simplified code which should make Here's the output from the run:
and here's the code:
Joel, maybe you could modify the code to avoid the semantic actions? -Larry |
I think it's hard to solve without semantic actions in this problem .In order to match the begin tag, we always have to match the begin tag name, Spirit won't do that for us unless we got a built-in support,. As Joel said , using Spirit Qi is more tricky. but even in Qi's mini_xml example , Joel still using a semantic action to do that. So I'm going to stick on the semantic action way and stop digging deeper. |
I'm with sehe: just use an html parser. |
@Hackman1993, the code here doesn't use semantic actions. Instead, it uses new make_transform_parser and transform_attribute_tagged. transform_attribute_tagged is pretty close to the Or you could use the pattern shown here which allows using either semantic action or the new make_transform_parser.hpp. The former pollutes the Parser namespace, that latter does not. |
I'm trying to write a parser to parse html with boost spirit x3, and I wrote parsers below:
Sorry about the long code, I've put them together so you can understand what I'm thinking。 The problem is these code can't compile. Error is :
fatal error C1202: recursive type or function dependency context too complex
I know this error comes out because of my parser html_element_ references tag_block_, and tag_block_ references html_element_, but I don't know how to make it work.
The text was updated successfully, but these errors were encountered: