diff options
author | Rory Dudley | 2024-09-01 04:26:32 -0600 |
---|---|---|
committer | Rory Dudley | 2024-09-02 01:00:26 -0600 |
commit | 5c29835f70178e64daeae9b82111fe31376f6f35 (patch) | |
tree | 8b82edaa874486fe46a12a25e408f796f8a5d875 /src/poem/read/parse.rs | |
parent | 6328666624e59574946f7af1570c5676aa54d0ac (diff) | |
download | dwarvish-5c29835f70178e64daeae9b82111fe31376f6f35.tar.gz |
Allow escaping characters
This patch adds the '\' character as a new rune, Rune::Special. This is
for escaping special characters. Also works in strings (", ').
Signed-off-by: Rory Dudley <rory@netc.lu>
Diffstat (limited to 'src/poem/read/parse.rs')
-rw-r--r-- | src/poem/read/parse.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/poem/read/parse.rs b/src/poem/read/parse.rs index fc1979f..0b6c5a3 100644 --- a/src/poem/read/parse.rs +++ b/src/poem/read/parse.rs @@ -74,6 +74,14 @@ macro_rules! string { $word.push('\x0e'); $i += 1; } + Some(c) if c == '\\' => { + let c = match $chars.next() { + Some(c) => c, + None => continue, + }; + $word.push(c); + $i += 1; + } Some(c) => { $word.push(c); $i += 1; @@ -108,6 +116,14 @@ macro_rules! poem { match $chars.next() { None => return Err(Mishap::PartialMishap($j, $i, $c)), Some(c) if c == token => break, + Some(c) if c == '\\' => { + let c = match $chars.next() { + Some(c) => c, + None => continue, + }; + $word.push(c); + $i += 1; + } Some(c) => { poetry.push(c); $i += 1; |