summaryrefslogtreecommitdiff
path: root/05/parse.b
diff options
context:
space:
mode:
Diffstat (limited to '05/parse.b')
-rw-r--r--05/parse.b34
1 files changed, 34 insertions, 0 deletions
diff --git a/05/parse.b b/05/parse.b
index dc61d0c..9ddf364 100644
--- a/05/parse.b
+++ b/05/parse.b
@@ -1,3 +1,37 @@
+function parse_tokens
+ argument tokens
+ local token
+ local ident
+ local type
+
+ token = tokens
+ :parse_tokens_loop
+ if *1token == TOKEN_EOF goto parse_tokens_eof
+ if *1token == KEYWORD_TYPEDEF goto parse_typedef
+
+ byte 0xcc ; not implemented
+
+ :parse_typedef
+ token += 16
+ parse_type_and_ident(&token, &ident, &type)
+ puts(ident)
+ putc(10)
+ print_type(type)
+ putc(10)
+ exit(0)
+ :parse_tokens_eof
+ return
+
+; parse things like `int x` or `int f(void, int, char *)`
+; advances *p_token and sets *p_ident to a pointer to the identifier (or 0 if this is just a type)
+; and *p_typeid to the type ID
+function parse_type_and_ident
+ argument p_token
+ argument p_ident
+ argument p_typeid
+ local token
+ byte 0xcc ; aah
+
; how many bytes does it take to encode this type?
function type_length
argument type