summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2023-03-18 19:27:34 -0400
committerKyle Gunger <kgunger12@gmail.com>2023-03-18 19:27:34 -0400
commit11ebac689b5a400862636e6ad5885d8cb3231161 (patch)
treec1d621dbac7fd1a41d5a618139423e680d9ec5bb
parent80b6af60eb8b9d971b9710ae9d91c2639a9e875f (diff)
Fix for multiline struct definitions
-rw-r--r--tnslc/simple.tnsl4
-rw-r--r--tnslc/tnslc.tnsl21
2 files changed, 19 insertions, 6 deletions
diff --git a/tnslc/simple.tnsl b/tnslc/simple.tnsl
index f722359..ca11667 100644
--- a/tnslc/simple.tnsl
+++ b/tnslc/simple.tnsl
@@ -10,6 +10,10 @@
}
;/
+mod.test tv = {
+ 1, 2, false, 0
+}
+
/; main [int]
~int b = ~mod.a
diff --git a/tnslc/tnslc.tnsl b/tnslc/tnslc.tnsl
index 06fc6dc..4aa6429 100644
--- a/tnslc/tnslc.tnsl
+++ b/tnslc/tnslc.tnsl
@@ -1565,7 +1565,7 @@
;{}uint8 arr = ""
;int alen = 0
- /; loop (cur`++; cur` < max) [cur`++]
+ /; loop (cur` = next_non_nl(tok, cur` + 1); cur` < max) [cur` = next_non_nl(tok, cur` + 1)]
;alen++
/; if (tok`{cur`}.cmp("{"))
@@ -1576,10 +1576,10 @@
;/
;t.ptr_chain = ptr
;arr = string_add(arr, decompose_array(tok, cur, current, t))
- ;cur`++
+ ;cur` = next_non_nl(tok, cur` + 1)
;; else
;decompose_struct(tok, cur, current, t)
- ;cur`++
+ ;cur` = next_non_nl(tok, cur` + 1)
;/
;; else
;arr = string_add(arr, decompose_data(tok, cur, current, t))
@@ -1597,15 +1597,17 @@
;int max = find_closing(tok, cur)
;{}uint8 out = ""
;int m = 0
- /; loop (cur`++; cur` < max) [cur`++]
+ /; loop (cur` = next_non_nl(tok, cur` + 1); cur` < max) [cur` = next_non_nl(tok, cur` + 1)]
/; if (tok`{cur`}.cmp("}"))
;break
;; else if (tok`{cur`}.cmp(","))
- ;cur`++
+ ;cur` = next_non_nl(tok, cur` + 1)
;/
+ ;tnsl.io.println(tok`{cur`}.data)
;out = string_add(out, decompose_data(tok, cur, current, t.members{m}.data_type))
;m++
;/
+ ;tnsl.io.println("o")
/; if (m < len (t.members) - 1)
/; loop (m < len (t.members)) [m++]
@@ -1644,6 +1646,14 @@
;return decompose_struct(tok, cur, current, t)
;/
;; if (tok`{cur`}.type_is(TOKEN.LITERAL))
+ /; if (string_equate(t.name, "bool"))
+ ;{}uint data = "0"
+ /; if (!(tok`{cur`}.cmp("false")))
+ ;data = "1"
+ ;/
+ ;return string_add(string_add(declare_size(t.s), data), "\n")
+ ;/
+
/; if (tok`{cur`}.data{0} == '"')
;return string_join({
declare_size(8), int_to_string(len unquote_str(tok`{cur`}.data)), "\n",
@@ -1654,7 +1664,6 @@
;/
;return string_add(string_add(declare_size(t.s), tok`{cur`}.data), "\n")
;/
-
;return decompose_empty(current, t)
;/