summaryrefslogtreecommitdiff
path: root/tnslc/utils
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-06-25 02:36:43 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-06-25 02:36:43 -0400
commit391153b533c9de61e801ac1815d6dcf2204e6bdb (patch)
treec4e32869e29a2e8be1e0c00f846535f317f5cc5b /tnslc/utils
parent3b5de0beed36c10798f96972ec9c9eeb142561c2 (diff)
load imported tnsl files
Diffstat (limited to 'tnslc/utils')
-rw-r--r--tnslc/utils/algo.tnsl40
1 files changed, 40 insertions, 0 deletions
diff --git a/tnslc/utils/algo.tnsl b/tnslc/utils/algo.tnsl
index 8426f9d..a08c773 100644
--- a/tnslc/utils/algo.tnsl
+++ b/tnslc/utils/algo.tnsl
@@ -200,3 +200,43 @@
return out.as_cstr()
;/
+/; unquote_cha(~uint8 cha) [uint8]
+ /; if (cha` !== '\\')
+ return cha`
+ ;/
+
+ cha++
+
+ /; if (cha` == '\"')
+ return '\"'
+ ;; else if (cha` == '\'')
+ return '\''
+ ;; else if (cha` == '\\')
+ return '\\'
+ ;; else if (cha` == 'n')
+ return '\n'
+ ;; else if (cha` == 't')
+ return '\t'
+ ;; else if (cha` == '0')
+ return 0
+ ;/
+
+ return cha`
+;/
+
+/; unquote_str(~uint8 str) [~uint8]
+ Vector out
+ out.init(1)
+
+ /; loop (str++; str` !== 0 && str` !== '\"') [str++]
+ uint8 buf = str`
+ /; if (str` == '\\')
+ buf = unquote_cha(str)
+ str++
+ ;/
+ out.push(~buf)
+ ;/
+
+ return out.as_cstr()
+;/
+