From: Dean M. B. <mik...@gm...> - 2009-08-15 15:24:11
|
Hi Kim! On Sat, Aug 15, 2009 at 4:21 AM, Kim Gräsman<kim...@gm...> wrote: > > I know I struggled with this when I did it with Spirit + Phoenix, I > don't know how Spirit 2 is different. The only way I could find was to > keep a buffer variable containing the possible user info, and then > commit to it once an @ was found. > Yeah, that's one way. The other way I was struggling with was with doing a "longest match" ala-regex where if you found an @ character, what you've seen before it is something you deal with differently. I tried doing something with the 'lexeme' parser with multiple nested lexemes -- this seemed to have worked, except that I can't seem to do the parsing grammar correctly. I've avoided trying to create my own parser type and just try and do everything in-lined to keep it simple, but it proves to be a pretty hard thing to do. > See my confusion in action here: > http://cpp-netlib.svn.sourceforge.net/viewvc/cpp-netlib/branches/uri/boost/network/uri.hpp?revision=143&view=markup > > I don't know if that helps at all, but maybe you can find inspiration > somehow... It looks like the Spirit 2 grammar has an entirely > different form, so I don't really see how it ties into the Spirit 1 > model. > Thanks for the link, yes I see the approach that seems to work -- however I'm not very keen on using Spirit 1 anymore at the moment having seen that the performance and expressiveness of Spirit 2x seems to be better. For instance, it's more efficient not having to use Phoenix and just have direct storage for assigning resulting values. Maybe you want to have a hand at Spirit 2x, and translating the logic you have there but without having to use Phoenix explicitly? Maybe you can express it as a normal "longest match" parser? :D Thanks again Kim. :) -- Dean Michael Berris blog.cplusplus-soup.com | twitter.com/mikhailberis linkedin.com/in/mikhailberis | facebook.com/dean.berris | deanberris.com |