summaryrefslogtreecommitdiff
path: root/tnslc/util.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-09-20 00:40:13 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-09-20 00:40:13 -0400
commitb0fb30d09c592d93db5d1cc403dcd6744d083d78 (patch)
treec14df5e2c674e4350d8f768b272cab74a518259d /tnslc/util.tnsl
parentbe9813b1062c1f9b2c0d13a76d56c41ba984c1db (diff)
Add ability to splice own asm code in
Diffstat (limited to 'tnslc/util.tnsl')
-rw-r--r--tnslc/util.tnsl45
1 files changed, 43 insertions, 2 deletions
diff --git a/tnslc/util.tnsl b/tnslc/util.tnsl
index 5d84dec..27f9f89 100644
--- a/tnslc/util.tnsl
+++ b/tnslc/util.tnsl
@@ -103,6 +103,8 @@
/; get_escape_code (charp c) [charp]
/; if (c == '\'')
;return '\''
+ ;; else if (c == '"')
+ ;return '"'
;; else if (c == 'a')
;return '\a'
;; else if (c == 'b')
@@ -125,15 +127,32 @@
;/
/; parse_hex_code ({}charp c) [charp]
- /;
+ ;charp out = 0
+
+ /; loop (int i = 0; i < len c) [i++]
+ ;out = out * 16
+ ;charp tmp = c{i}
+ /; if (tmp !< 'a')
+ ;tmp = tmp - 'a' + 'A'
+ ;/
+ /; if (tmp !< '0' && tmp !> '9')
+ ;out = out + tmp - '0'
+ ;; else if (tmp !< 'A' && tmp !> 'F')
+ ;out = out + 10 + (tmp - 'A')
+ ;; else
+ ;break
+ ;/
;/
+
+ ;return out
;/
/; unquote_char ({}charp c) [charp]
/; if (c{1} == '\\')
/; if (c{2} == 'x')
- ;return 0
+ ;{}charp d = {c{3}, c{4}}
+ ;return parse_hex_code(d)
;/
;return get_escape_code(c{2})
;/
@@ -142,5 +161,27 @@
;/
/; unquote_string ({}charp str) [{}charp]
+ ;{}charp out = ""
+ ;{}charp unc = "'"
+
+ /; loop (int i = 1; i < len str - 1) [i++]
+ /; if (str{i} == '\\')
+ ;unc.append('\\')
+ ;unc.append(str{i + 1})
+ ;i++
+
+ /; if (str{i} == 'x')
+ ;unc.append(str{i + 1})
+ ;unc.append(str{i + 2})
+ ;i = i + 2
+ ;/
+
+ ;out.append(unquote_char(unc))
+ ;unc = "'"
+ ;; else
+ ;out.append(str{i})
+ ;/
+ ;/
+ ;return out
;/