Hey,
I was just wondering how to do this properly,
say I want to parse a String and collect its contents while doing so. ' " ' are 
not permitted unless they are escaped by a ' \ '.
A rule could look something like this:

        rule(:string) { str('"') >> (str('\\"') | str('"').absent? >> 
any).repeat.as(:string) >> str('"') }

While collecting everything will get collected, but it would be handy to do 
something like this:

    rule(:string) { str('"') >> (str('\\').ignore >> str('"') | 
str('"').absent? >> any).repeat.as(:string) >> str('"') }

so that the ' \ ' won't get collected with the rest, which results in the 
escape automagically being resolved :)

Is something like this possible? Is it even a good idea, or should it be done 
in the transform step?

Cheers,
Jan

Reply via email to