This commit is contained in:
parent
74dad4c484
commit
ed068e859d
|
@ -67,6 +67,6 @@ for channel in json.load(open('channels.json')):
|
||||||
#? stderr.write(repr(item)+'\n')
|
#? stderr.write(repr(item)+'\n')
|
||||||
print(f"({json.dumps(item['ts'])} {parent(item)} {json.dumps(channel['name'])} {by(item)} {json.dumps(item['text'])})")
|
print(f"({json.dumps(item['ts'])} {parent(item)} {json.dumps(channel['name'])} {by(item)} {json.dumps(item['text'])})")
|
||||||
item_idx[item['ts']] = idx
|
item_idx[item['ts']] = idx
|
||||||
idx += 1
|
idx += 1 # only increment when actually used and no exception raised
|
||||||
except KeyError:
|
except KeyError:
|
||||||
stderr.write(repr(item)+'\n')
|
stderr.write(repr(item)+'\n')
|
||||||
|
|
|
@ -18,11 +18,7 @@ type item {
|
||||||
by: int # user index
|
by: int # user index
|
||||||
text: (handle array byte)
|
text: (handle array byte)
|
||||||
parent: int # item index
|
parent: int # item index
|
||||||
}
|
comments: (handle array int)
|
||||||
|
|
||||||
type post {
|
|
||||||
root: int # item index
|
|
||||||
comments: (handle array int) # item indices
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# globals:
|
# globals:
|
||||||
|
@ -32,8 +28,9 @@ type post {
|
||||||
#
|
#
|
||||||
# flows:
|
# flows:
|
||||||
# channel -> posts
|
# channel -> posts
|
||||||
# user -> posts
|
# user -> posts|comments
|
||||||
# post -> comments
|
# post -> comments
|
||||||
|
# comment -> post|comments
|
||||||
# keywords -> posts|comments
|
# keywords -> posts|comments
|
||||||
|
|
||||||
# I try to put all the static buffer sizes in this function.
|
# 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) {
|
fn parse in: (addr stream byte), users: (addr array user), channels: (addr array channel), items: (addr array item) {
|
||||||
var line-storage: (stream byte 0x18000)
|
# 'in' consists of a long, flat sequence of records surrounded by parens
|
||||||
var line/ecx: (addr stream byte) <- address line-storage
|
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 {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue