Skip to content

Commit

Permalink
Parse loop expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
N00byEdge committed Oct 4, 2023
1 parent 42394cd commit 115d7be
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions selfhost/parser.n
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const NodeType = enum(u8) {
// payload: list of branch nodes (1 - 2 in list, true cond first)
@"if",

// payload: loop body
@"loop",

// payload: lhs
// idx - 1: rhs
// token is the binary operator
Expand Down Expand Up @@ -293,6 +296,11 @@ fn parse_primary_expression(context: *ParserContext) u32 {
node_payload.get(result).* = branch_builder.head;
return result;
}
else if(p == .loop_keyword) {
const result = context.add_advance(.@"loop");
node_payload.get(result).* = parse_block(context);
return result;
}
else if(p == .@"{") {
const result = add_with_token(context.current_token, .block);
node_payload.get(result).* = parse_block(context);
Expand Down

0 comments on commit 115d7be

Please sign in to comment.