diff options
author | Ian Moffett <ian@osmora.org> | 2025-10-01 19:51:26 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-10-01 19:51:26 -0400 |
commit | 986a736de0418bf01f52f2e44fdf58f23f04e615 (patch) | |
tree | 2b462471f62c59f11299cacf4847ad4fc45845ef /src/sys/include | |
parent | f927e045e37129cf1a57ad85c15a0b04093f3177 (diff) |
np: parse: Create proc AST, handle end/begin, ...
This commit introduces AST object types and AST integer type
definitions. We also now keep track of how deep we are in begin/end
tags.
- Introduce parsing for TT_BEGIN
- Introduce parsing for TT_END
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/include')
-rw-r--r-- | src/sys/include/np/ast.h | 14 | ||||
-rw-r--r-- | src/sys/include/os/np.h | 4 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/sys/include/np/ast.h b/src/sys/include/np/ast.h index 8e516d7..9232226 100644 --- a/src/sys/include/np/ast.h +++ b/src/sys/include/np/ast.h @@ -52,16 +52,26 @@ typedef enum { } ast_itype_t; /* + * AST node type + */ +typedef enum { + AT_BAD_OBJTYPE, /* Bad */ + AST_PROC, /* Procedure */ +} ast_type_t; + +/* * Represents an AST node * * @ident: Identifier - * @token: Token type + * @num_type: Integer type + * @type: Object type * @left: Left node * @right: Right node */ struct ast_node { char *ident; - tt_t token; + ast_itype_t num_type; + ast_type_t type; struct ast_node *left; struct ast_node *right; }; diff --git a/src/sys/include/os/np.h b/src/sys/include/os/np.h index c3921cb..9b04f0e 100644 --- a/src/sys/include/os/np.h +++ b/src/sys/include/os/np.h @@ -49,6 +49,8 @@ * @lex_st: Lexer state * @ast_root: Parse tree * @ccache: Character cache (temporary store for lexer) + * @in_func: Is set if we are inside a function + * @begin_depth: How deep in "begin" we are */ struct np_work { char *source; @@ -58,6 +60,8 @@ struct np_work { struct ptrbox *work_mem; struct ast_node *ast_root; char ccache; + uint8_t in_func : 1; + uint8_t begin_depth; }; /* |