feat: runtime content processing, supporting glue
This commit is contained in:
parent
d325cdf965
commit
f5eac49729
12 changed files with 387 additions and 286 deletions
|
|
@ -923,13 +923,12 @@ fn parseLbraceExpr(p: *Parse) Error!?*Ast.Node {
|
|||
.end = rbrace_token.loc.end,
|
||||
}, lhs, null);
|
||||
}
|
||||
_ = try p.expectToken(.colon, true);
|
||||
|
||||
_ = try p.expectToken(.colon, false);
|
||||
if (p.checkToken(.newline)) {
|
||||
_ = p.nextToken();
|
||||
return parseConditional(p, lbrace_token, lhs);
|
||||
} else {
|
||||
_ = p.nextToken();
|
||||
return parseInlineIf(p, lbrace_token, lhs);
|
||||
}
|
||||
}
|
||||
|
|
@ -977,19 +976,22 @@ fn parseContent(p: *Parse, options: ContentOptions) Error!?*Ast.Node {
|
|||
leading_glue = true;
|
||||
_ = p.nextToken();
|
||||
}
|
||||
while (true) {
|
||||
loop: while (true) {
|
||||
const node: ?*Ast.Node = switch (p.token.tag) {
|
||||
.eof, .newline, .left_arrow, .right_brace => break,
|
||||
.left_brace => try parseLbraceExpr(p),
|
||||
.right_arrow => try parseDivertStmt(p),
|
||||
.glue => blk: {
|
||||
const next_token = p.nextToken();
|
||||
switch (next_token.tag) {
|
||||
.eof, .newline, .right_brace => {
|
||||
trailing_glue = true;
|
||||
break;
|
||||
},
|
||||
else => break :blk null,
|
||||
while (true) {
|
||||
_ = p.nextToken();
|
||||
switch (p.token.tag) {
|
||||
.whitespace => continue,
|
||||
.eof, .newline, .right_brace => {
|
||||
trailing_glue = true;
|
||||
break :loop;
|
||||
},
|
||||
else => break :blk null,
|
||||
}
|
||||
}
|
||||
},
|
||||
else => |tag| blk: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue