4

A common idiom for bash is is to use \ to escape the newline at the end of the line,

If a \<newline> pair appears, and the backslash is not itself quoted, the \<newline> is treated as a line continuation (that is, it is removed from the input stream and effectively ignored).

Such that

FOO \
BAR

is the same as,

FOO BAR

How would I write this grammar into pest.rs? Note this means that NEWLINE is significant in my grammar, and I can't merely ignore it.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

2

One method is to set your

WHITESPACE = { ( " "* ~ "\\" ~ NEWLINE ~ " "* ) }

This keeps regular newlines significant unless they're prefixed by \.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468