aboutsummaryrefslogtreecommitdiff
path: root/parser.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-19 20:41:31 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-19 20:42:09 -0700
commit47db74229deaf281ad02c8305c4e4d4c8dbd3d7d (patch)
treefac39ef65240c3de58b68a4f59bb93f2d4e622c6 /parser.moon
parent0eff1c77f250e6839086f41af0c79bb3e2e8ea39 (diff)
Fixed some bugs in trailing_line_len() and refactored tree_to_nomsu into
separate inline/not-inline functions.
Diffstat (limited to 'parser.moon')
-rw-r--r--parser.moon7
1 files changed, 7 insertions, 0 deletions
diff --git a/parser.moon b/parser.moon
index 993fd54..1998ae2 100644
--- a/parser.moon
+++ b/parser.moon
@@ -144,4 +144,11 @@ Parser.is_operator = (s)->
Parser.is_identifier = (s)->
return not not (NOMSU_DEFS.ident_char^1 * -1)\match(s)
+inline_escaper = re.compile "{~ (%utf8_char / ('\\' -> '\\\\') / [ -~] / ('\n' -> '\\n') / ('\t' -> '\\t') / ('\b' -> '\\b') / ('\a' -> '\\a') / ('\v' -> '\\v') / ('\f' -> '\\f') / ('\r' -> '\\r') / ('\"' -> '\\\"') / (. -> escape))* ~}", {utf8_char: NOMSU_DEFS.utf8_char, escape:(=> ("\\%03d")\format(@byte!))}
+Parser.inline_escape = (s)->
+ return inline_escaper\match(s)
+escaper = re.compile "{~ (%utf8_char / ('\\' -> '\\\\') / [\n\r\t -~] / (. -> escape))* ~}", {utf8_char: NOMSU_DEFS.utf8_char, escape:(=> ("\\%03d")\format(@byte!))}
+Parser.escape = (s)->
+ return escaper\match(s)
+
return Parser