kschiess / parslet

A small PEG based parser library. See the Hacking page in the Wiki as well.
kschiess.github.com/parslet
MIT License
809 stars 95 forks source link

preprocess string before parsing? #182

Closed sethboyles closed 6 years ago

sethboyles commented 7 years ago

I would like to preprocess a string before the parser parses everything. For instance, I would like to replace all left and right quote characters with normal quotes " rather than having to write the extra cases into all of my rules. Is there an easy way to handle that in Parslet?

Thanks

kschiess commented 6 years ago

What stops you from handling this in Ruby before using parslet?

sethboyles commented 6 years ago

Nothing, just wondering if Parslet provided anything for this.

kschiess commented 6 years ago

There would be no good place to do this in the parsing pipeline; it would risk making everything slower. If string.tr or a string.replace can work, I would suggest using that.