| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | const std = @import("../index.zig"); |
| 2 | 2 | const assert = std.debug.assert; |
| 3 | | const SegmentedList = std.SegmentedList; |
| 4 | 3 | const mem = std.mem; |
| 5 | 4 | const ast = std.zig.ast; |
| 6 | 5 | const Tokenizer = std.zig.Tokenizer; |
| ... | ... | @@ -15,7 +14,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 15 | 14 | var tree_arena = std.heap.ArenaAllocator.init(allocator); |
| 16 | 15 | errdefer tree_arena.deinit(); |
| 17 | 16 | |
| 18 | | var stack = SegmentedList(State, 32).init(allocator); |
| 17 | var stack = std.ArrayList(State).init(allocator); |
| 19 | 18 | defer stack.deinit(); |
| 20 | 19 | |
| 21 | 20 | const arena = &tree_arena.allocator; |
| ... | ... | @@ -46,11 +45,11 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 46 | 45 | } |
| 47 | 46 | var tok_it = tree.tokens.iterator(0); |
| 48 | 47 | |
| 49 | | try stack.push(State.TopLevel); |
| 48 | try stack.append(State.TopLevel); |
| 50 | 49 | |
| 51 | 50 | while (true) { |
| 52 | 51 | // This gives us 1 free push that can't fail |
| 53 | | const state = ??stack.pop(); |
| 52 | const state = stack.pop(); |
| 54 | 53 | |
| 55 | 54 | switch (state) { |
| 56 | 55 | State.TopLevel => { |
| ... | ... | @@ -65,7 +64,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 65 | 64 | const token_ptr = token.ptr; |
| 66 | 65 | switch (token_ptr.id) { |
| 67 | 66 | Token.Id.Keyword_test => { |
| 68 | | stack.push(State.TopLevel) catch unreachable; |
| 67 | stack.append(State.TopLevel) catch unreachable; |
| 69 | 68 | |
| 70 | 69 | const block = try arena.construct(ast.Node.Block { |
| 71 | 70 | .base = ast.Node { |
| ... | ... | @@ -86,14 +85,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 86 | 85 | .body_node = &block.base, |
| 87 | 86 | }); |
| 88 | 87 | try root_node.decls.push(&test_node.base); |
| 89 | | try stack.push(State { .Block = block }); |
| 90 | | try stack.push(State { |
| 88 | try stack.append(State { .Block = block }); |
| 89 | try stack.append(State { |
| 91 | 90 | .ExpectTokenSave = ExpectTokenSave { |
| 92 | 91 | .id = Token.Id.LBrace, |
| 93 | 92 | .ptr = &block.rbrace, |
| 94 | 93 | } |
| 95 | 94 | }); |
| 96 | | try stack.push(State { .StringLiteral = OptionalCtx { .Required = &test_node.name } }); |
| 95 | try stack.append(State { .StringLiteral = OptionalCtx { .Required = &test_node.name } }); |
| 97 | 96 | continue; |
| 98 | 97 | }, |
| 99 | 98 | Token.Id.Eof => { |
| ... | ... | @@ -102,8 +101,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 102 | 101 | return tree; |
| 103 | 102 | }, |
| 104 | 103 | Token.Id.Keyword_pub => { |
| 105 | | stack.push(State.TopLevel) catch unreachable; |
| 106 | | try stack.push(State { |
| 104 | stack.append(State.TopLevel) catch unreachable; |
| 105 | try stack.append(State { |
| 107 | 106 | .TopLevelExtern = TopLevelDeclCtx { |
| 108 | 107 | .decls = &root_node.decls, |
| 109 | 108 | .visib_token = token_index, |
| ... | ... | @@ -134,9 +133,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 134 | 133 | }); |
| 135 | 134 | try root_node.decls.push(&node.base); |
| 136 | 135 | |
| 137 | | stack.push(State.TopLevel) catch unreachable; |
| 138 | | try stack.push(State { .Block = block }); |
| 139 | | try stack.push(State { |
| 136 | stack.append(State.TopLevel) catch unreachable; |
| 137 | try stack.append(State { .Block = block }); |
| 138 | try stack.append(State { |
| 140 | 139 | .ExpectTokenSave = ExpectTokenSave { |
| 141 | 140 | .id = Token.Id.LBrace, |
| 142 | 141 | .ptr = &block.rbrace, |
| ... | ... | @@ -146,8 +145,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 146 | 145 | }, |
| 147 | 146 | else => { |
| 148 | 147 | putBackToken(&tok_it, &tree); |
| 149 | | stack.push(State.TopLevel) catch unreachable; |
| 150 | | try stack.push(State { |
| 148 | stack.append(State.TopLevel) catch unreachable; |
| 149 | try stack.append(State { |
| 151 | 150 | .TopLevelExtern = TopLevelDeclCtx { |
| 152 | 151 | .decls = &root_node.decls, |
| 153 | 152 | .visib_token = null, |
| ... | ... | @@ -166,7 +165,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 166 | 165 | const token_ptr = token.ptr; |
| 167 | 166 | switch (token_ptr.id) { |
| 168 | 167 | Token.Id.Keyword_export, Token.Id.Keyword_inline => { |
| 169 | | stack.push(State { |
| 168 | stack.append(State { |
| 170 | 169 | .TopLevelDecl = TopLevelDeclCtx { |
| 171 | 170 | .decls = ctx.decls, |
| 172 | 171 | .visib_token = ctx.visib_token, |
| ... | ... | @@ -181,7 +180,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 181 | 180 | continue; |
| 182 | 181 | }, |
| 183 | 182 | Token.Id.Keyword_extern => { |
| 184 | | stack.push(State { |
| 183 | stack.append(State { |
| 185 | 184 | .TopLevelLibname = TopLevelDeclCtx { |
| 186 | 185 | .decls = ctx.decls, |
| 187 | 186 | .visib_token = ctx.visib_token, |
| ... | ... | @@ -197,7 +196,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 197 | 196 | }, |
| 198 | 197 | else => { |
| 199 | 198 | putBackToken(&tok_it, &tree); |
| 200 | | stack.push(State { .TopLevelDecl = ctx }) catch unreachable; |
| 199 | stack.append(State { .TopLevelDecl = ctx }) catch unreachable; |
| 201 | 200 | continue; |
| 202 | 201 | } |
| 203 | 202 | } |
| ... | ... | @@ -213,7 +212,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 213 | 212 | }; |
| 214 | 213 | }; |
| 215 | 214 | |
| 216 | | stack.push(State { |
| 215 | stack.append(State { |
| 217 | 216 | .TopLevelDecl = TopLevelDeclCtx { |
| 218 | 217 | .decls = ctx.decls, |
| 219 | 218 | .visib_token = ctx.visib_token, |
| ... | ... | @@ -246,13 +245,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 246 | 245 | }); |
| 247 | 246 | try ctx.decls.push(&node.base); |
| 248 | 247 | |
| 249 | | stack.push(State { |
| 248 | stack.append(State { |
| 250 | 249 | .ExpectTokenSave = ExpectTokenSave { |
| 251 | 250 | .id = Token.Id.Semicolon, |
| 252 | 251 | .ptr = &node.semicolon_token, |
| 253 | 252 | } |
| 254 | 253 | }) catch unreachable; |
| 255 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 254 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 256 | 255 | continue; |
| 257 | 256 | }, |
| 258 | 257 | Token.Id.Keyword_var, Token.Id.Keyword_const => { |
| ... | ... | @@ -265,7 +264,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 265 | 264 | } |
| 266 | 265 | } |
| 267 | 266 | |
| 268 | | try stack.push(State { |
| 267 | try stack.append(State { |
| 269 | 268 | .VarDecl = VarDeclCtx { |
| 270 | 269 | .comments = ctx.comments, |
| 271 | 270 | .visib_token = ctx.visib_token, |
| ... | ... | @@ -299,13 +298,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 299 | 298 | .align_expr = null, |
| 300 | 299 | }); |
| 301 | 300 | try ctx.decls.push(&fn_proto.base); |
| 302 | | stack.push(State { .FnDef = fn_proto }) catch unreachable; |
| 303 | | try stack.push(State { .FnProto = fn_proto }); |
| 301 | stack.append(State { .FnDef = fn_proto }) catch unreachable; |
| 302 | try stack.append(State { .FnProto = fn_proto }); |
| 304 | 303 | |
| 305 | 304 | switch (token_ptr.id) { |
| 306 | 305 | Token.Id.Keyword_nakedcc, Token.Id.Keyword_stdcallcc => { |
| 307 | 306 | fn_proto.cc_token = token_index; |
| 308 | | try stack.push(State { |
| 307 | try stack.append(State { |
| 309 | 308 | .ExpectTokenSave = ExpectTokenSave { |
| 310 | 309 | .id = Token.Id.Keyword_fn, |
| 311 | 310 | .ptr = &fn_proto.fn_token, |
| ... | ... | @@ -324,13 +323,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 324 | 323 | ); |
| 325 | 324 | fn_proto.async_attr = async_node; |
| 326 | 325 | |
| 327 | | try stack.push(State { |
| 326 | try stack.append(State { |
| 328 | 327 | .ExpectTokenSave = ExpectTokenSave { |
| 329 | 328 | .id = Token.Id.Keyword_fn, |
| 330 | 329 | .ptr = &fn_proto.fn_token, |
| 331 | 330 | } |
| 332 | 331 | }); |
| 333 | | try stack.push(State { .AsyncAllocator = async_node }); |
| 332 | try stack.append(State { .AsyncAllocator = async_node }); |
| 334 | 333 | continue; |
| 335 | 334 | }, |
| 336 | 335 | Token.Id.Keyword_fn => { |
| ... | ... | @@ -363,14 +362,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 363 | 362 | const node_ptr = try ctx.container_decl.fields_and_decls.addOne(); |
| 364 | 363 | *node_ptr = &node.base; |
| 365 | 364 | |
| 366 | | stack.push(State { .FieldListCommaOrEnd = ctx.container_decl }) catch unreachable; |
| 367 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.type_expr } }); |
| 368 | | try stack.push(State { .ExpectToken = Token.Id.Colon }); |
| 365 | stack.append(State { .FieldListCommaOrEnd = ctx.container_decl }) catch unreachable; |
| 366 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.type_expr } }); |
| 367 | try stack.append(State { .ExpectToken = Token.Id.Colon }); |
| 369 | 368 | continue; |
| 370 | 369 | } |
| 371 | 370 | |
| 372 | | stack.push(State{ .ContainerDecl = ctx.container_decl }) catch unreachable; |
| 373 | | try stack.push(State { |
| 371 | stack.append(State{ .ContainerDecl = ctx.container_decl }) catch unreachable; |
| 372 | try stack.append(State { |
| 374 | 373 | .TopLevelExtern = TopLevelDeclCtx { |
| 375 | 374 | .decls = &ctx.container_decl.fields_and_decls, |
| 376 | 375 | .visib_token = ctx.visib_token, |
| ... | ... | @@ -390,7 +389,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 390 | 389 | putBackToken(&tok_it, &tree); |
| 391 | 390 | continue; |
| 392 | 391 | } |
| 393 | | stack.push(State { .Expression = ctx }) catch unreachable; |
| 392 | stack.append(State { .Expression = ctx }) catch unreachable; |
| 394 | 393 | continue; |
| 395 | 394 | }, |
| 396 | 395 | |
| ... | ... | @@ -420,9 +419,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 420 | 419 | } |
| 421 | 420 | ); |
| 422 | 421 | |
| 423 | | stack.push(State { .ContainerDecl = node }) catch unreachable; |
| 424 | | try stack.push(State { .ExpectToken = Token.Id.LBrace }); |
| 425 | | try stack.push(State { .ContainerInitArgStart = node }); |
| 422 | stack.append(State { .ContainerDecl = node }) catch unreachable; |
| 423 | try stack.append(State { .ExpectToken = Token.Id.LBrace }); |
| 424 | try stack.append(State { .ContainerInitArgStart = node }); |
| 426 | 425 | continue; |
| 427 | 426 | }, |
| 428 | 427 | |
| ... | ... | @@ -431,8 +430,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 431 | 430 | continue; |
| 432 | 431 | } |
| 433 | 432 | |
| 434 | | stack.push(State { .ExpectToken = Token.Id.RParen }) catch unreachable; |
| 435 | | try stack.push(State { .ContainerInitArg = container_decl }); |
| 433 | stack.append(State { .ExpectToken = Token.Id.RParen }) catch unreachable; |
| 434 | try stack.append(State { .ContainerInitArg = container_decl }); |
| 436 | 435 | continue; |
| 437 | 436 | }, |
| 438 | 437 | |
| ... | ... | @@ -447,8 +446,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 447 | 446 | const lparen_tok_index = lparen_tok.index; |
| 448 | 447 | const lparen_tok_ptr = lparen_tok.ptr; |
| 449 | 448 | if (lparen_tok_ptr.id == Token.Id.LParen) { |
| 450 | | try stack.push(State { .ExpectToken = Token.Id.RParen } ); |
| 451 | | try stack.push(State { .Expression = OptionalCtx { |
| 449 | try stack.append(State { .ExpectToken = Token.Id.RParen } ); |
| 450 | try stack.append(State { .Expression = OptionalCtx { |
| 452 | 451 | .RequiredNull = &container_decl.init_arg_expr.Enum, |
| 453 | 452 | } }); |
| 454 | 453 | } else { |
| ... | ... | @@ -458,7 +457,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 458 | 457 | else => { |
| 459 | 458 | putBackToken(&tok_it, &tree); |
| 460 | 459 | container_decl.init_arg_expr = ast.Node.ContainerDecl.InitArg { .Type = undefined }; |
| 461 | | stack.push(State { .Expression = OptionalCtx { .Required = &container_decl.init_arg_expr.Type } }) catch unreachable; |
| 460 | stack.append(State { .Expression = OptionalCtx { .Required = &container_decl.init_arg_expr.Type } }) catch unreachable; |
| 462 | 461 | }, |
| 463 | 462 | } |
| 464 | 463 | continue; |
| ... | ... | @@ -489,9 +488,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 489 | 488 | const node_ptr = try container_decl.fields_and_decls.addOne(); |
| 490 | 489 | *node_ptr = &node.base; |
| 491 | 490 | |
| 492 | | try stack.push(State { .FieldListCommaOrEnd = container_decl }); |
| 493 | | try stack.push(State { .TypeExprBegin = OptionalCtx { .Required = &node.type_expr } }); |
| 494 | | try stack.push(State { .ExpectToken = Token.Id.Colon }); |
| 491 | try stack.append(State { .FieldListCommaOrEnd = container_decl }); |
| 492 | try stack.append(State { .TypeExprBegin = OptionalCtx { .Required = &node.type_expr } }); |
| 493 | try stack.append(State { .ExpectToken = Token.Id.Colon }); |
| 495 | 494 | continue; |
| 496 | 495 | }, |
| 497 | 496 | ast.Node.ContainerDecl.Kind.Union => { |
| ... | ... | @@ -504,10 +503,10 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 504 | 503 | }); |
| 505 | 504 | try container_decl.fields_and_decls.push(&node.base); |
| 506 | 505 | |
| 507 | | stack.push(State { .FieldListCommaOrEnd = container_decl }) catch unreachable; |
| 508 | | try stack.push(State { .FieldInitValue = OptionalCtx { .RequiredNull = &node.value_expr } }); |
| 509 | | try stack.push(State { .TypeExprBegin = OptionalCtx { .RequiredNull = &node.type_expr } }); |
| 510 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 506 | stack.append(State { .FieldListCommaOrEnd = container_decl }) catch unreachable; |
| 507 | try stack.append(State { .FieldInitValue = OptionalCtx { .RequiredNull = &node.value_expr } }); |
| 508 | try stack.append(State { .TypeExprBegin = OptionalCtx { .RequiredNull = &node.type_expr } }); |
| 509 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 511 | 510 | continue; |
| 512 | 511 | }, |
| 513 | 512 | ast.Node.ContainerDecl.Kind.Enum => { |
| ... | ... | @@ -519,9 +518,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 519 | 518 | }); |
| 520 | 519 | try container_decl.fields_and_decls.push(&node.base); |
| 521 | 520 | |
| 522 | | stack.push(State { .FieldListCommaOrEnd = container_decl }) catch unreachable; |
| 523 | | try stack.push(State { .Expression = OptionalCtx { .RequiredNull = &node.value } }); |
| 524 | | try stack.push(State { .IfToken = Token.Id.Equal }); |
| 521 | stack.append(State { .FieldListCommaOrEnd = container_decl }) catch unreachable; |
| 522 | try stack.append(State { .Expression = OptionalCtx { .RequiredNull = &node.value } }); |
| 523 | try stack.append(State { .IfToken = Token.Id.Equal }); |
| 525 | 524 | continue; |
| 526 | 525 | }, |
| 527 | 526 | } |
| ... | ... | @@ -529,7 +528,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 529 | 528 | Token.Id.Keyword_pub => { |
| 530 | 529 | switch (container_decl.kind) { |
| 531 | 530 | ast.Node.ContainerDecl.Kind.Struct => { |
| 532 | | try stack.push(State { |
| 531 | try stack.append(State { |
| 533 | 532 | .TopLevelExternOrField = TopLevelExternOrFieldCtx { |
| 534 | 533 | .visib_token = token_index, |
| 535 | 534 | .container_decl = container_decl, |
| ... | ... | @@ -539,8 +538,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 539 | 538 | continue; |
| 540 | 539 | }, |
| 541 | 540 | else => { |
| 542 | | stack.push(State{ .ContainerDecl = container_decl }) catch unreachable; |
| 543 | | try stack.push(State { |
| 541 | stack.append(State{ .ContainerDecl = container_decl }) catch unreachable; |
| 542 | try stack.append(State { |
| 544 | 543 | .TopLevelExtern = TopLevelDeclCtx { |
| 545 | 544 | .decls = &container_decl.fields_and_decls, |
| 546 | 545 | .visib_token = token_index, |
| ... | ... | @@ -554,8 +553,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 554 | 553 | } |
| 555 | 554 | }, |
| 556 | 555 | Token.Id.Keyword_export => { |
| 557 | | stack.push(State{ .ContainerDecl = container_decl }) catch unreachable; |
| 558 | | try stack.push(State { |
| 556 | stack.append(State{ .ContainerDecl = container_decl }) catch unreachable; |
| 557 | try stack.append(State { |
| 559 | 558 | .TopLevelExtern = TopLevelDeclCtx { |
| 560 | 559 | .decls = &container_decl.fields_and_decls, |
| 561 | 560 | .visib_token = token_index, |
| ... | ... | @@ -578,8 +577,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 578 | 577 | }, |
| 579 | 578 | else => { |
| 580 | 579 | putBackToken(&tok_it, &tree); |
| 581 | | stack.push(State{ .ContainerDecl = container_decl }) catch unreachable; |
| 582 | | try stack.push(State { |
| 580 | stack.append(State{ .ContainerDecl = container_decl }) catch unreachable; |
| 581 | try stack.append(State { |
| 583 | 582 | .TopLevelExtern = TopLevelDeclCtx { |
| 584 | 583 | .decls = &container_decl.fields_and_decls, |
| 585 | 584 | .visib_token = null, |
| ... | ... | @@ -615,10 +614,10 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 615 | 614 | }); |
| 616 | 615 | try ctx.list.push(&var_decl.base); |
| 617 | 616 | |
| 618 | | try stack.push(State { .VarDeclAlign = var_decl }); |
| 619 | | try stack.push(State { .TypeExprBegin = OptionalCtx { .RequiredNull = &var_decl.type_node} }); |
| 620 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 621 | | try stack.push(State { |
| 617 | try stack.append(State { .VarDeclAlign = var_decl }); |
| 618 | try stack.append(State { .TypeExprBegin = OptionalCtx { .RequiredNull = &var_decl.type_node} }); |
| 619 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 620 | try stack.append(State { |
| 622 | 621 | .ExpectTokenSave = ExpectTokenSave { |
| 623 | 622 | .id = Token.Id.Identifier, |
| 624 | 623 | .ptr = &var_decl.name_token, |
| ... | ... | @@ -627,15 +626,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 627 | 626 | continue; |
| 628 | 627 | }, |
| 629 | 628 | State.VarDeclAlign => |var_decl| { |
| 630 | | try stack.push(State { .VarDeclEq = var_decl }); |
| 629 | try stack.append(State { .VarDeclEq = var_decl }); |
| 631 | 630 | |
| 632 | 631 | const next_token = nextToken(&tok_it, &tree); |
| 633 | 632 | const next_token_index = next_token.index; |
| 634 | 633 | const next_token_ptr = next_token.ptr; |
| 635 | 634 | if (next_token_ptr.id == Token.Id.Keyword_align) { |
| 636 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 637 | | try stack.push(State { .Expression = OptionalCtx { .RequiredNull = &var_decl.align_node} }); |
| 638 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 635 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 636 | try stack.append(State { .Expression = OptionalCtx { .RequiredNull = &var_decl.align_node} }); |
| 637 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 639 | 638 | continue; |
| 640 | 639 | } |
| 641 | 640 | |
| ... | ... | @@ -649,13 +648,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 649 | 648 | switch (token_ptr.id) { |
| 650 | 649 | Token.Id.Equal => { |
| 651 | 650 | var_decl.eq_token = token_index; |
| 652 | | stack.push(State { |
| 651 | stack.append(State { |
| 653 | 652 | .ExpectTokenSave = ExpectTokenSave { |
| 654 | 653 | .id = Token.Id.Semicolon, |
| 655 | 654 | .ptr = &var_decl.semicolon_token, |
| 656 | 655 | }, |
| 657 | 656 | }) catch unreachable; |
| 658 | | try stack.push(State { .Expression = OptionalCtx { .RequiredNull = &var_decl.init_node } }); |
| 657 | try stack.append(State { .Expression = OptionalCtx { .RequiredNull = &var_decl.init_node } }); |
| 659 | 658 | continue; |
| 660 | 659 | }, |
| 661 | 660 | Token.Id.Semicolon => { |
| ... | ... | @@ -686,7 +685,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 686 | 685 | .rbrace = undefined, |
| 687 | 686 | }); |
| 688 | 687 | fn_proto.body_node = &block.base; |
| 689 | | stack.push(State { .Block = block }) catch unreachable; |
| 688 | stack.append(State { .Block = block }) catch unreachable; |
| 690 | 689 | continue; |
| 691 | 690 | }, |
| 692 | 691 | Token.Id.Semicolon => continue, |
| ... | ... | @@ -699,9 +698,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 699 | 698 | } |
| 700 | 699 | }, |
| 701 | 700 | State.FnProto => |fn_proto| { |
| 702 | | stack.push(State { .FnProtoAlign = fn_proto }) catch unreachable; |
| 703 | | try stack.push(State { .ParamDecl = fn_proto }); |
| 704 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 701 | stack.append(State { .FnProtoAlign = fn_proto }) catch unreachable; |
| 702 | try stack.append(State { .ParamDecl = fn_proto }); |
| 703 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 705 | 704 | |
| 706 | 705 | if (eatToken(&tok_it, &tree, Token.Id.Identifier)) |name_token| { |
| 707 | 706 | fn_proto.name_token = name_token; |
| ... | ... | @@ -709,12 +708,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 709 | 708 | continue; |
| 710 | 709 | }, |
| 711 | 710 | State.FnProtoAlign => |fn_proto| { |
| 712 | | stack.push(State { .FnProtoReturnType = fn_proto }) catch unreachable; |
| 711 | stack.append(State { .FnProtoReturnType = fn_proto }) catch unreachable; |
| 713 | 712 | |
| 714 | 713 | if (eatToken(&tok_it, &tree, Token.Id.Keyword_align)) |align_token| { |
| 715 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 716 | | try stack.push(State { .Expression = OptionalCtx { .RequiredNull = &fn_proto.align_expr } }); |
| 717 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 714 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 715 | try stack.append(State { .Expression = OptionalCtx { .RequiredNull = &fn_proto.align_expr } }); |
| 716 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 718 | 717 | } |
| 719 | 718 | continue; |
| 720 | 719 | }, |
| ... | ... | @@ -725,7 +724,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 725 | 724 | switch (token_ptr.id) { |
| 726 | 725 | Token.Id.Bang => { |
| 727 | 726 | fn_proto.return_type = ast.Node.FnProto.ReturnType { .InferErrorSet = undefined }; |
| 728 | | stack.push(State { |
| 727 | stack.append(State { |
| 729 | 728 | .TypeExprBegin = OptionalCtx { .Required = &fn_proto.return_type.InferErrorSet }, |
| 730 | 729 | }) catch unreachable; |
| 731 | 730 | continue; |
| ... | ... | @@ -747,7 +746,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 747 | 746 | |
| 748 | 747 | putBackToken(&tok_it, &tree); |
| 749 | 748 | fn_proto.return_type = ast.Node.FnProto.ReturnType { .Explicit = undefined }; |
| 750 | | stack.push(State { .TypeExprBegin = OptionalCtx { .Required = &fn_proto.return_type.Explicit }, }) catch unreachable; |
| 749 | stack.append(State { .TypeExprBegin = OptionalCtx { .Required = &fn_proto.return_type.Explicit }, }) catch unreachable; |
| 751 | 750 | continue; |
| 752 | 751 | }, |
| 753 | 752 | } |
| ... | ... | @@ -768,14 +767,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 768 | 767 | }); |
| 769 | 768 | try fn_proto.params.push(&param_decl.base); |
| 770 | 769 | |
| 771 | | stack.push(State { |
| 770 | stack.append(State { |
| 772 | 771 | .ParamDeclEnd = ParamDeclEndCtx { |
| 773 | 772 | .param_decl = param_decl, |
| 774 | 773 | .fn_proto = fn_proto, |
| 775 | 774 | } |
| 776 | 775 | }) catch unreachable; |
| 777 | | try stack.push(State { .ParamDeclName = param_decl }); |
| 778 | | try stack.push(State { .ParamDeclAliasOrComptime = param_decl }); |
| 776 | try stack.append(State { .ParamDeclName = param_decl }); |
| 777 | try stack.append(State { .ParamDeclAliasOrComptime = param_decl }); |
| 779 | 778 | continue; |
| 780 | 779 | }, |
| 781 | 780 | State.ParamDeclAliasOrComptime => |param_decl| { |
| ... | ... | @@ -801,12 +800,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 801 | 800 | State.ParamDeclEnd => |ctx| { |
| 802 | 801 | if (eatToken(&tok_it, &tree, Token.Id.Ellipsis3)) |ellipsis3| { |
| 803 | 802 | ctx.param_decl.var_args_token = ellipsis3; |
| 804 | | stack.push(State { .ExpectToken = Token.Id.RParen }) catch unreachable; |
| 803 | stack.append(State { .ExpectToken = Token.Id.RParen }) catch unreachable; |
| 805 | 804 | continue; |
| 806 | 805 | } |
| 807 | 806 | |
| 808 | | try stack.push(State { .ParamDeclComma = ctx.fn_proto }); |
| 809 | | try stack.push(State { |
| 807 | try stack.append(State { .ParamDeclComma = ctx.fn_proto }); |
| 808 | try stack.append(State { |
| 810 | 809 | .TypeExprBegin = OptionalCtx { .Required = &ctx.param_decl.type_node } |
| 811 | 810 | }); |
| 812 | 811 | continue; |
| ... | ... | @@ -815,7 +814,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 815 | 814 | switch (expectCommaOrEnd(&tok_it, &tree, Token.Id.RParen)) { |
| 816 | 815 | ExpectCommaOrEndResult.end_token => |t| { |
| 817 | 816 | if (t == null) { |
| 818 | | stack.push(State { .ParamDecl = fn_proto }) catch unreachable; |
| 817 | stack.append(State { .ParamDecl = fn_proto }) catch unreachable; |
| 819 | 818 | } |
| 820 | 819 | continue; |
| 821 | 820 | }, |
| ... | ... | @@ -828,7 +827,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 828 | 827 | |
| 829 | 828 | State.MaybeLabeledExpression => |ctx| { |
| 830 | 829 | if (eatToken(&tok_it, &tree, Token.Id.Colon)) |_| { |
| 831 | | stack.push(State { |
| 830 | stack.append(State { |
| 832 | 831 | .LabeledExpression = LabelCtx { |
| 833 | 832 | .label = ctx.label, |
| 834 | 833 | .opt_ctx = ctx.opt_ctx, |
| ... | ... | @@ -855,11 +854,11 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 855 | 854 | .rbrace = undefined, |
| 856 | 855 | } |
| 857 | 856 | ); |
| 858 | | stack.push(State { .Block = block }) catch unreachable; |
| 857 | stack.append(State { .Block = block }) catch unreachable; |
| 859 | 858 | continue; |
| 860 | 859 | }, |
| 861 | 860 | Token.Id.Keyword_while => { |
| 862 | | stack.push(State { |
| 861 | stack.append(State { |
| 863 | 862 | .While = LoopCtx { |
| 864 | 863 | .label = ctx.label, |
| 865 | 864 | .inline_token = null, |
| ... | ... | @@ -870,7 +869,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 870 | 869 | continue; |
| 871 | 870 | }, |
| 872 | 871 | Token.Id.Keyword_for => { |
| 873 | | stack.push(State { |
| 872 | stack.append(State { |
| 874 | 873 | .For = LoopCtx { |
| 875 | 874 | .label = ctx.label, |
| 876 | 875 | .inline_token = null, |
| ... | ... | @@ -891,12 +890,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 891 | 890 | .body = null, |
| 892 | 891 | }); |
| 893 | 892 | ctx.opt_ctx.store(&node.base); |
| 894 | | stack.push(State { .SuspendBody = node }) catch unreachable; |
| 895 | | try stack.push(State { .Payload = OptionalCtx { .Optional = &node.payload } }); |
| 893 | stack.append(State { .SuspendBody = node }) catch unreachable; |
| 894 | try stack.append(State { .Payload = OptionalCtx { .Optional = &node.payload } }); |
| 896 | 895 | continue; |
| 897 | 896 | }, |
| 898 | 897 | Token.Id.Keyword_inline => { |
| 899 | | stack.push(State { |
| 898 | stack.append(State { |
| 900 | 899 | .Inline = InlineCtx { |
| 901 | 900 | .label = ctx.label, |
| 902 | 901 | .inline_token = token_index, |
| ... | ... | @@ -924,7 +923,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 924 | 923 | const token_ptr = token.ptr; |
| 925 | 924 | switch (token_ptr.id) { |
| 926 | 925 | Token.Id.Keyword_while => { |
| 927 | | stack.push(State { |
| 926 | stack.append(State { |
| 928 | 927 | .While = LoopCtx { |
| 929 | 928 | .inline_token = ctx.inline_token, |
| 930 | 929 | .label = ctx.label, |
| ... | ... | @@ -935,7 +934,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 935 | 934 | continue; |
| 936 | 935 | }, |
| 937 | 936 | Token.Id.Keyword_for => { |
| 938 | | stack.push(State { |
| 937 | stack.append(State { |
| 939 | 938 | .For = LoopCtx { |
| 940 | 939 | .inline_token = ctx.inline_token, |
| 941 | 940 | .label = ctx.label, |
| ... | ... | @@ -972,20 +971,20 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 972 | 971 | .@"else" = null, |
| 973 | 972 | } |
| 974 | 973 | ); |
| 975 | | stack.push(State { .Else = &node.@"else" }) catch unreachable; |
| 976 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.body } }); |
| 977 | | try stack.push(State { .WhileContinueExpr = &node.continue_expr }); |
| 978 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 979 | | try stack.push(State { .PointerPayload = OptionalCtx { .Optional = &node.payload } }); |
| 980 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 981 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.condition } }); |
| 982 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 974 | stack.append(State { .Else = &node.@"else" }) catch unreachable; |
| 975 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.body } }); |
| 976 | try stack.append(State { .WhileContinueExpr = &node.continue_expr }); |
| 977 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 978 | try stack.append(State { .PointerPayload = OptionalCtx { .Optional = &node.payload } }); |
| 979 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 980 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.condition } }); |
| 981 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 983 | 982 | continue; |
| 984 | 983 | }, |
| 985 | 984 | State.WhileContinueExpr => |dest| { |
| 986 | | stack.push(State { .ExpectToken = Token.Id.RParen }) catch unreachable; |
| 987 | | try stack.push(State { .AssignmentExpressionBegin = OptionalCtx { .RequiredNull = dest } }); |
| 988 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 985 | stack.append(State { .ExpectToken = Token.Id.RParen }) catch unreachable; |
| 986 | try stack.append(State { .AssignmentExpressionBegin = OptionalCtx { .RequiredNull = dest } }); |
| 987 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 989 | 988 | continue; |
| 990 | 989 | }, |
| 991 | 990 | State.For => |ctx| { |
| ... | ... | @@ -1001,12 +1000,12 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1001 | 1000 | .@"else" = null, |
| 1002 | 1001 | } |
| 1003 | 1002 | ); |
| 1004 | | stack.push(State { .Else = &node.@"else" }) catch unreachable; |
| 1005 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.body } }); |
| 1006 | | try stack.push(State { .PointerIndexPayload = OptionalCtx { .Optional = &node.payload } }); |
| 1007 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 1008 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.array_expr } }); |
| 1009 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 1003 | stack.append(State { .Else = &node.@"else" }) catch unreachable; |
| 1004 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.body } }); |
| 1005 | try stack.append(State { .PointerIndexPayload = OptionalCtx { .Optional = &node.payload } }); |
| 1006 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 1007 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.array_expr } }); |
| 1008 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 1010 | 1009 | continue; |
| 1011 | 1010 | }, |
| 1012 | 1011 | State.Else => |dest| { |
| ... | ... | @@ -1021,8 +1020,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1021 | 1020 | ); |
| 1022 | 1021 | *dest = node; |
| 1023 | 1022 | |
| 1024 | | stack.push(State { .Expression = OptionalCtx { .Required = &node.body } }) catch unreachable; |
| 1025 | | try stack.push(State { .Payload = OptionalCtx { .Optional = &node.payload } }); |
| 1023 | stack.append(State { .Expression = OptionalCtx { .Required = &node.body } }) catch unreachable; |
| 1024 | try stack.append(State { .Payload = OptionalCtx { .Optional = &node.payload } }); |
| 1026 | 1025 | continue; |
| 1027 | 1026 | } else { |
| 1028 | 1027 | continue; |
| ... | ... | @@ -1041,7 +1040,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1041 | 1040 | }, |
| 1042 | 1041 | else => { |
| 1043 | 1042 | putBackToken(&tok_it, &tree); |
| 1044 | | stack.push(State { .Block = block }) catch unreachable; |
| 1043 | stack.append(State { .Block = block }) catch unreachable; |
| 1045 | 1044 | |
| 1046 | 1045 | var any_comments = false; |
| 1047 | 1046 | while (try eatLineComment(arena, &tok_it, &tree)) |line_comment| { |
| ... | ... | @@ -1050,7 +1049,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1050 | 1049 | } |
| 1051 | 1050 | if (any_comments) continue; |
| 1052 | 1051 | |
| 1053 | | try stack.push(State { .Statement = block }); |
| 1052 | try stack.append(State { .Statement = block }); |
| 1054 | 1053 | continue; |
| 1055 | 1054 | }, |
| 1056 | 1055 | } |
| ... | ... | @@ -1061,7 +1060,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1061 | 1060 | const token_ptr = token.ptr; |
| 1062 | 1061 | switch (token_ptr.id) { |
| 1063 | 1062 | Token.Id.Keyword_comptime => { |
| 1064 | | stack.push(State { |
| 1063 | stack.append(State { |
| 1065 | 1064 | .ComptimeStatement = ComptimeStatementCtx { |
| 1066 | 1065 | .comptime_token = token_index, |
| 1067 | 1066 | .block = block, |
| ... | ... | @@ -1070,7 +1069,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1070 | 1069 | continue; |
| 1071 | 1070 | }, |
| 1072 | 1071 | Token.Id.Keyword_var, Token.Id.Keyword_const => { |
| 1073 | | stack.push(State { |
| 1072 | stack.append(State { |
| 1074 | 1073 | .VarDecl = VarDeclCtx { |
| 1075 | 1074 | .comments = null, |
| 1076 | 1075 | .visib_token = null, |
| ... | ... | @@ -1099,8 +1098,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1099 | 1098 | const node_ptr = try block.statements.addOne(); |
| 1100 | 1099 | *node_ptr = &node.base; |
| 1101 | 1100 | |
| 1102 | | stack.push(State { .Semicolon = node_ptr }) catch unreachable; |
| 1103 | | try stack.push(State { .AssignmentExpressionBegin = OptionalCtx{ .Required = &node.expr } }); |
| 1101 | stack.append(State { .Semicolon = node_ptr }) catch unreachable; |
| 1102 | try stack.append(State { .AssignmentExpressionBegin = OptionalCtx{ .Required = &node.expr } }); |
| 1104 | 1103 | continue; |
| 1105 | 1104 | }, |
| 1106 | 1105 | Token.Id.LBrace => { |
| ... | ... | @@ -1113,14 +1112,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1113 | 1112 | }); |
| 1114 | 1113 | try block.statements.push(&inner_block.base); |
| 1115 | 1114 | |
| 1116 | | stack.push(State { .Block = inner_block }) catch unreachable; |
| 1115 | stack.append(State { .Block = inner_block }) catch unreachable; |
| 1117 | 1116 | continue; |
| 1118 | 1117 | }, |
| 1119 | 1118 | else => { |
| 1120 | 1119 | putBackToken(&tok_it, &tree); |
| 1121 | 1120 | const statement = try block.statements.addOne(); |
| 1122 | | try stack.push(State { .Semicolon = statement }); |
| 1123 | | try stack.push(State { .AssignmentExpressionBegin = OptionalCtx{ .Required = statement } }); |
| 1121 | try stack.append(State { .Semicolon = statement }); |
| 1122 | try stack.append(State { .AssignmentExpressionBegin = OptionalCtx{ .Required = statement } }); |
| 1124 | 1123 | continue; |
| 1125 | 1124 | } |
| 1126 | 1125 | } |
| ... | ... | @@ -1131,7 +1130,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1131 | 1130 | const token_ptr = token.ptr; |
| 1132 | 1131 | switch (token_ptr.id) { |
| 1133 | 1132 | Token.Id.Keyword_var, Token.Id.Keyword_const => { |
| 1134 | | stack.push(State { |
| 1133 | stack.append(State { |
| 1135 | 1134 | .VarDecl = VarDeclCtx { |
| 1136 | 1135 | .comments = null, |
| 1137 | 1136 | .visib_token = null, |
| ... | ... | @@ -1148,8 +1147,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1148 | 1147 | putBackToken(&tok_it, &tree); |
| 1149 | 1148 | putBackToken(&tok_it, &tree); |
| 1150 | 1149 | const statement = try ctx.block.statements.addOne(); |
| 1151 | | try stack.push(State { .Semicolon = statement }); |
| 1152 | | try stack.push(State { .Expression = OptionalCtx { .Required = statement } }); |
| 1150 | try stack.append(State { .Semicolon = statement }); |
| 1151 | try stack.append(State { .Expression = OptionalCtx { .Required = statement } }); |
| 1153 | 1152 | continue; |
| 1154 | 1153 | } |
| 1155 | 1154 | } |
| ... | ... | @@ -1157,7 +1156,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1157 | 1156 | State.Semicolon => |node_ptr| { |
| 1158 | 1157 | const node = *node_ptr; |
| 1159 | 1158 | if (node.requireSemiColon()) { |
| 1160 | | stack.push(State { .ExpectToken = Token.Id.Semicolon }) catch unreachable; |
| 1159 | stack.append(State { .ExpectToken = Token.Id.Semicolon }) catch unreachable; |
| 1161 | 1160 | continue; |
| 1162 | 1161 | } |
| 1163 | 1162 | continue; |
| ... | ... | @@ -1182,14 +1181,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1182 | 1181 | ); |
| 1183 | 1182 | try items.push(node); |
| 1184 | 1183 | |
| 1185 | | stack.push(State { .AsmOutputItems = items }) catch unreachable; |
| 1186 | | try stack.push(State { .IfToken = Token.Id.Comma }); |
| 1187 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 1188 | | try stack.push(State { .AsmOutputReturnOrType = node }); |
| 1189 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 1190 | | try stack.push(State { .StringLiteral = OptionalCtx { .Required = &node.constraint } }); |
| 1191 | | try stack.push(State { .ExpectToken = Token.Id.RBracket }); |
| 1192 | | try stack.push(State { .Identifier = OptionalCtx { .Required = &node.symbolic_name } }); |
| 1184 | stack.append(State { .AsmOutputItems = items }) catch unreachable; |
| 1185 | try stack.append(State { .IfToken = Token.Id.Comma }); |
| 1186 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 1187 | try stack.append(State { .AsmOutputReturnOrType = node }); |
| 1188 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 1189 | try stack.append(State { .StringLiteral = OptionalCtx { .Required = &node.constraint } }); |
| 1190 | try stack.append(State { .ExpectToken = Token.Id.RBracket }); |
| 1191 | try stack.append(State { .Identifier = OptionalCtx { .Required = &node.symbolic_name } }); |
| 1193 | 1192 | continue; |
| 1194 | 1193 | }, |
| 1195 | 1194 | State.AsmOutputReturnOrType => |node| { |
| ... | ... | @@ -1203,7 +1202,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1203 | 1202 | }, |
| 1204 | 1203 | Token.Id.Arrow => { |
| 1205 | 1204 | node.kind = ast.Node.AsmOutput.Kind { .Return = undefined }; |
| 1206 | | try stack.push(State { .TypeExprBegin = OptionalCtx { .Required = &node.kind.Return } }); |
| 1205 | try stack.append(State { .TypeExprBegin = OptionalCtx { .Required = &node.kind.Return } }); |
| 1207 | 1206 | continue; |
| 1208 | 1207 | }, |
| 1209 | 1208 | else => { |
| ... | ... | @@ -1235,20 +1234,20 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1235 | 1234 | ); |
| 1236 | 1235 | try items.push(node); |
| 1237 | 1236 | |
| 1238 | | stack.push(State { .AsmInputItems = items }) catch unreachable; |
| 1239 | | try stack.push(State { .IfToken = Token.Id.Comma }); |
| 1240 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 1241 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 1242 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 1243 | | try stack.push(State { .StringLiteral = OptionalCtx { .Required = &node.constraint } }); |
| 1244 | | try stack.push(State { .ExpectToken = Token.Id.RBracket }); |
| 1245 | | try stack.push(State { .Identifier = OptionalCtx { .Required = &node.symbolic_name } }); |
| 1237 | stack.append(State { .AsmInputItems = items }) catch unreachable; |
| 1238 | try stack.append(State { .IfToken = Token.Id.Comma }); |
| 1239 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 1240 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 1241 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 1242 | try stack.append(State { .StringLiteral = OptionalCtx { .Required = &node.constraint } }); |
| 1243 | try stack.append(State { .ExpectToken = Token.Id.RBracket }); |
| 1244 | try stack.append(State { .Identifier = OptionalCtx { .Required = &node.symbolic_name } }); |
| 1246 | 1245 | continue; |
| 1247 | 1246 | }, |
| 1248 | 1247 | State.AsmClobberItems => |items| { |
| 1249 | | stack.push(State { .AsmClobberItems = items }) catch unreachable; |
| 1250 | | try stack.push(State { .IfToken = Token.Id.Comma }); |
| 1251 | | try stack.push(State { .StringLiteral = OptionalCtx { .Required = try items.addOne() } }); |
| 1248 | stack.append(State { .AsmClobberItems = items }) catch unreachable; |
| 1249 | try stack.append(State { .IfToken = Token.Id.Comma }); |
| 1250 | try stack.append(State { .StringLiteral = OptionalCtx { .Required = try items.addOne() } }); |
| 1252 | 1251 | continue; |
| 1253 | 1252 | }, |
| 1254 | 1253 | |
| ... | ... | @@ -1259,8 +1258,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1259 | 1258 | continue; |
| 1260 | 1259 | } |
| 1261 | 1260 | |
| 1262 | | stack.push(State { .ExprListCommaOrEnd = list_state }) catch unreachable; |
| 1263 | | try stack.push(State { .Expression = OptionalCtx { .Required = try list_state.list.addOne() } }); |
| 1261 | stack.append(State { .ExprListCommaOrEnd = list_state }) catch unreachable; |
| 1262 | try stack.append(State { .Expression = OptionalCtx { .Required = try list_state.list.addOne() } }); |
| 1264 | 1263 | continue; |
| 1265 | 1264 | }, |
| 1266 | 1265 | State.ExprListCommaOrEnd => |list_state| { |
| ... | ... | @@ -1269,7 +1268,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1269 | 1268 | *list_state.ptr = end; |
| 1270 | 1269 | continue; |
| 1271 | 1270 | } else { |
| 1272 | | stack.push(State { .ExprListItemOrEnd = list_state }) catch unreachable; |
| 1271 | stack.append(State { .ExprListItemOrEnd = list_state }) catch unreachable; |
| 1273 | 1272 | continue; |
| 1274 | 1273 | }, |
| 1275 | 1274 | ExpectCommaOrEndResult.parse_error => |e| { |
| ... | ... | @@ -1298,16 +1297,16 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1298 | 1297 | }); |
| 1299 | 1298 | try list_state.list.push(&node.base); |
| 1300 | 1299 | |
| 1301 | | stack.push(State { .FieldInitListCommaOrEnd = list_state }) catch unreachable; |
| 1302 | | try stack.push(State { .Expression = OptionalCtx{ .Required = &node.expr } }); |
| 1303 | | try stack.push(State { .ExpectToken = Token.Id.Equal }); |
| 1304 | | try stack.push(State { |
| 1300 | stack.append(State { .FieldInitListCommaOrEnd = list_state }) catch unreachable; |
| 1301 | try stack.append(State { .Expression = OptionalCtx{ .Required = &node.expr } }); |
| 1302 | try stack.append(State { .ExpectToken = Token.Id.Equal }); |
| 1303 | try stack.append(State { |
| 1305 | 1304 | .ExpectTokenSave = ExpectTokenSave { |
| 1306 | 1305 | .id = Token.Id.Identifier, |
| 1307 | 1306 | .ptr = &node.name_token, |
| 1308 | 1307 | } |
| 1309 | 1308 | }); |
| 1310 | | try stack.push(State { |
| 1309 | try stack.append(State { |
| 1311 | 1310 | .ExpectTokenSave = ExpectTokenSave { |
| 1312 | 1311 | .id = Token.Id.Period, |
| 1313 | 1312 | .ptr = &node.period_token, |
| ... | ... | @@ -1321,7 +1320,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1321 | 1320 | *list_state.ptr = end; |
| 1322 | 1321 | continue; |
| 1323 | 1322 | } else { |
| 1324 | | stack.push(State { .FieldInitListItemOrEnd = list_state }) catch unreachable; |
| 1323 | stack.append(State { .FieldInitListItemOrEnd = list_state }) catch unreachable; |
| 1325 | 1324 | continue; |
| 1326 | 1325 | }, |
| 1327 | 1326 | ExpectCommaOrEndResult.parse_error => |e| { |
| ... | ... | @@ -1336,7 +1335,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1336 | 1335 | container_decl.rbrace_token = end; |
| 1337 | 1336 | continue; |
| 1338 | 1337 | } else { |
| 1339 | | try stack.push(State { .ContainerDecl = container_decl }); |
| 1338 | try stack.append(State { .ContainerDecl = container_decl }); |
| 1340 | 1339 | continue; |
| 1341 | 1340 | }, |
| 1342 | 1341 | ExpectCommaOrEndResult.parse_error => |e| { |
| ... | ... | @@ -1357,8 +1356,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1357 | 1356 | |
| 1358 | 1357 | const node_ptr = try list_state.list.addOne(); |
| 1359 | 1358 | |
| 1360 | | try stack.push(State { .ErrorTagListCommaOrEnd = list_state }); |
| 1361 | | try stack.push(State { .ErrorTag = node_ptr }); |
| 1359 | try stack.append(State { .ErrorTagListCommaOrEnd = list_state }); |
| 1360 | try stack.append(State { .ErrorTag = node_ptr }); |
| 1362 | 1361 | continue; |
| 1363 | 1362 | }, |
| 1364 | 1363 | State.ErrorTagListCommaOrEnd => |list_state| { |
| ... | ... | @@ -1367,7 +1366,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1367 | 1366 | *list_state.ptr = end; |
| 1368 | 1367 | continue; |
| 1369 | 1368 | } else { |
| 1370 | | stack.push(State { .ErrorTagListItemOrEnd = list_state }) catch unreachable; |
| 1369 | stack.append(State { .ErrorTagListItemOrEnd = list_state }) catch unreachable; |
| 1371 | 1370 | continue; |
| 1372 | 1371 | }, |
| 1373 | 1372 | ExpectCommaOrEndResult.parse_error => |e| { |
| ... | ... | @@ -1396,10 +1395,10 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1396 | 1395 | .expr = undefined, |
| 1397 | 1396 | }); |
| 1398 | 1397 | try list_state.list.push(&node.base); |
| 1399 | | try stack.push(State { .SwitchCaseCommaOrEnd = list_state }); |
| 1400 | | try stack.push(State { .AssignmentExpressionBegin = OptionalCtx { .Required = &node.expr } }); |
| 1401 | | try stack.push(State { .PointerPayload = OptionalCtx { .Optional = &node.payload } }); |
| 1402 | | try stack.push(State { .SwitchCaseFirstItem = &node.items }); |
| 1398 | try stack.append(State { .SwitchCaseCommaOrEnd = list_state }); |
| 1399 | try stack.append(State { .AssignmentExpressionBegin = OptionalCtx { .Required = &node.expr } }); |
| 1400 | try stack.append(State { .PointerPayload = OptionalCtx { .Optional = &node.payload } }); |
| 1401 | try stack.append(State { .SwitchCaseFirstItem = &node.items }); |
| 1403 | 1402 | |
| 1404 | 1403 | continue; |
| 1405 | 1404 | }, |
| ... | ... | @@ -1410,7 +1409,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1410 | 1409 | *list_state.ptr = end; |
| 1411 | 1410 | continue; |
| 1412 | 1411 | } else { |
| 1413 | | try stack.push(State { .SwitchCaseOrEnd = list_state }); |
| 1412 | try stack.append(State { .SwitchCaseOrEnd = list_state }); |
| 1414 | 1413 | continue; |
| 1415 | 1414 | }, |
| 1416 | 1415 | ExpectCommaOrEndResult.parse_error => |e| { |
| ... | ... | @@ -1431,23 +1430,23 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1431 | 1430 | }); |
| 1432 | 1431 | try case_items.push(&else_node.base); |
| 1433 | 1432 | |
| 1434 | | try stack.push(State { .ExpectToken = Token.Id.EqualAngleBracketRight }); |
| 1433 | try stack.append(State { .ExpectToken = Token.Id.EqualAngleBracketRight }); |
| 1435 | 1434 | continue; |
| 1436 | 1435 | } else { |
| 1437 | 1436 | putBackToken(&tok_it, &tree); |
| 1438 | | try stack.push(State { .SwitchCaseItem = case_items }); |
| 1437 | try stack.append(State { .SwitchCaseItem = case_items }); |
| 1439 | 1438 | continue; |
| 1440 | 1439 | } |
| 1441 | 1440 | }, |
| 1442 | 1441 | State.SwitchCaseItem => |case_items| { |
| 1443 | | stack.push(State { .SwitchCaseItemCommaOrEnd = case_items }) catch unreachable; |
| 1444 | | try stack.push(State { .RangeExpressionBegin = OptionalCtx { .Required = try case_items.addOne() } }); |
| 1442 | stack.append(State { .SwitchCaseItemCommaOrEnd = case_items }) catch unreachable; |
| 1443 | try stack.append(State { .RangeExpressionBegin = OptionalCtx { .Required = try case_items.addOne() } }); |
| 1445 | 1444 | }, |
| 1446 | 1445 | State.SwitchCaseItemCommaOrEnd => |case_items| { |
| 1447 | 1446 | switch (expectCommaOrEnd(&tok_it, &tree, Token.Id.EqualAngleBracketRight)) { |
| 1448 | 1447 | ExpectCommaOrEndResult.end_token => |t| { |
| 1449 | 1448 | if (t == null) { |
| 1450 | | stack.push(State { .SwitchCaseItem = case_items }) catch unreachable; |
| 1449 | stack.append(State { .SwitchCaseItem = case_items }) catch unreachable; |
| 1451 | 1450 | } |
| 1452 | 1451 | continue; |
| 1453 | 1452 | }, |
| ... | ... | @@ -1462,7 +1461,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1462 | 1461 | |
| 1463 | 1462 | State.SuspendBody => |suspend_node| { |
| 1464 | 1463 | if (suspend_node.payload != null) { |
| 1465 | | try stack.push(State { .AssignmentExpressionBegin = OptionalCtx { .RequiredNull = &suspend_node.body } }); |
| 1464 | try stack.append(State { .AssignmentExpressionBegin = OptionalCtx { .RequiredNull = &suspend_node.body } }); |
| 1466 | 1465 | } |
| 1467 | 1466 | continue; |
| 1468 | 1467 | }, |
| ... | ... | @@ -1472,13 +1471,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1472 | 1471 | } |
| 1473 | 1472 | |
| 1474 | 1473 | async_node.rangle_bracket = TokenIndex(0); |
| 1475 | | try stack.push(State { |
| 1474 | try stack.append(State { |
| 1476 | 1475 | .ExpectTokenSave = ExpectTokenSave { |
| 1477 | 1476 | .id = Token.Id.AngleBracketRight, |
| 1478 | 1477 | .ptr = &??async_node.rangle_bracket, |
| 1479 | 1478 | } |
| 1480 | 1479 | }); |
| 1481 | | try stack.push(State { .TypeExprBegin = OptionalCtx { .RequiredNull = &async_node.allocator_type } }); |
| 1480 | try stack.append(State { .TypeExprBegin = OptionalCtx { .RequiredNull = &async_node.allocator_type } }); |
| 1482 | 1481 | continue; |
| 1483 | 1482 | }, |
| 1484 | 1483 | State.AsyncEnd => |ctx| { |
| ... | ... | @@ -1533,11 +1532,11 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1533 | 1532 | .align_expr = null, |
| 1534 | 1533 | }); |
| 1535 | 1534 | ctx.opt_ctx.store(&fn_proto.base); |
| 1536 | | stack.push(State { .FnProto = fn_proto }) catch unreachable; |
| 1535 | stack.append(State { .FnProto = fn_proto }) catch unreachable; |
| 1537 | 1536 | continue; |
| 1538 | 1537 | } |
| 1539 | 1538 | |
| 1540 | | stack.push(State { |
| 1539 | stack.append(State { |
| 1541 | 1540 | .ContainerKind = ContainerKindCtx { |
| 1542 | 1541 | .opt_ctx = ctx.opt_ctx, |
| 1543 | 1542 | .ltoken = ctx.extern_token, |
| ... | ... | @@ -1560,13 +1559,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1560 | 1559 | } |
| 1561 | 1560 | }; |
| 1562 | 1561 | |
| 1563 | | stack.push(State { |
| 1562 | stack.append(State { |
| 1564 | 1563 | .ExpectTokenSave = ExpectTokenSave { |
| 1565 | 1564 | .id = Token.Id.RBracket, |
| 1566 | 1565 | .ptr = &node.rtoken, |
| 1567 | 1566 | } |
| 1568 | 1567 | }) catch unreachable; |
| 1569 | | try stack.push(State { .Expression = OptionalCtx { .Optional = &node.op.Slice.end } }); |
| 1568 | try stack.append(State { .Expression = OptionalCtx { .Optional = &node.op.Slice.end } }); |
| 1570 | 1569 | continue; |
| 1571 | 1570 | }, |
| 1572 | 1571 | Token.Id.RBracket => { |
| ... | ... | @@ -1592,15 +1591,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1592 | 1591 | .volatile_token = null, |
| 1593 | 1592 | } |
| 1594 | 1593 | }; |
| 1595 | | stack.push(State { .TypeExprBegin = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1596 | | try stack.push(State { .AddrOfModifiers = &node.op.SliceType }); |
| 1594 | stack.append(State { .TypeExprBegin = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1595 | try stack.append(State { .AddrOfModifiers = &node.op.SliceType }); |
| 1597 | 1596 | continue; |
| 1598 | 1597 | } |
| 1599 | 1598 | |
| 1600 | 1599 | node.op = ast.Node.PrefixOp.Op { .ArrayType = undefined }; |
| 1601 | | stack.push(State { .TypeExprBegin = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1602 | | try stack.push(State { .ExpectToken = Token.Id.RBracket }); |
| 1603 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.op.ArrayType } }); |
| 1600 | stack.append(State { .TypeExprBegin = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1601 | try stack.append(State { .ExpectToken = Token.Id.RBracket }); |
| 1602 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.op.ArrayType } }); |
| 1604 | 1603 | continue; |
| 1605 | 1604 | }, |
| 1606 | 1605 | State.AddrOfModifiers => |addr_of_info| { |
| ... | ... | @@ -1609,20 +1608,20 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1609 | 1608 | const token_ptr = token.ptr; |
| 1610 | 1609 | switch (token_ptr.id) { |
| 1611 | 1610 | Token.Id.Keyword_align => { |
| 1612 | | stack.push(state) catch unreachable; |
| 1611 | stack.append(state) catch unreachable; |
| 1613 | 1612 | if (addr_of_info.align_expr != null) { |
| 1614 | 1613 | *(try tree.errors.addOne()) = Error { |
| 1615 | 1614 | .ExtraAlignQualifier = Error.ExtraAlignQualifier { .token = token_index }, |
| 1616 | 1615 | }; |
| 1617 | 1616 | return tree; |
| 1618 | 1617 | } |
| 1619 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 1620 | | try stack.push(State { .Expression = OptionalCtx { .RequiredNull = &addr_of_info.align_expr} }); |
| 1621 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 1618 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 1619 | try stack.append(State { .Expression = OptionalCtx { .RequiredNull = &addr_of_info.align_expr} }); |
| 1620 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 1622 | 1621 | continue; |
| 1623 | 1622 | }, |
| 1624 | 1623 | Token.Id.Keyword_const => { |
| 1625 | | stack.push(state) catch unreachable; |
| 1624 | stack.append(state) catch unreachable; |
| 1626 | 1625 | if (addr_of_info.const_token != null) { |
| 1627 | 1626 | *(try tree.errors.addOne()) = Error { |
| 1628 | 1627 | .ExtraConstQualifier = Error.ExtraConstQualifier { .token = token_index }, |
| ... | ... | @@ -1633,7 +1632,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1633 | 1632 | continue; |
| 1634 | 1633 | }, |
| 1635 | 1634 | Token.Id.Keyword_volatile => { |
| 1636 | | stack.push(state) catch unreachable; |
| 1635 | stack.append(state) catch unreachable; |
| 1637 | 1636 | if (addr_of_info.volatile_token != null) { |
| 1638 | 1637 | *(try tree.errors.addOne()) = Error { |
| 1639 | 1638 | .ExtraVolatileQualifier = Error.ExtraVolatileQualifier { .token = token_index }, |
| ... | ... | @@ -1679,13 +1678,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1679 | 1678 | } |
| 1680 | 1679 | ); |
| 1681 | 1680 | |
| 1682 | | stack.push(State { |
| 1681 | stack.append(State { |
| 1683 | 1682 | .ExpectTokenSave = ExpectTokenSave { |
| 1684 | 1683 | .id = Token.Id.Pipe, |
| 1685 | 1684 | .ptr = &node.rpipe, |
| 1686 | 1685 | } |
| 1687 | 1686 | }) catch unreachable; |
| 1688 | | try stack.push(State { .Identifier = OptionalCtx { .Required = &node.error_symbol } }); |
| 1687 | try stack.append(State { .Identifier = OptionalCtx { .Required = &node.error_symbol } }); |
| 1689 | 1688 | continue; |
| 1690 | 1689 | }, |
| 1691 | 1690 | State.PointerPayload => |opt_ctx| { |
| ... | ... | @@ -1717,14 +1716,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1717 | 1716 | } |
| 1718 | 1717 | ); |
| 1719 | 1718 | |
| 1720 | | try stack.push(State { |
| 1719 | try stack.append(State { |
| 1721 | 1720 | .ExpectTokenSave = ExpectTokenSave { |
| 1722 | 1721 | .id = Token.Id.Pipe, |
| 1723 | 1722 | .ptr = &node.rpipe, |
| 1724 | 1723 | } |
| 1725 | 1724 | }); |
| 1726 | | try stack.push(State { .Identifier = OptionalCtx { .Required = &node.value_symbol } }); |
| 1727 | | try stack.push(State { |
| 1725 | try stack.append(State { .Identifier = OptionalCtx { .Required = &node.value_symbol } }); |
| 1726 | try stack.append(State { |
| 1728 | 1727 | .OptionalTokenSave = OptionalTokenSave { |
| 1729 | 1728 | .id = Token.Id.Asterisk, |
| 1730 | 1729 | .ptr = &node.ptr_token, |
| ... | ... | @@ -1762,16 +1761,16 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1762 | 1761 | } |
| 1763 | 1762 | ); |
| 1764 | 1763 | |
| 1765 | | stack.push(State { |
| 1764 | stack.append(State { |
| 1766 | 1765 | .ExpectTokenSave = ExpectTokenSave { |
| 1767 | 1766 | .id = Token.Id.Pipe, |
| 1768 | 1767 | .ptr = &node.rpipe, |
| 1769 | 1768 | } |
| 1770 | 1769 | }) catch unreachable; |
| 1771 | | try stack.push(State { .Identifier = OptionalCtx { .RequiredNull = &node.index_symbol } }); |
| 1772 | | try stack.push(State { .IfToken = Token.Id.Comma }); |
| 1773 | | try stack.push(State { .Identifier = OptionalCtx { .Required = &node.value_symbol } }); |
| 1774 | | try stack.push(State { |
| 1770 | try stack.append(State { .Identifier = OptionalCtx { .RequiredNull = &node.index_symbol } }); |
| 1771 | try stack.append(State { .IfToken = Token.Id.Comma }); |
| 1772 | try stack.append(State { .Identifier = OptionalCtx { .Required = &node.value_symbol } }); |
| 1773 | try stack.append(State { |
| 1775 | 1774 | .OptionalTokenSave = OptionalTokenSave { |
| 1776 | 1775 | .id = Token.Id.Asterisk, |
| 1777 | 1776 | .ptr = &node.ptr_token, |
| ... | ... | @@ -1796,18 +1795,18 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1796 | 1795 | } |
| 1797 | 1796 | ); |
| 1798 | 1797 | |
| 1799 | | stack.push(State { .Expression = OptionalCtx { .Optional = &node.rhs } }) catch unreachable; |
| 1798 | stack.append(State { .Expression = OptionalCtx { .Optional = &node.rhs } }) catch unreachable; |
| 1800 | 1799 | |
| 1801 | 1800 | switch (token_ptr.id) { |
| 1802 | 1801 | Token.Id.Keyword_break => { |
| 1803 | 1802 | node.kind = ast.Node.ControlFlowExpression.Kind { .Break = null }; |
| 1804 | | try stack.push(State { .Identifier = OptionalCtx { .RequiredNull = &node.kind.Break } }); |
| 1805 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 1803 | try stack.append(State { .Identifier = OptionalCtx { .RequiredNull = &node.kind.Break } }); |
| 1804 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 1806 | 1805 | }, |
| 1807 | 1806 | Token.Id.Keyword_continue => { |
| 1808 | 1807 | node.kind = ast.Node.ControlFlowExpression.Kind { .Continue = null }; |
| 1809 | | try stack.push(State { .Identifier = OptionalCtx { .RequiredNull = &node.kind.Continue } }); |
| 1810 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 1808 | try stack.append(State { .Identifier = OptionalCtx { .RequiredNull = &node.kind.Continue } }); |
| 1809 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 1811 | 1810 | }, |
| 1812 | 1811 | Token.Id.Keyword_return => { |
| 1813 | 1812 | node.kind = ast.Node.ControlFlowExpression.Kind.Return; |
| ... | ... | @@ -1831,21 +1830,21 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1831 | 1830 | } |
| 1832 | 1831 | ); |
| 1833 | 1832 | |
| 1834 | | stack.push(State { .Expression = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1833 | stack.append(State { .Expression = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1835 | 1834 | continue; |
| 1836 | 1835 | }, |
| 1837 | 1836 | else => { |
| 1838 | 1837 | if (!try parseBlockExpr(&stack, arena, opt_ctx, token_ptr, token_index)) { |
| 1839 | 1838 | putBackToken(&tok_it, &tree); |
| 1840 | | stack.push(State { .UnwrapExpressionBegin = opt_ctx }) catch unreachable; |
| 1839 | stack.append(State { .UnwrapExpressionBegin = opt_ctx }) catch unreachable; |
| 1841 | 1840 | } |
| 1842 | 1841 | continue; |
| 1843 | 1842 | } |
| 1844 | 1843 | } |
| 1845 | 1844 | }, |
| 1846 | 1845 | State.RangeExpressionBegin => |opt_ctx| { |
| 1847 | | stack.push(State { .RangeExpressionEnd = opt_ctx }) catch unreachable; |
| 1848 | | try stack.push(State { .Expression = opt_ctx }); |
| 1846 | stack.append(State { .RangeExpressionEnd = opt_ctx }) catch unreachable; |
| 1847 | try stack.append(State { .Expression = opt_ctx }); |
| 1849 | 1848 | continue; |
| 1850 | 1849 | }, |
| 1851 | 1850 | State.RangeExpressionEnd => |opt_ctx| { |
| ... | ... | @@ -1861,13 +1860,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1861 | 1860 | .rhs = undefined, |
| 1862 | 1861 | } |
| 1863 | 1862 | ); |
| 1864 | | stack.push(State { .Expression = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1863 | stack.append(State { .Expression = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 1865 | 1864 | continue; |
| 1866 | 1865 | } |
| 1867 | 1866 | }, |
| 1868 | 1867 | State.AssignmentExpressionBegin => |opt_ctx| { |
| 1869 | | stack.push(State { .AssignmentExpressionEnd = opt_ctx }) catch unreachable; |
| 1870 | | try stack.push(State { .Expression = opt_ctx }); |
| 1868 | stack.append(State { .AssignmentExpressionEnd = opt_ctx }) catch unreachable; |
| 1869 | try stack.append(State { .Expression = opt_ctx }); |
| 1871 | 1870 | continue; |
| 1872 | 1871 | }, |
| 1873 | 1872 | |
| ... | ... | @@ -1887,8 +1886,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1887 | 1886 | .rhs = undefined, |
| 1888 | 1887 | } |
| 1889 | 1888 | ); |
| 1890 | | stack.push(State { .AssignmentExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1891 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.rhs } }); |
| 1889 | stack.append(State { .AssignmentExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1890 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.rhs } }); |
| 1892 | 1891 | continue; |
| 1893 | 1892 | } else { |
| 1894 | 1893 | putBackToken(&tok_it, &tree); |
| ... | ... | @@ -1897,8 +1896,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1897 | 1896 | }, |
| 1898 | 1897 | |
| 1899 | 1898 | State.UnwrapExpressionBegin => |opt_ctx| { |
| 1900 | | stack.push(State { .UnwrapExpressionEnd = opt_ctx }) catch unreachable; |
| 1901 | | try stack.push(State { .BoolOrExpressionBegin = opt_ctx }); |
| 1899 | stack.append(State { .UnwrapExpressionEnd = opt_ctx }) catch unreachable; |
| 1900 | try stack.append(State { .BoolOrExpressionBegin = opt_ctx }); |
| 1902 | 1901 | continue; |
| 1903 | 1902 | }, |
| 1904 | 1903 | |
| ... | ... | @@ -1919,11 +1918,11 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1919 | 1918 | } |
| 1920 | 1919 | ); |
| 1921 | 1920 | |
| 1922 | | stack.push(State { .UnwrapExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1923 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.rhs } }); |
| 1921 | stack.append(State { .UnwrapExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1922 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.rhs } }); |
| 1924 | 1923 | |
| 1925 | 1924 | if (node.op == ast.Node.InfixOp.Op.Catch) { |
| 1926 | | try stack.push(State { .Payload = OptionalCtx { .Optional = &node.op.Catch } }); |
| 1925 | try stack.append(State { .Payload = OptionalCtx { .Optional = &node.op.Catch } }); |
| 1927 | 1926 | } |
| 1928 | 1927 | continue; |
| 1929 | 1928 | } else { |
| ... | ... | @@ -1933,8 +1932,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1933 | 1932 | }, |
| 1934 | 1933 | |
| 1935 | 1934 | State.BoolOrExpressionBegin => |opt_ctx| { |
| 1936 | | stack.push(State { .BoolOrExpressionEnd = opt_ctx }) catch unreachable; |
| 1937 | | try stack.push(State { .BoolAndExpressionBegin = opt_ctx }); |
| 1935 | stack.append(State { .BoolOrExpressionEnd = opt_ctx }) catch unreachable; |
| 1936 | try stack.append(State { .BoolAndExpressionBegin = opt_ctx }); |
| 1938 | 1937 | continue; |
| 1939 | 1938 | }, |
| 1940 | 1939 | |
| ... | ... | @@ -1951,15 +1950,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1951 | 1950 | .rhs = undefined, |
| 1952 | 1951 | } |
| 1953 | 1952 | ); |
| 1954 | | stack.push(State { .BoolOrExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1955 | | try stack.push(State { .BoolAndExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 1953 | stack.append(State { .BoolOrExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1954 | try stack.append(State { .BoolAndExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 1956 | 1955 | continue; |
| 1957 | 1956 | } |
| 1958 | 1957 | }, |
| 1959 | 1958 | |
| 1960 | 1959 | State.BoolAndExpressionBegin => |opt_ctx| { |
| 1961 | | stack.push(State { .BoolAndExpressionEnd = opt_ctx }) catch unreachable; |
| 1962 | | try stack.push(State { .ComparisonExpressionBegin = opt_ctx }); |
| 1960 | stack.append(State { .BoolAndExpressionEnd = opt_ctx }) catch unreachable; |
| 1961 | try stack.append(State { .ComparisonExpressionBegin = opt_ctx }); |
| 1963 | 1962 | continue; |
| 1964 | 1963 | }, |
| 1965 | 1964 | |
| ... | ... | @@ -1976,15 +1975,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 1976 | 1975 | .rhs = undefined, |
| 1977 | 1976 | } |
| 1978 | 1977 | ); |
| 1979 | | stack.push(State { .BoolAndExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1980 | | try stack.push(State { .ComparisonExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 1978 | stack.append(State { .BoolAndExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 1979 | try stack.append(State { .ComparisonExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 1981 | 1980 | continue; |
| 1982 | 1981 | } |
| 1983 | 1982 | }, |
| 1984 | 1983 | |
| 1985 | 1984 | State.ComparisonExpressionBegin => |opt_ctx| { |
| 1986 | | stack.push(State { .ComparisonExpressionEnd = opt_ctx }) catch unreachable; |
| 1987 | | try stack.push(State { .BinaryOrExpressionBegin = opt_ctx }); |
| 1985 | stack.append(State { .ComparisonExpressionEnd = opt_ctx }) catch unreachable; |
| 1986 | try stack.append(State { .BinaryOrExpressionBegin = opt_ctx }); |
| 1988 | 1987 | continue; |
| 1989 | 1988 | }, |
| 1990 | 1989 | |
| ... | ... | @@ -2004,8 +2003,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2004 | 2003 | .rhs = undefined, |
| 2005 | 2004 | } |
| 2006 | 2005 | ); |
| 2007 | | stack.push(State { .ComparisonExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2008 | | try stack.push(State { .BinaryOrExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2006 | stack.append(State { .ComparisonExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2007 | try stack.append(State { .BinaryOrExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2009 | 2008 | continue; |
| 2010 | 2009 | } else { |
| 2011 | 2010 | putBackToken(&tok_it, &tree); |
| ... | ... | @@ -2014,8 +2013,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2014 | 2013 | }, |
| 2015 | 2014 | |
| 2016 | 2015 | State.BinaryOrExpressionBegin => |opt_ctx| { |
| 2017 | | stack.push(State { .BinaryOrExpressionEnd = opt_ctx }) catch unreachable; |
| 2018 | | try stack.push(State { .BinaryXorExpressionBegin = opt_ctx }); |
| 2016 | stack.append(State { .BinaryOrExpressionEnd = opt_ctx }) catch unreachable; |
| 2017 | try stack.append(State { .BinaryXorExpressionBegin = opt_ctx }); |
| 2019 | 2018 | continue; |
| 2020 | 2019 | }, |
| 2021 | 2020 | |
| ... | ... | @@ -2032,15 +2031,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2032 | 2031 | .rhs = undefined, |
| 2033 | 2032 | } |
| 2034 | 2033 | ); |
| 2035 | | stack.push(State { .BinaryOrExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2036 | | try stack.push(State { .BinaryXorExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2034 | stack.append(State { .BinaryOrExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2035 | try stack.append(State { .BinaryXorExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2037 | 2036 | continue; |
| 2038 | 2037 | } |
| 2039 | 2038 | }, |
| 2040 | 2039 | |
| 2041 | 2040 | State.BinaryXorExpressionBegin => |opt_ctx| { |
| 2042 | | stack.push(State { .BinaryXorExpressionEnd = opt_ctx }) catch unreachable; |
| 2043 | | try stack.push(State { .BinaryAndExpressionBegin = opt_ctx }); |
| 2041 | stack.append(State { .BinaryXorExpressionEnd = opt_ctx }) catch unreachable; |
| 2042 | try stack.append(State { .BinaryAndExpressionBegin = opt_ctx }); |
| 2044 | 2043 | continue; |
| 2045 | 2044 | }, |
| 2046 | 2045 | |
| ... | ... | @@ -2057,15 +2056,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2057 | 2056 | .rhs = undefined, |
| 2058 | 2057 | } |
| 2059 | 2058 | ); |
| 2060 | | stack.push(State { .BinaryXorExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2061 | | try stack.push(State { .BinaryAndExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2059 | stack.append(State { .BinaryXorExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2060 | try stack.append(State { .BinaryAndExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2062 | 2061 | continue; |
| 2063 | 2062 | } |
| 2064 | 2063 | }, |
| 2065 | 2064 | |
| 2066 | 2065 | State.BinaryAndExpressionBegin => |opt_ctx| { |
| 2067 | | stack.push(State { .BinaryAndExpressionEnd = opt_ctx }) catch unreachable; |
| 2068 | | try stack.push(State { .BitShiftExpressionBegin = opt_ctx }); |
| 2066 | stack.append(State { .BinaryAndExpressionEnd = opt_ctx }) catch unreachable; |
| 2067 | try stack.append(State { .BitShiftExpressionBegin = opt_ctx }); |
| 2069 | 2068 | continue; |
| 2070 | 2069 | }, |
| 2071 | 2070 | |
| ... | ... | @@ -2082,15 +2081,15 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2082 | 2081 | .rhs = undefined, |
| 2083 | 2082 | } |
| 2084 | 2083 | ); |
| 2085 | | stack.push(State { .BinaryAndExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2086 | | try stack.push(State { .BitShiftExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2084 | stack.append(State { .BinaryAndExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2085 | try stack.append(State { .BitShiftExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2087 | 2086 | continue; |
| 2088 | 2087 | } |
| 2089 | 2088 | }, |
| 2090 | 2089 | |
| 2091 | 2090 | State.BitShiftExpressionBegin => |opt_ctx| { |
| 2092 | | stack.push(State { .BitShiftExpressionEnd = opt_ctx }) catch unreachable; |
| 2093 | | try stack.push(State { .AdditionExpressionBegin = opt_ctx }); |
| 2091 | stack.append(State { .BitShiftExpressionEnd = opt_ctx }) catch unreachable; |
| 2092 | try stack.append(State { .AdditionExpressionBegin = opt_ctx }); |
| 2094 | 2093 | continue; |
| 2095 | 2094 | }, |
| 2096 | 2095 | |
| ... | ... | @@ -2110,8 +2109,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2110 | 2109 | .rhs = undefined, |
| 2111 | 2110 | } |
| 2112 | 2111 | ); |
| 2113 | | stack.push(State { .BitShiftExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2114 | | try stack.push(State { .AdditionExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2112 | stack.append(State { .BitShiftExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2113 | try stack.append(State { .AdditionExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2115 | 2114 | continue; |
| 2116 | 2115 | } else { |
| 2117 | 2116 | putBackToken(&tok_it, &tree); |
| ... | ... | @@ -2120,8 +2119,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2120 | 2119 | }, |
| 2121 | 2120 | |
| 2122 | 2121 | State.AdditionExpressionBegin => |opt_ctx| { |
| 2123 | | stack.push(State { .AdditionExpressionEnd = opt_ctx }) catch unreachable; |
| 2124 | | try stack.push(State { .MultiplyExpressionBegin = opt_ctx }); |
| 2122 | stack.append(State { .AdditionExpressionEnd = opt_ctx }) catch unreachable; |
| 2123 | try stack.append(State { .MultiplyExpressionBegin = opt_ctx }); |
| 2125 | 2124 | continue; |
| 2126 | 2125 | }, |
| 2127 | 2126 | |
| ... | ... | @@ -2141,8 +2140,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2141 | 2140 | .rhs = undefined, |
| 2142 | 2141 | } |
| 2143 | 2142 | ); |
| 2144 | | stack.push(State { .AdditionExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2145 | | try stack.push(State { .MultiplyExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2143 | stack.append(State { .AdditionExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2144 | try stack.append(State { .MultiplyExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2146 | 2145 | continue; |
| 2147 | 2146 | } else { |
| 2148 | 2147 | putBackToken(&tok_it, &tree); |
| ... | ... | @@ -2151,8 +2150,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2151 | 2150 | }, |
| 2152 | 2151 | |
| 2153 | 2152 | State.MultiplyExpressionBegin => |opt_ctx| { |
| 2154 | | stack.push(State { .MultiplyExpressionEnd = opt_ctx }) catch unreachable; |
| 2155 | | try stack.push(State { .CurlySuffixExpressionBegin = opt_ctx }); |
| 2153 | stack.append(State { .MultiplyExpressionEnd = opt_ctx }) catch unreachable; |
| 2154 | try stack.append(State { .CurlySuffixExpressionBegin = opt_ctx }); |
| 2156 | 2155 | continue; |
| 2157 | 2156 | }, |
| 2158 | 2157 | |
| ... | ... | @@ -2172,8 +2171,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2172 | 2171 | .rhs = undefined, |
| 2173 | 2172 | } |
| 2174 | 2173 | ); |
| 2175 | | stack.push(State { .MultiplyExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2176 | | try stack.push(State { .CurlySuffixExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2174 | stack.append(State { .MultiplyExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2175 | try stack.append(State { .CurlySuffixExpressionBegin = OptionalCtx { .Required = &node.rhs } }); |
| 2177 | 2176 | continue; |
| 2178 | 2177 | } else { |
| 2179 | 2178 | putBackToken(&tok_it, &tree); |
| ... | ... | @@ -2182,9 +2181,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2182 | 2181 | }, |
| 2183 | 2182 | |
| 2184 | 2183 | State.CurlySuffixExpressionBegin => |opt_ctx| { |
| 2185 | | stack.push(State { .CurlySuffixExpressionEnd = opt_ctx }) catch unreachable; |
| 2186 | | try stack.push(State { .IfToken = Token.Id.LBrace }); |
| 2187 | | try stack.push(State { .TypeExprBegin = opt_ctx }); |
| 2184 | stack.append(State { .CurlySuffixExpressionEnd = opt_ctx }) catch unreachable; |
| 2185 | try stack.append(State { .IfToken = Token.Id.LBrace }); |
| 2186 | try stack.append(State { .TypeExprBegin = opt_ctx }); |
| 2188 | 2187 | continue; |
| 2189 | 2188 | }, |
| 2190 | 2189 | |
| ... | ... | @@ -2202,9 +2201,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2202 | 2201 | }); |
| 2203 | 2202 | opt_ctx.store(&node.base); |
| 2204 | 2203 | |
| 2205 | | stack.push(State { .CurlySuffixExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2206 | | try stack.push(State { .IfToken = Token.Id.LBrace }); |
| 2207 | | try stack.push(State { |
| 2204 | stack.append(State { .CurlySuffixExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2205 | try stack.append(State { .IfToken = Token.Id.LBrace }); |
| 2206 | try stack.append(State { |
| 2208 | 2207 | .FieldInitListItemOrEnd = ListSave(@typeOf(node.op.StructInitializer)) { |
| 2209 | 2208 | .list = &node.op.StructInitializer, |
| 2210 | 2209 | .ptr = &node.rtoken, |
| ... | ... | @@ -2223,9 +2222,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2223 | 2222 | .rtoken = undefined, |
| 2224 | 2223 | } |
| 2225 | 2224 | ); |
| 2226 | | stack.push(State { .CurlySuffixExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2227 | | try stack.push(State { .IfToken = Token.Id.LBrace }); |
| 2228 | | try stack.push(State { |
| 2225 | stack.append(State { .CurlySuffixExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2226 | try stack.append(State { .IfToken = Token.Id.LBrace }); |
| 2227 | try stack.append(State { |
| 2229 | 2228 | .ExprListItemOrEnd = ExprListCtx { |
| 2230 | 2229 | .list = &node.op.ArrayInitializer, |
| 2231 | 2230 | .end = Token.Id.RBrace, |
| ... | ... | @@ -2236,8 +2235,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2236 | 2235 | }, |
| 2237 | 2236 | |
| 2238 | 2237 | State.TypeExprBegin => |opt_ctx| { |
| 2239 | | stack.push(State { .TypeExprEnd = opt_ctx }) catch unreachable; |
| 2240 | | try stack.push(State { .PrefixOpExpression = opt_ctx }); |
| 2238 | stack.append(State { .TypeExprEnd = opt_ctx }) catch unreachable; |
| 2239 | try stack.append(State { .PrefixOpExpression = opt_ctx }); |
| 2241 | 2240 | continue; |
| 2242 | 2241 | }, |
| 2243 | 2242 | |
| ... | ... | @@ -2254,8 +2253,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2254 | 2253 | .rhs = undefined, |
| 2255 | 2254 | } |
| 2256 | 2255 | ); |
| 2257 | | stack.push(State { .TypeExprEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2258 | | try stack.push(State { .PrefixOpExpression = OptionalCtx { .Required = &node.rhs } }); |
| 2256 | stack.append(State { .TypeExprEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2257 | try stack.append(State { .PrefixOpExpression = OptionalCtx { .Required = &node.rhs } }); |
| 2259 | 2258 | continue; |
| 2260 | 2259 | } |
| 2261 | 2260 | }, |
| ... | ... | @@ -2288,14 +2287,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2288 | 2287 | node = child; |
| 2289 | 2288 | } |
| 2290 | 2289 | |
| 2291 | | stack.push(State { .TypeExprBegin = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 2290 | stack.append(State { .TypeExprBegin = OptionalCtx { .Required = &node.rhs } }) catch unreachable; |
| 2292 | 2291 | if (node.op == ast.Node.PrefixOp.Op.AddrOf) { |
| 2293 | | try stack.push(State { .AddrOfModifiers = &node.op.AddrOf }); |
| 2292 | try stack.append(State { .AddrOfModifiers = &node.op.AddrOf }); |
| 2294 | 2293 | } |
| 2295 | 2294 | continue; |
| 2296 | 2295 | } else { |
| 2297 | 2296 | putBackToken(&tok_it, &tree); |
| 2298 | | stack.push(State { .SuffixOpExpressionBegin = opt_ctx }) catch unreachable; |
| 2297 | stack.append(State { .SuffixOpExpressionBegin = opt_ctx }) catch unreachable; |
| 2299 | 2298 | continue; |
| 2300 | 2299 | } |
| 2301 | 2300 | }, |
| ... | ... | @@ -2310,20 +2309,20 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2310 | 2309 | .rangle_bracket = null, |
| 2311 | 2310 | } |
| 2312 | 2311 | ); |
| 2313 | | stack.push(State { |
| 2312 | stack.append(State { |
| 2314 | 2313 | .AsyncEnd = AsyncEndCtx { |
| 2315 | 2314 | .ctx = opt_ctx, |
| 2316 | 2315 | .attribute = async_node, |
| 2317 | 2316 | } |
| 2318 | 2317 | }) catch unreachable; |
| 2319 | | try stack.push(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }); |
| 2320 | | try stack.push(State { .PrimaryExpression = opt_ctx.toRequired() }); |
| 2321 | | try stack.push(State { .AsyncAllocator = async_node }); |
| 2318 | try stack.append(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }); |
| 2319 | try stack.append(State { .PrimaryExpression = opt_ctx.toRequired() }); |
| 2320 | try stack.append(State { .AsyncAllocator = async_node }); |
| 2322 | 2321 | continue; |
| 2323 | 2322 | } |
| 2324 | 2323 | |
| 2325 | | stack.push(State { .SuffixOpExpressionEnd = opt_ctx }) catch unreachable; |
| 2326 | | try stack.push(State { .PrimaryExpression = opt_ctx }); |
| 2324 | stack.append(State { .SuffixOpExpressionEnd = opt_ctx }) catch unreachable; |
| 2325 | try stack.append(State { .PrimaryExpression = opt_ctx }); |
| 2327 | 2326 | continue; |
| 2328 | 2327 | }, |
| 2329 | 2328 | |
| ... | ... | @@ -2348,8 +2347,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2348 | 2347 | .rtoken = undefined, |
| 2349 | 2348 | } |
| 2350 | 2349 | ); |
| 2351 | | stack.push(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2352 | | try stack.push(State { |
| 2350 | stack.append(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2351 | try stack.append(State { |
| 2353 | 2352 | .ExprListItemOrEnd = ExprListCtx { |
| 2354 | 2353 | .list = &node.op.Call.params, |
| 2355 | 2354 | .end = Token.Id.RParen, |
| ... | ... | @@ -2369,9 +2368,9 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2369 | 2368 | .rtoken = undefined |
| 2370 | 2369 | } |
| 2371 | 2370 | ); |
| 2372 | | stack.push(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2373 | | try stack.push(State { .SliceOrArrayAccess = node }); |
| 2374 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.op.ArrayAccess }}); |
| 2371 | stack.append(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2372 | try stack.append(State { .SliceOrArrayAccess = node }); |
| 2373 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.op.ArrayAccess }}); |
| 2375 | 2374 | continue; |
| 2376 | 2375 | }, |
| 2377 | 2376 | Token.Id.Period => { |
| ... | ... | @@ -2384,8 +2383,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2384 | 2383 | .rhs = undefined, |
| 2385 | 2384 | } |
| 2386 | 2385 | ); |
| 2387 | | stack.push(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2388 | | try stack.push(State { .Identifier = OptionalCtx { .Required = &node.rhs } }); |
| 2386 | stack.append(State { .SuffixOpExpressionEnd = opt_ctx.toRequired() }) catch unreachable; |
| 2387 | try stack.append(State { .Identifier = OptionalCtx { .Required = &node.rhs } }); |
| 2389 | 2388 | continue; |
| 2390 | 2389 | }, |
| 2391 | 2390 | else => { |
| ... | ... | @@ -2455,7 +2454,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2455 | 2454 | .return_type = undefined, |
| 2456 | 2455 | }; |
| 2457 | 2456 | const return_type_ptr = &((??node.result).return_type); |
| 2458 | | try stack.push(State { .Expression = OptionalCtx { .Required = return_type_ptr, } }); |
| 2457 | try stack.append(State { .Expression = OptionalCtx { .Required = return_type_ptr, } }); |
| 2459 | 2458 | continue; |
| 2460 | 2459 | }, |
| 2461 | 2460 | Token.Id.StringLiteral, Token.Id.MultilineStringLiteralLine => { |
| ... | ... | @@ -2471,13 +2470,13 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2471 | 2470 | .rparen = undefined, |
| 2472 | 2471 | } |
| 2473 | 2472 | ); |
| 2474 | | stack.push(State { |
| 2473 | stack.append(State { |
| 2475 | 2474 | .ExpectTokenSave = ExpectTokenSave { |
| 2476 | 2475 | .id = Token.Id.RParen, |
| 2477 | 2476 | .ptr = &node.rparen, |
| 2478 | 2477 | } |
| 2479 | 2478 | }) catch unreachable; |
| 2480 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 2479 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 2481 | 2480 | continue; |
| 2482 | 2481 | }, |
| 2483 | 2482 | Token.Id.Builtin => { |
| ... | ... | @@ -2489,14 +2488,14 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2489 | 2488 | .rparen_token = undefined, |
| 2490 | 2489 | } |
| 2491 | 2490 | ); |
| 2492 | | stack.push(State { |
| 2491 | stack.append(State { |
| 2493 | 2492 | .ExprListItemOrEnd = ExprListCtx { |
| 2494 | 2493 | .list = &node.params, |
| 2495 | 2494 | .end = Token.Id.RParen, |
| 2496 | 2495 | .ptr = &node.rparen_token, |
| 2497 | 2496 | } |
| 2498 | 2497 | }) catch unreachable; |
| 2499 | | try stack.push(State { .ExpectToken = Token.Id.LParen, }); |
| 2498 | try stack.append(State { .ExpectToken = Token.Id.LParen, }); |
| 2500 | 2499 | continue; |
| 2501 | 2500 | }, |
| 2502 | 2501 | Token.Id.LBracket => { |
| ... | ... | @@ -2508,11 +2507,11 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2508 | 2507 | .rhs = undefined, |
| 2509 | 2508 | } |
| 2510 | 2509 | ); |
| 2511 | | stack.push(State { .SliceOrArrayType = node }) catch unreachable; |
| 2510 | stack.append(State { .SliceOrArrayType = node }) catch unreachable; |
| 2512 | 2511 | continue; |
| 2513 | 2512 | }, |
| 2514 | 2513 | Token.Id.Keyword_error => { |
| 2515 | | stack.push(State { |
| 2514 | stack.append(State { |
| 2516 | 2515 | .ErrorTypeOrSetDecl = ErrorTypeOrSetDeclCtx { |
| 2517 | 2516 | .error_token = token.index, |
| 2518 | 2517 | .opt_ctx = opt_ctx |
| ... | ... | @@ -2521,7 +2520,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2521 | 2520 | continue; |
| 2522 | 2521 | }, |
| 2523 | 2522 | Token.Id.Keyword_packed => { |
| 2524 | | stack.push(State { |
| 2523 | stack.append(State { |
| 2525 | 2524 | .ContainerKind = ContainerKindCtx { |
| 2526 | 2525 | .opt_ctx = opt_ctx, |
| 2527 | 2526 | .ltoken = token.index, |
| ... | ... | @@ -2531,7 +2530,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2531 | 2530 | continue; |
| 2532 | 2531 | }, |
| 2533 | 2532 | Token.Id.Keyword_extern => { |
| 2534 | | stack.push(State { |
| 2533 | stack.append(State { |
| 2535 | 2534 | .ExternType = ExternTypeCtx { |
| 2536 | 2535 | .opt_ctx = opt_ctx, |
| 2537 | 2536 | .extern_token = token.index, |
| ... | ... | @@ -2542,7 +2541,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2542 | 2541 | }, |
| 2543 | 2542 | Token.Id.Keyword_struct, Token.Id.Keyword_union, Token.Id.Keyword_enum => { |
| 2544 | 2543 | putBackToken(&tok_it, &tree); |
| 2545 | | stack.push(State { |
| 2544 | stack.append(State { |
| 2546 | 2545 | .ContainerKind = ContainerKindCtx { |
| 2547 | 2546 | .opt_ctx = opt_ctx, |
| 2548 | 2547 | .ltoken = token.index, |
| ... | ... | @@ -2552,7 +2551,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2552 | 2551 | continue; |
| 2553 | 2552 | }, |
| 2554 | 2553 | Token.Id.Identifier => { |
| 2555 | | stack.push(State { |
| 2554 | stack.append(State { |
| 2556 | 2555 | .MaybeLabeledExpression = MaybeLabeledExpressionCtx { |
| 2557 | 2556 | .label = token.index, |
| 2558 | 2557 | .opt_ctx = opt_ctx |
| ... | ... | @@ -2580,7 +2579,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2580 | 2579 | .align_expr = null, |
| 2581 | 2580 | }); |
| 2582 | 2581 | opt_ctx.store(&fn_proto.base); |
| 2583 | | stack.push(State { .FnProto = fn_proto }) catch unreachable; |
| 2582 | stack.append(State { .FnProto = fn_proto }) catch unreachable; |
| 2584 | 2583 | continue; |
| 2585 | 2584 | }, |
| 2586 | 2585 | Token.Id.Keyword_nakedcc, Token.Id.Keyword_stdcallcc => { |
| ... | ... | @@ -2603,8 +2602,8 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2603 | 2602 | .align_expr = null, |
| 2604 | 2603 | }); |
| 2605 | 2604 | opt_ctx.store(&fn_proto.base); |
| 2606 | | stack.push(State { .FnProto = fn_proto }) catch unreachable; |
| 2607 | | try stack.push(State { |
| 2605 | stack.append(State { .FnProto = fn_proto }) catch unreachable; |
| 2606 | try stack.append(State { |
| 2608 | 2607 | .ExpectTokenSave = ExpectTokenSave { |
| 2609 | 2608 | .id = Token.Id.Keyword_fn, |
| 2610 | 2609 | .ptr = &fn_proto.fn_token |
| ... | ... | @@ -2625,21 +2624,21 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2625 | 2624 | .rparen = undefined, |
| 2626 | 2625 | } |
| 2627 | 2626 | ); |
| 2628 | | stack.push(State { |
| 2627 | stack.append(State { |
| 2629 | 2628 | .ExpectTokenSave = ExpectTokenSave { |
| 2630 | 2629 | .id = Token.Id.RParen, |
| 2631 | 2630 | .ptr = &node.rparen, |
| 2632 | 2631 | } |
| 2633 | 2632 | }) catch unreachable; |
| 2634 | | try stack.push(State { .AsmClobberItems = &node.clobbers }); |
| 2635 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 2636 | | try stack.push(State { .AsmInputItems = &node.inputs }); |
| 2637 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 2638 | | try stack.push(State { .AsmOutputItems = &node.outputs }); |
| 2639 | | try stack.push(State { .IfToken = Token.Id.Colon }); |
| 2640 | | try stack.push(State { .StringLiteral = OptionalCtx { .Required = &node.template } }); |
| 2641 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 2642 | | try stack.push(State { |
| 2633 | try stack.append(State { .AsmClobberItems = &node.clobbers }); |
| 2634 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 2635 | try stack.append(State { .AsmInputItems = &node.inputs }); |
| 2636 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 2637 | try stack.append(State { .AsmOutputItems = &node.outputs }); |
| 2638 | try stack.append(State { .IfToken = Token.Id.Colon }); |
| 2639 | try stack.append(State { .StringLiteral = OptionalCtx { .Required = &node.template } }); |
| 2640 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 2641 | try stack.append(State { |
| 2643 | 2642 | .OptionalTokenSave = OptionalTokenSave { |
| 2644 | 2643 | .id = Token.Id.Keyword_volatile, |
| 2645 | 2644 | .ptr = &node.volatile_token, |
| ... | ... | @@ -2647,7 +2646,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2647 | 2646 | }); |
| 2648 | 2647 | }, |
| 2649 | 2648 | Token.Id.Keyword_inline => { |
| 2650 | | stack.push(State { |
| 2649 | stack.append(State { |
| 2651 | 2650 | .Inline = InlineCtx { |
| 2652 | 2651 | .label = null, |
| 2653 | 2652 | .inline_token = token.index, |
| ... | ... | @@ -2688,7 +2687,7 @@ pub fn parse(allocator: &mem.Allocator, source: []const u8) !ast.Tree { |
| 2688 | 2687 | }); |
| 2689 | 2688 | ctx.opt_ctx.store(&node.base); |
| 2690 | 2689 | |
| 2691 | | stack.push(State { |
| 2690 | stack.append(State { |
| 2692 | 2691 | .ErrorTagListItemOrEnd = ListSave(@typeOf(node.decls)) { |
| 2693 | 2692 | .list = &node.decls, |
| 2694 | 2693 | .ptr = &node.rbrace_token, |
| ... | ... | @@ -3153,7 +3152,7 @@ fn parseStringLiteral(arena: &mem.Allocator, tok_it: &ast.Tree.TokenList.Iterato |
| 3153 | 3152 | } |
| 3154 | 3153 | } |
| 3155 | 3154 | |
| 3156 | | fn parseBlockExpr(stack: &SegmentedList(State, 32), arena: &mem.Allocator, ctx: &const OptionalCtx, |
| 3155 | fn parseBlockExpr(stack: &std.ArrayList(State), arena: &mem.Allocator, ctx: &const OptionalCtx, |
| 3157 | 3156 | token_ptr: &const Token, token_index: TokenIndex) !bool { |
| 3158 | 3157 | switch (token_ptr.id) { |
| 3159 | 3158 | Token.Id.Keyword_suspend => { |
| ... | ... | @@ -3167,8 +3166,8 @@ fn parseBlockExpr(stack: &SegmentedList(State, 32), arena: &mem.Allocator, ctx: |
| 3167 | 3166 | } |
| 3168 | 3167 | ); |
| 3169 | 3168 | |
| 3170 | | stack.push(State { .SuspendBody = node }) catch unreachable; |
| 3171 | | try stack.push(State { .Payload = OptionalCtx { .Optional = &node.payload } }); |
| 3169 | stack.append(State { .SuspendBody = node }) catch unreachable; |
| 3170 | try stack.append(State { .Payload = OptionalCtx { .Optional = &node.payload } }); |
| 3172 | 3171 | return true; |
| 3173 | 3172 | }, |
| 3174 | 3173 | Token.Id.Keyword_if => { |
| ... | ... | @@ -3183,16 +3182,16 @@ fn parseBlockExpr(stack: &SegmentedList(State, 32), arena: &mem.Allocator, ctx: |
| 3183 | 3182 | } |
| 3184 | 3183 | ); |
| 3185 | 3184 | |
| 3186 | | stack.push(State { .Else = &node.@"else" }) catch unreachable; |
| 3187 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.body } }); |
| 3188 | | try stack.push(State { .PointerPayload = OptionalCtx { .Optional = &node.payload } }); |
| 3189 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 3190 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.condition } }); |
| 3191 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 3185 | stack.append(State { .Else = &node.@"else" }) catch unreachable; |
| 3186 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.body } }); |
| 3187 | try stack.append(State { .PointerPayload = OptionalCtx { .Optional = &node.payload } }); |
| 3188 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 3189 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.condition } }); |
| 3190 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 3192 | 3191 | return true; |
| 3193 | 3192 | }, |
| 3194 | 3193 | Token.Id.Keyword_while => { |
| 3195 | | stack.push(State { |
| 3194 | stack.append(State { |
| 3196 | 3195 | .While = LoopCtx { |
| 3197 | 3196 | .label = null, |
| 3198 | 3197 | .inline_token = null, |
| ... | ... | @@ -3203,7 +3202,7 @@ fn parseBlockExpr(stack: &SegmentedList(State, 32), arena: &mem.Allocator, ctx: |
| 3203 | 3202 | return true; |
| 3204 | 3203 | }, |
| 3205 | 3204 | Token.Id.Keyword_for => { |
| 3206 | | stack.push(State { |
| 3205 | stack.append(State { |
| 3207 | 3206 | .For = LoopCtx { |
| 3208 | 3207 | .label = null, |
| 3209 | 3208 | .inline_token = null, |
| ... | ... | @@ -3225,16 +3224,16 @@ fn parseBlockExpr(stack: &SegmentedList(State, 32), arena: &mem.Allocator, ctx: |
| 3225 | 3224 | }); |
| 3226 | 3225 | ctx.store(&node.base); |
| 3227 | 3226 | |
| 3228 | | stack.push(State { |
| 3227 | stack.append(State { |
| 3229 | 3228 | .SwitchCaseOrEnd = ListSave(@typeOf(node.cases)) { |
| 3230 | 3229 | .list = &node.cases, |
| 3231 | 3230 | .ptr = &node.rbrace, |
| 3232 | 3231 | }, |
| 3233 | 3232 | }) catch unreachable; |
| 3234 | | try stack.push(State { .ExpectToken = Token.Id.LBrace }); |
| 3235 | | try stack.push(State { .ExpectToken = Token.Id.RParen }); |
| 3236 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 3237 | | try stack.push(State { .ExpectToken = Token.Id.LParen }); |
| 3233 | try stack.append(State { .ExpectToken = Token.Id.LBrace }); |
| 3234 | try stack.append(State { .ExpectToken = Token.Id.RParen }); |
| 3235 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 3236 | try stack.append(State { .ExpectToken = Token.Id.LParen }); |
| 3238 | 3237 | return true; |
| 3239 | 3238 | }, |
| 3240 | 3239 | Token.Id.Keyword_comptime => { |
| ... | ... | @@ -3246,7 +3245,7 @@ fn parseBlockExpr(stack: &SegmentedList(State, 32), arena: &mem.Allocator, ctx: |
| 3246 | 3245 | .doc_comments = null, |
| 3247 | 3246 | } |
| 3248 | 3247 | ); |
| 3249 | | try stack.push(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 3248 | try stack.append(State { .Expression = OptionalCtx { .Required = &node.expr } }); |
| 3250 | 3249 | return true; |
| 3251 | 3250 | }, |
| 3252 | 3251 | Token.Id.LBrace => { |
| ... | ... | @@ -3258,7 +3257,7 @@ fn parseBlockExpr(stack: &SegmentedList(State, 32), arena: &mem.Allocator, ctx: |
| 3258 | 3257 | .rbrace = undefined, |
| 3259 | 3258 | }); |
| 3260 | 3259 | ctx.store(&block.base); |
| 3261 | | stack.push(State { .Block = block }) catch unreachable; |
| 3260 | stack.append(State { .Block = block }) catch unreachable; |
| 3262 | 3261 | return true; |
| 3263 | 3262 | }, |
| 3264 | 3263 | else => { |
| ... | ... | @@ -3473,10 +3472,10 @@ const RenderAstFrame = struct { |
| 3473 | 3472 | }; |
| 3474 | 3473 | |
| 3475 | 3474 | pub fn renderAst(allocator: &mem.Allocator, tree: &const ast.Tree, stream: var) !void { |
| 3476 | | var stack = SegmentedList(State, 32).init(allocator); |
| 3475 | var stack = std.ArrayList(State).init(allocator); |
| 3477 | 3476 | defer stack.deinit(); |
| 3478 | 3477 | |
| 3479 | | try stack.push(RenderAstFrame { |
| 3478 | try stack.append(RenderAstFrame { |
| 3480 | 3479 | .node = &root_node.base, |
| 3481 | 3480 | .indent = 0, |
| 3482 | 3481 | }); |
| ... | ... | @@ -3491,7 +3490,7 @@ pub fn renderAst(allocator: &mem.Allocator, tree: &const ast.Tree, stream: var) |
| 3491 | 3490 | try stream.print("{}\n", @tagName(frame.node.id)); |
| 3492 | 3491 | var child_i: usize = 0; |
| 3493 | 3492 | while (frame.node.iterate(child_i)) |child| : (child_i += 1) { |
| 3494 | | try stack.push(RenderAstFrame { |
| 3493 | try stack.append(RenderAstFrame { |
| 3495 | 3494 | .node = child, |
| 3496 | 3495 | .indent = frame.indent + 2, |
| 3497 | 3496 | }); |