about summary refs log tree commit diff stats
path: root/browse_slack/main.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-10 05:26:10 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-10 05:26:10 -0700
commited068e859d1ba9cd466c0356799cfeba44704cfe (patch)
tree204e173992ff6b826b27c1a07978b36afae89436 /browse_slack/main.mu
parent74dad4c484df86c03037deaaf683fd6d86e05119 (diff)
downloadmu-ed068e859d1ba9cd466c0356799cfeba44704cfe.tar.gz
.
Diffstat (limited to 'browse_slack/main.mu')
-rw-r--r--browse_slack/main.mu49
1 files changed, 41 insertions, 8 deletions
diff --git a/browse_slack/main.mu b/browse_slack/main.mu
index 6948665f..dadf653c 100644
--- a/browse_slack/main.mu
+++ b/browse_slack/main.mu
@@ -18,11 +18,7 @@ type item {
   by: int  # user index
   text: (handle array byte)
   parent: int  # item index
-}
-
-type post {
-  root: int  # item index
-  comments: (handle array int)  # item indices
+  comments: (handle array int)
 }
 
 # globals:
@@ -32,8 +28,9 @@ type post {
 #
 # flows:
 #   channel -> posts
-#   user -> posts
+#   user -> posts|comments
 #   post -> comments
+#   comment -> post|comments
 #   keywords -> posts|comments
 
 # I try to put all the static buffer sizes in this function.
@@ -80,6 +77,42 @@ fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk)
 }
 
 fn parse in: (addr stream byte), users: (addr array user), channels: (addr array channel), items: (addr array item) {
-  var line-storage: (stream byte 0x18000)
-  var line/ecx: (addr stream byte) <- address line-storage
+  # 'in' consists of a long, flat sequence of records surrounded by parens
+  var record-storage: (stream byte 0x18000)
+  var record/ecx: (addr stream byte) <- address record-storage
+  var user-idx/edx: int <- copy 0
+  var item-idx/ebx: int <- copy 0
+  {
+    var done?/eax: boolean <- stream-empty? in
+    compare done?, 0/false
+    break-if-!=
+    parse-record in, record
+    var user?/eax: boolean <- user-record? record
+    {
+      compare user?, 0/false
+      break-if-=
+      parse-user record, users, user-idx
+      user-idx <- increment
+    }
+    {
+      compare user?, 0/false
+      break-if-!=
+      parse-item record, channels, items, item-idx
+      item-idx <- increment
+    }
+    loop
+  }
+}
+
+fn parse-record in: (addr stream byte), out: (addr stream byte) {
+}
+
+fn user-record? record: (addr stream byte) -> _/eax: boolean {
+  return 0/false
+}
+
+fn parse-user record: (addr stream byte), users: (addr array user), user-idx: int {
+}
+
+fn parse-item record: (addr stream byte), channels: (addr array channel), items: (addr array item), item-idx: int {
 }