From 391153b533c9de61e801ac1815d6dcf2204e6bdb Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 25 Jun 2024 02:36:43 -0400 Subject: load imported tnsl files --- tnslc/utils/algo.tnsl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tnslc/utils') 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() +;/ + -- cgit v1.2.3