Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Pest.rs how can I manage a multi-line syntax where a line ends in "\"?

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.

like image 793
NO WAR WITH RUSSIA Avatar asked Oct 17 '25 02:10

NO WAR WITH RUSSIA


1 Answers

One method is to set your

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

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

like image 191
NO WAR WITH RUSSIA Avatar answered Oct 19 '25 19:10

NO WAR WITH RUSSIA