summaryrefslogtreecommitdiff
path: root/oryxc/src/parser.rs
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2026-03-10 17:38:30 +0100
committerThomas Voss <mail@thomasvoss.com> 2026-03-10 17:38:30 +0100
commit59b2e5bd0fd7cea5fc3f9c74241cf4fa08e99228 (patch)
treeb6628d20ba5d62413c97bfd975cd456fa7ce65e1 /oryxc/src/parser.rs
parent73cc7b764478cadb42ac9e3cb2cc86cc054548a3 (diff)
Wrap the AST nodes and extra data in a struct
Diffstat (limited to 'oryxc/src/parser.rs')
-rw-r--r--oryxc/src/parser.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/oryxc/src/parser.rs b/oryxc/src/parser.rs
index 70b530f..319beea 100644
--- a/oryxc/src/parser.rs
+++ b/oryxc/src/parser.rs
@@ -44,6 +44,12 @@ pub struct AstNode {
pub sub: SubNodes,
}
+#[derive(Debug)]
+pub struct Ast {
+ pub nodes: Soa<AstNode>,
+ pub extra: Vec<u32>,
+}
+
struct Parser<'a> {
ast: Soa<AstNode>,
extra_data: Vec<u32>,
@@ -885,9 +891,7 @@ impl<'a> Parser<'a> {
}
}
-pub fn parse(
- tokens: &Soa<Token>,
-) -> Result<(Soa<AstNode>, Vec<u32>), Vec<OryxError>> {
+pub fn parse(tokens: &Soa<Token>) -> Result<Ast, Vec<OryxError>> {
let mut p = Parser::new(tokens);
while p.get() != TokenType::Eof {
p.parse_toplevel();
@@ -904,5 +908,8 @@ pub fn parse(
tok: 0,
sub: SubNodes(stmtsbeg as u32, nstmts as u32),
});
- return Ok((p.ast, p.extra_data));
+ return Ok(Ast {
+ nodes: p.ast,
+ extra: p.extra_data,
+ });
}