[Pyparsing] Newline-Sensitive Languages
Brought to you by:
ptmcg
|
From: Eric D. <eri...@gm...> - 2017-07-10 21:40:13
|
What is the best way to create a newline-sensitive language (like Python
itself)? I continually run into problems where the newlines are eaten by
the automated whitespace-grabber, and I've found what I believe to be
two working solutions:
- Attach .setWhitespaceChars(' \t') to the end of all of the low-level
parsers so that, when combined, they don't gobble up newlines.
- Add White(' \t') between all low-level parsers, such that they eat
non-newline whitespace but not the newlines.
Neither one of these is particularly elegant. It would be nice if
.setWhitespaceChars propagated down to children (like .ignore does), but
I don't expect it to be changed anytime soon because it would break
backwards compatibility pretty bad for anyone who was using either one
of these methods of producing newline-dependent languages.
Which of these two is preferable? Or, alternatively, is there an even
better way that I haven't thought of yet?
Thanks in advance!
|