| author | |
| committer | |
| log | bb22490fcc8ed7c96d665242cd18934f9d547555 |
| tree | 5703427c6d2830c87b001fdd8b57fbb63a22a46b |
| parent | e2289961c6b53451e5bdcdfb6eec27e27f6553ca |
| signature |
3 files changed, 1003 insertions(+), 1003 deletions(-)
lib/std/zig/ast.zig+576-576| ... | ... | @@ -199,148 +199,148 @@ pub const Tree = struct { |
| 199 | 199 | var end_offset: TokenIndex = 0; |
| 200 | 200 | var n = node; |
| 201 | 201 | while (true) switch (tags[n]) { |
| 202 | .Root => return 0, | |
| 203 | ||
| 204 | .UsingNamespace, | |
| 205 | .TestDecl, | |
| 206 | .ErrDefer, | |
| 207 | .Defer, | |
| 208 | .BoolNot, | |
| 209 | .Negation, | |
| 210 | .BitNot, | |
| 211 | .NegationWrap, | |
| 212 | .AddressOf, | |
| 213 | .Try, | |
| 214 | .Await, | |
| 215 | .OptionalType, | |
| 216 | .Switch, | |
| 217 | .SwitchComma, | |
| 218 | .IfSimple, | |
| 219 | .If, | |
| 220 | .Suspend, | |
| 221 | .Resume, | |
| 222 | .Continue, | |
| 223 | .Break, | |
| 224 | .Return, | |
| 225 | .AnyFrameType, | |
| 226 | .Identifier, | |
| 227 | .AnyFrameLiteral, | |
| 228 | .CharLiteral, | |
| 229 | .IntegerLiteral, | |
| 230 | .FloatLiteral, | |
| 231 | .FalseLiteral, | |
| 232 | .TrueLiteral, | |
| 233 | .NullLiteral, | |
| 234 | .UndefinedLiteral, | |
| 235 | .UnreachableLiteral, | |
| 236 | .StringLiteral, | |
| 237 | .GroupedExpression, | |
| 238 | .BuiltinCallTwo, | |
| 239 | .BuiltinCallTwoComma, | |
| 240 | .BuiltinCall, | |
| 241 | .BuiltinCallComma, | |
| 242 | .ErrorSetDecl, | |
| 243 | .AnyType, | |
| 244 | .Comptime, | |
| 245 | .Nosuspend, | |
| 246 | .AsmSimple, | |
| 247 | .Asm, | |
| 248 | .FnProtoSimple, | |
| 249 | .FnProtoMulti, | |
| 250 | .FnProtoOne, | |
| 251 | .FnProto, | |
| 252 | .ArrayType, | |
| 253 | .ArrayTypeSentinel, | |
| 254 | .ErrorValue, | |
| 202 | .root => return 0, | |
| 203 | ||
| 204 | .@"usingnamespace", | |
| 205 | .test_decl, | |
| 206 | .@"errdefer", | |
| 207 | .@"defer", | |
| 208 | .bool_not, | |
| 209 | .negation, | |
| 210 | .bit_not, | |
| 211 | .negation_wrap, | |
| 212 | .address_of, | |
| 213 | .@"try", | |
| 214 | .@"await", | |
| 215 | .optional_type, | |
| 216 | .@"switch", | |
| 217 | .switch_comma, | |
| 218 | .if_simple, | |
| 219 | .@"if", | |
| 220 | .@"suspend", | |
| 221 | .@"resume", | |
| 222 | .@"continue", | |
| 223 | .@"break", | |
| 224 | .@"return", | |
| 225 | .anyframe_type, | |
| 226 | .identifier, | |
| 227 | .anyframe_literal, | |
| 228 | .char_literal, | |
| 229 | .integer_literal, | |
| 230 | .float_literal, | |
| 231 | .false_literal, | |
| 232 | .true_literal, | |
| 233 | .null_literal, | |
| 234 | .undefined_literal, | |
| 235 | .unreachable_literal, | |
| 236 | .string_literal, | |
| 237 | .grouped_expression, | |
| 238 | .builtin_call_two, | |
| 239 | .builtin_call_two_comma, | |
| 240 | .builtin_call, | |
| 241 | .builtin_call_comma, | |
| 242 | .error_set_decl, | |
| 243 | .@"anytype", | |
| 244 | .@"comptime", | |
| 245 | .@"nosuspend", | |
| 246 | .asm_simple, | |
| 247 | .@"asm", | |
| 248 | .fn_proto_simple, | |
| 249 | .fn_proto_multi, | |
| 250 | .fn_proto_one, | |
| 251 | .fn_proto, | |
| 252 | .array_type, | |
| 253 | .array_type_sentinel, | |
| 254 | .error_value, | |
| 255 | 255 | => return main_tokens[n] - end_offset, |
| 256 | 256 | |
| 257 | .ArrayInitDot, | |
| 258 | .ArrayInitDotComma, | |
| 259 | .ArrayInitDotTwo, | |
| 260 | .ArrayInitDotTwoComma, | |
| 261 | .StructInitDot, | |
| 262 | .StructInitDotComma, | |
| 263 | .StructInitDotTwo, | |
| 264 | .StructInitDotTwoComma, | |
| 265 | .EnumLiteral, | |
| 257 | .array_init_dot, | |
| 258 | .array_init_dot_comma, | |
| 259 | .array_init_dot_two, | |
| 260 | .array_init_dot_two_comma, | |
| 261 | .struct_init_dot, | |
| 262 | .struct_init_dot_comma, | |
| 263 | .struct_init_dot_two, | |
| 264 | .struct_init_dot_two_comma, | |
| 265 | .enum_literal, | |
| 266 | 266 | => return main_tokens[n] - 1 - end_offset, |
| 267 | 267 | |
| 268 | .Catch, | |
| 269 | .FieldAccess, | |
| 270 | .UnwrapOptional, | |
| 271 | .EqualEqual, | |
| 272 | .BangEqual, | |
| 273 | .LessThan, | |
| 274 | .GreaterThan, | |
| 275 | .LessOrEqual, | |
| 276 | .GreaterOrEqual, | |
| 277 | .AssignMul, | |
| 278 | .AssignDiv, | |
| 279 | .AssignMod, | |
| 280 | .AssignAdd, | |
| 281 | .AssignSub, | |
| 282 | .AssignBitShiftLeft, | |
| 283 | .AssignBitShiftRight, | |
| 284 | .AssignBitAnd, | |
| 285 | .AssignBitXor, | |
| 286 | .AssignBitOr, | |
| 287 | .AssignMulWrap, | |
| 288 | .AssignAddWrap, | |
| 289 | .AssignSubWrap, | |
| 290 | .Assign, | |
| 291 | .MergeErrorSets, | |
| 292 | .Mul, | |
| 293 | .Div, | |
| 294 | .Mod, | |
| 295 | .ArrayMult, | |
| 296 | .MulWrap, | |
| 297 | .Add, | |
| 298 | .Sub, | |
| 299 | .ArrayCat, | |
| 300 | .AddWrap, | |
| 301 | .SubWrap, | |
| 302 | .BitShiftLeft, | |
| 303 | .BitShiftRight, | |
| 304 | .BitAnd, | |
| 305 | .BitXor, | |
| 306 | .BitOr, | |
| 307 | .OrElse, | |
| 308 | .BoolAnd, | |
| 309 | .BoolOr, | |
| 310 | .SliceOpen, | |
| 311 | .Slice, | |
| 312 | .SliceSentinel, | |
| 313 | .Deref, | |
| 314 | .ArrayAccess, | |
| 315 | .ArrayInitOne, | |
| 316 | .ArrayInitOneComma, | |
| 317 | .ArrayInit, | |
| 318 | .ArrayInitComma, | |
| 319 | .StructInitOne, | |
| 320 | .StructInitOneComma, | |
| 321 | .StructInit, | |
| 322 | .StructInitComma, | |
| 323 | .CallOne, | |
| 324 | .CallOneComma, | |
| 325 | .Call, | |
| 326 | .CallComma, | |
| 327 | .SwitchRange, | |
| 328 | .FnDecl, | |
| 329 | .ErrorUnion, | |
| 268 | .@"catch", | |
| 269 | .field_access, | |
| 270 | .unwrap_optional, | |
| 271 | .equal_equal, | |
| 272 | .bang_equal, | |
| 273 | .less_than, | |
| 274 | .greater_than, | |
| 275 | .less_or_equal, | |
| 276 | .greater_or_equal, | |
| 277 | .assign_mul, | |
| 278 | .assign_div, | |
| 279 | .assign_mod, | |
| 280 | .assign_add, | |
| 281 | .assign_sub, | |
| 282 | .assign_bit_shift_left, | |
| 283 | .assign_bit_shift_right, | |
| 284 | .assign_bit_and, | |
| 285 | .assign_bit_xor, | |
| 286 | .assign_bit_or, | |
| 287 | .assign_mul_wrap, | |
| 288 | .assign_add_wrap, | |
| 289 | .assign_sub_wrap, | |
| 290 | .assign, | |
| 291 | .merge_error_sets, | |
| 292 | .mul, | |
| 293 | .div, | |
| 294 | .mod, | |
| 295 | .array_mult, | |
| 296 | .mul_wrap, | |
| 297 | .add, | |
| 298 | .sub, | |
| 299 | .array_cat, | |
| 300 | .add_wrap, | |
| 301 | .sub_wrap, | |
| 302 | .bit_shift_left, | |
| 303 | .bit_shift_right, | |
| 304 | .bit_and, | |
| 305 | .bit_xor, | |
| 306 | .bit_or, | |
| 307 | .@"orelse", | |
| 308 | .bool_and, | |
| 309 | .bool_or, | |
| 310 | .slice_open, | |
| 311 | .slice, | |
| 312 | .slice_sentinel, | |
| 313 | .deref, | |
| 314 | .array_access, | |
| 315 | .array_init_one, | |
| 316 | .array_init_one_comma, | |
| 317 | .array_init, | |
| 318 | .array_init_comma, | |
| 319 | .struct_init_one, | |
| 320 | .struct_init_one_comma, | |
| 321 | .struct_init, | |
| 322 | .struct_init_comma, | |
| 323 | .call_one, | |
| 324 | .call_one_comma, | |
| 325 | .call, | |
| 326 | .call_comma, | |
| 327 | .switch_range, | |
| 328 | .fn_decl, | |
| 329 | .error_union, | |
| 330 | 330 | => n = datas[n].lhs, |
| 331 | 331 | |
| 332 | .AsyncCallOne, | |
| 333 | .AsyncCallOneComma, | |
| 334 | .AsyncCall, | |
| 335 | .AsyncCallComma, | |
| 332 | .async_call_one, | |
| 333 | .async_call_one_comma, | |
| 334 | .async_call, | |
| 335 | .async_call_comma, | |
| 336 | 336 | => { |
| 337 | 337 | end_offset += 1; // async token |
| 338 | 338 | n = datas[n].lhs; |
| 339 | 339 | }, |
| 340 | 340 | |
| 341 | .ContainerFieldInit, | |
| 342 | .ContainerFieldAlign, | |
| 343 | .ContainerField, | |
| 341 | .container_field_init, | |
| 342 | .container_field_align, | |
| 343 | .container_field, | |
| 344 | 344 | => { |
| 345 | 345 | const name_token = main_tokens[n]; |
| 346 | 346 | if (name_token > 0 and token_tags[name_token - 1] == .keyword_comptime) { |
| ... | ... | @@ -349,10 +349,10 @@ pub const Tree = struct { |
| 349 | 349 | return name_token - end_offset; |
| 350 | 350 | }, |
| 351 | 351 | |
| 352 | .GlobalVarDecl, | |
| 353 | .LocalVarDecl, | |
| 354 | .SimpleVarDecl, | |
| 355 | .AlignedVarDecl, | |
| 352 | .global_var_decl, | |
| 353 | .local_var_decl, | |
| 354 | .simple_var_decl, | |
| 355 | .aligned_var_decl, | |
| 356 | 356 | => { |
| 357 | 357 | var i = main_tokens[n]; // mut token |
| 358 | 358 | while (i > 0) { |
| ... | ... | @@ -372,10 +372,10 @@ pub const Tree = struct { |
| 372 | 372 | return i - end_offset; |
| 373 | 373 | }, |
| 374 | 374 | |
| 375 | .Block, | |
| 376 | .BlockSemicolon, | |
| 377 | .BlockTwo, | |
| 378 | .BlockTwoSemicolon, | |
| 375 | .block, | |
| 376 | .block_semicolon, | |
| 377 | .block_two, | |
| 378 | .block_two_semicolon, | |
| 379 | 379 | => { |
| 380 | 380 | // Look for a label. |
| 381 | 381 | const lbrace = main_tokens[n]; |
| ... | ... | @@ -385,18 +385,18 @@ pub const Tree = struct { |
| 385 | 385 | return lbrace - end_offset; |
| 386 | 386 | }, |
| 387 | 387 | |
| 388 | .ContainerDecl, | |
| 389 | .ContainerDeclComma, | |
| 390 | .ContainerDeclTwo, | |
| 391 | .ContainerDeclTwoComma, | |
| 392 | .ContainerDeclArg, | |
| 393 | .ContainerDeclArgComma, | |
| 394 | .TaggedUnion, | |
| 395 | .TaggedUnionComma, | |
| 396 | .TaggedUnionTwo, | |
| 397 | .TaggedUnionTwoComma, | |
| 398 | .TaggedUnionEnumTag, | |
| 399 | .TaggedUnionEnumTagComma, | |
| 388 | .container_decl, | |
| 389 | .container_decl_comma, | |
| 390 | .container_decl_two, | |
| 391 | .container_decl_two_comma, | |
| 392 | .container_decl_arg, | |
| 393 | .container_decl_arg_comma, | |
| 394 | .tagged_union, | |
| 395 | .tagged_union_comma, | |
| 396 | .tagged_union_two, | |
| 397 | .tagged_union_two_comma, | |
| 398 | .tagged_union_enum_tag, | |
| 399 | .tagged_union_enum_tag_comma, | |
| 400 | 400 | => { |
| 401 | 401 | const main_token = main_tokens[n]; |
| 402 | 402 | switch (token_tags[main_token - 1]) { |
| ... | ... | @@ -406,10 +406,10 @@ pub const Tree = struct { |
| 406 | 406 | return main_token - end_offset; |
| 407 | 407 | }, |
| 408 | 408 | |
| 409 | .PtrTypeAligned, | |
| 410 | .PtrTypeSentinel, | |
| 411 | .PtrType, | |
| 412 | .PtrTypeBitRange, | |
| 409 | .ptr_type_aligned, | |
| 410 | .ptr_type_sentinel, | |
| 411 | .ptr_type, | |
| 412 | .ptr_type_bit_range, | |
| 413 | 413 | => { |
| 414 | 414 | const main_token = main_tokens[n]; |
| 415 | 415 | return switch (token_tags[main_token]) { |
| ... | ... | @@ -424,29 +424,29 @@ pub const Tree = struct { |
| 424 | 424 | } - end_offset; |
| 425 | 425 | }, |
| 426 | 426 | |
| 427 | .SwitchCaseOne => { | |
| 427 | .switch_case_one => { | |
| 428 | 428 | if (datas[n].lhs == 0) { |
| 429 | 429 | return main_tokens[n] - 1 - end_offset; // else token |
| 430 | 430 | } else { |
| 431 | 431 | n = datas[n].lhs; |
| 432 | 432 | } |
| 433 | 433 | }, |
| 434 | .SwitchCase => { | |
| 434 | .switch_case => { | |
| 435 | 435 | const extra = tree.extraData(datas[n].lhs, Node.SubRange); |
| 436 | 436 | assert(extra.end - extra.start > 0); |
| 437 | 437 | n = extra.start; |
| 438 | 438 | }, |
| 439 | 439 | |
| 440 | .AsmOutput, .AsmInput => { | |
| 440 | .asm_output, .asm_input => { | |
| 441 | 441 | assert(token_tags[main_tokens[n] - 1] == .l_bracket); |
| 442 | 442 | return main_tokens[n] - 1 - end_offset; |
| 443 | 443 | }, |
| 444 | 444 | |
| 445 | .WhileSimple, | |
| 446 | .WhileCont, | |
| 447 | .While, | |
| 448 | .ForSimple, | |
| 449 | .For, | |
| 445 | .while_simple, | |
| 446 | .while_cont, | |
| 447 | .@"while", | |
| 448 | .for_simple, | |
| 449 | .@"for", | |
| 450 | 450 | => { |
| 451 | 451 | const main_token = main_tokens[n]; |
| 452 | 452 | return switch (token_tags[main_token - 1]) { |
| ... | ... | @@ -465,115 +465,115 @@ pub const Tree = struct { |
| 465 | 465 | var n = node; |
| 466 | 466 | var end_offset: TokenIndex = 0; |
| 467 | 467 | while (true) switch (tags[n]) { |
| 468 | .Root => return @intCast(TokenIndex, tree.tokens.len - 1), | |
| 469 | ||
| 470 | .UsingNamespace, | |
| 471 | .BoolNot, | |
| 472 | .Negation, | |
| 473 | .BitNot, | |
| 474 | .NegationWrap, | |
| 475 | .AddressOf, | |
| 476 | .Try, | |
| 477 | .Await, | |
| 478 | .OptionalType, | |
| 479 | .Resume, | |
| 480 | .Nosuspend, | |
| 481 | .Comptime, | |
| 468 | .root => return @intCast(TokenIndex, tree.tokens.len - 1), | |
| 469 | ||
| 470 | .@"usingnamespace", | |
| 471 | .bool_not, | |
| 472 | .negation, | |
| 473 | .bit_not, | |
| 474 | .negation_wrap, | |
| 475 | .address_of, | |
| 476 | .@"try", | |
| 477 | .@"await", | |
| 478 | .optional_type, | |
| 479 | .@"resume", | |
| 480 | .@"nosuspend", | |
| 481 | .@"comptime", | |
| 482 | 482 | => n = datas[n].lhs, |
| 483 | 483 | |
| 484 | .TestDecl, | |
| 485 | .ErrDefer, | |
| 486 | .Defer, | |
| 487 | .Catch, | |
| 488 | .EqualEqual, | |
| 489 | .BangEqual, | |
| 490 | .LessThan, | |
| 491 | .GreaterThan, | |
| 492 | .LessOrEqual, | |
| 493 | .GreaterOrEqual, | |
| 494 | .AssignMul, | |
| 495 | .AssignDiv, | |
| 496 | .AssignMod, | |
| 497 | .AssignAdd, | |
| 498 | .AssignSub, | |
| 499 | .AssignBitShiftLeft, | |
| 500 | .AssignBitShiftRight, | |
| 501 | .AssignBitAnd, | |
| 502 | .AssignBitXor, | |
| 503 | .AssignBitOr, | |
| 504 | .AssignMulWrap, | |
| 505 | .AssignAddWrap, | |
| 506 | .AssignSubWrap, | |
| 507 | .Assign, | |
| 508 | .MergeErrorSets, | |
| 509 | .Mul, | |
| 510 | .Div, | |
| 511 | .Mod, | |
| 512 | .ArrayMult, | |
| 513 | .MulWrap, | |
| 514 | .Add, | |
| 515 | .Sub, | |
| 516 | .ArrayCat, | |
| 517 | .AddWrap, | |
| 518 | .SubWrap, | |
| 519 | .BitShiftLeft, | |
| 520 | .BitShiftRight, | |
| 521 | .BitAnd, | |
| 522 | .BitXor, | |
| 523 | .BitOr, | |
| 524 | .OrElse, | |
| 525 | .BoolAnd, | |
| 526 | .BoolOr, | |
| 527 | .AnyFrameType, | |
| 528 | .ErrorUnion, | |
| 529 | .IfSimple, | |
| 530 | .WhileSimple, | |
| 531 | .ForSimple, | |
| 532 | .FnProtoSimple, | |
| 533 | .FnProtoMulti, | |
| 534 | .PtrTypeAligned, | |
| 535 | .PtrTypeSentinel, | |
| 536 | .PtrType, | |
| 537 | .PtrTypeBitRange, | |
| 538 | .ArrayType, | |
| 539 | .SwitchCaseOne, | |
| 540 | .SwitchCase, | |
| 541 | .SwitchRange, | |
| 484 | .test_decl, | |
| 485 | .@"errdefer", | |
| 486 | .@"defer", | |
| 487 | .@"catch", | |
| 488 | .equal_equal, | |
| 489 | .bang_equal, | |
| 490 | .less_than, | |
| 491 | .greater_than, | |
| 492 | .less_or_equal, | |
| 493 | .greater_or_equal, | |
| 494 | .assign_mul, | |
| 495 | .assign_div, | |
| 496 | .assign_mod, | |
| 497 | .assign_add, | |
| 498 | .assign_sub, | |
| 499 | .assign_bit_shift_left, | |
| 500 | .assign_bit_shift_right, | |
| 501 | .assign_bit_and, | |
| 502 | .assign_bit_xor, | |
| 503 | .assign_bit_or, | |
| 504 | .assign_mul_wrap, | |
| 505 | .assign_add_wrap, | |
| 506 | .assign_sub_wrap, | |
| 507 | .assign, | |
| 508 | .merge_error_sets, | |
| 509 | .mul, | |
| 510 | .div, | |
| 511 | .mod, | |
| 512 | .array_mult, | |
| 513 | .mul_wrap, | |
| 514 | .add, | |
| 515 | .sub, | |
| 516 | .array_cat, | |
| 517 | .add_wrap, | |
| 518 | .sub_wrap, | |
| 519 | .bit_shift_left, | |
| 520 | .bit_shift_right, | |
| 521 | .bit_and, | |
| 522 | .bit_xor, | |
| 523 | .bit_or, | |
| 524 | .@"orelse", | |
| 525 | .bool_and, | |
| 526 | .bool_or, | |
| 527 | .anyframe_type, | |
| 528 | .error_union, | |
| 529 | .if_simple, | |
| 530 | .while_simple, | |
| 531 | .for_simple, | |
| 532 | .fn_proto_simple, | |
| 533 | .fn_proto_multi, | |
| 534 | .ptr_type_aligned, | |
| 535 | .ptr_type_sentinel, | |
| 536 | .ptr_type, | |
| 537 | .ptr_type_bit_range, | |
| 538 | .array_type, | |
| 539 | .switch_case_one, | |
| 540 | .switch_case, | |
| 541 | .switch_range, | |
| 542 | 542 | => n = datas[n].rhs, |
| 543 | 543 | |
| 544 | .FieldAccess, | |
| 545 | .UnwrapOptional, | |
| 546 | .GroupedExpression, | |
| 547 | .StringLiteral, | |
| 548 | .ErrorSetDecl, | |
| 549 | .AsmSimple, | |
| 550 | .AsmOutput, | |
| 551 | .AsmInput, | |
| 552 | .ErrorValue, | |
| 544 | .field_access, | |
| 545 | .unwrap_optional, | |
| 546 | .grouped_expression, | |
| 547 | .string_literal, | |
| 548 | .error_set_decl, | |
| 549 | .asm_simple, | |
| 550 | .asm_output, | |
| 551 | .asm_input, | |
| 552 | .error_value, | |
| 553 | 553 | => return datas[n].rhs + end_offset, |
| 554 | 554 | |
| 555 | .AnyType, | |
| 556 | .AnyFrameLiteral, | |
| 557 | .CharLiteral, | |
| 558 | .IntegerLiteral, | |
| 559 | .FloatLiteral, | |
| 560 | .FalseLiteral, | |
| 561 | .TrueLiteral, | |
| 562 | .NullLiteral, | |
| 563 | .UndefinedLiteral, | |
| 564 | .UnreachableLiteral, | |
| 565 | .Identifier, | |
| 566 | .Deref, | |
| 567 | .EnumLiteral, | |
| 555 | .@"anytype", | |
| 556 | .anyframe_literal, | |
| 557 | .char_literal, | |
| 558 | .integer_literal, | |
| 559 | .float_literal, | |
| 560 | .false_literal, | |
| 561 | .true_literal, | |
| 562 | .null_literal, | |
| 563 | .undefined_literal, | |
| 564 | .unreachable_literal, | |
| 565 | .identifier, | |
| 566 | .deref, | |
| 567 | .enum_literal, | |
| 568 | 568 | => return main_tokens[n] + end_offset, |
| 569 | 569 | |
| 570 | .Return => if (datas[n].lhs != 0) { | |
| 570 | .@"return" => if (datas[n].lhs != 0) { | |
| 571 | 571 | n = datas[n].lhs; |
| 572 | 572 | } else { |
| 573 | 573 | return main_tokens[n] + end_offset; |
| 574 | 574 | }, |
| 575 | 575 | |
| 576 | .Call, .AsyncCall => { | |
| 576 | .call, .async_call => { | |
| 577 | 577 | end_offset += 1; // for the rparen |
| 578 | 578 | const params = tree.extraData(datas[n].rhs, Node.SubRange); |
| 579 | 579 | if (params.end - params.start == 0) { |
| ... | ... | @@ -581,7 +581,7 @@ pub const Tree = struct { |
| 581 | 581 | } |
| 582 | 582 | n = tree.extra_data[params.end - 1]; // last parameter |
| 583 | 583 | }, |
| 584 | .TaggedUnionEnumTag => { | |
| 584 | .tagged_union_enum_tag => { | |
| 585 | 585 | const members = tree.extraData(datas[n].rhs, Node.SubRange); |
| 586 | 586 | if (members.end - members.start == 0) { |
| 587 | 587 | end_offset += 4; // for the rparen + rparen + lbrace + rbrace |
| ... | ... | @@ -591,16 +591,16 @@ pub const Tree = struct { |
| 591 | 591 | n = tree.extra_data[members.end - 1]; // last parameter |
| 592 | 592 | } |
| 593 | 593 | }, |
| 594 | .CallComma, | |
| 595 | .AsyncCallComma, | |
| 596 | .TaggedUnionEnumTagComma, | |
| 594 | .call_comma, | |
| 595 | .async_call_comma, | |
| 596 | .tagged_union_enum_tag_comma, | |
| 597 | 597 | => { |
| 598 | 598 | end_offset += 2; // for the comma + rparen/rbrace |
| 599 | 599 | const params = tree.extraData(datas[n].rhs, Node.SubRange); |
| 600 | 600 | assert(params.end > params.start); |
| 601 | 601 | n = tree.extra_data[params.end - 1]; // last parameter |
| 602 | 602 | }, |
| 603 | .Switch => { | |
| 603 | .@"switch" => { | |
| 604 | 604 | const cases = tree.extraData(datas[n].rhs, Node.SubRange); |
| 605 | 605 | if (cases.end - cases.start == 0) { |
| 606 | 606 | end_offset += 3; // rparen, lbrace, rbrace |
| ... | ... | @@ -610,7 +610,7 @@ pub const Tree = struct { |
| 610 | 610 | n = tree.extra_data[cases.end - 1]; // last case |
| 611 | 611 | } |
| 612 | 612 | }, |
| 613 | .ContainerDeclArg => { | |
| 613 | .container_decl_arg => { | |
| 614 | 614 | const members = tree.extraData(datas[n].rhs, Node.SubRange); |
| 615 | 615 | if (members.end - members.start == 0) { |
| 616 | 616 | end_offset += 1; // for the rparen |
| ... | ... | @@ -620,53 +620,53 @@ pub const Tree = struct { |
| 620 | 620 | n = tree.extra_data[members.end - 1]; // last parameter |
| 621 | 621 | } |
| 622 | 622 | }, |
| 623 | .Asm => { | |
| 623 | .@"asm" => { | |
| 624 | 624 | const extra = tree.extraData(datas[n].rhs, Node.Asm); |
| 625 | 625 | return extra.rparen + end_offset; |
| 626 | 626 | }, |
| 627 | .ArrayInit, | |
| 628 | .StructInit, | |
| 627 | .array_init, | |
| 628 | .struct_init, | |
| 629 | 629 | => { |
| 630 | 630 | const elements = tree.extraData(datas[n].rhs, Node.SubRange); |
| 631 | 631 | assert(elements.end - elements.start > 0); |
| 632 | 632 | end_offset += 1; // for the rbrace |
| 633 | 633 | n = tree.extra_data[elements.end - 1]; // last element |
| 634 | 634 | }, |
| 635 | .ArrayInitComma, | |
| 636 | .StructInitComma, | |
| 637 | .ContainerDeclArgComma, | |
| 638 | .SwitchComma, | |
| 635 | .array_init_comma, | |
| 636 | .struct_init_comma, | |
| 637 | .container_decl_arg_comma, | |
| 638 | .switch_comma, | |
| 639 | 639 | => { |
| 640 | 640 | const members = tree.extraData(datas[n].rhs, Node.SubRange); |
| 641 | 641 | assert(members.end - members.start > 0); |
| 642 | 642 | end_offset += 2; // for the comma + rbrace |
| 643 | 643 | n = tree.extra_data[members.end - 1]; // last parameter |
| 644 | 644 | }, |
| 645 | .ArrayInitDot, | |
| 646 | .StructInitDot, | |
| 647 | .Block, | |
| 648 | .ContainerDecl, | |
| 649 | .TaggedUnion, | |
| 650 | .BuiltinCall, | |
| 645 | .array_init_dot, | |
| 646 | .struct_init_dot, | |
| 647 | .block, | |
| 648 | .container_decl, | |
| 649 | .tagged_union, | |
| 650 | .builtin_call, | |
| 651 | 651 | => { |
| 652 | 652 | assert(datas[n].rhs - datas[n].lhs > 0); |
| 653 | 653 | end_offset += 1; // for the rbrace |
| 654 | 654 | n = tree.extra_data[datas[n].rhs - 1]; // last statement |
| 655 | 655 | }, |
| 656 | .ArrayInitDotComma, | |
| 657 | .StructInitDotComma, | |
| 658 | .BlockSemicolon, | |
| 659 | .ContainerDeclComma, | |
| 660 | .TaggedUnionComma, | |
| 661 | .BuiltinCallComma, | |
| 656 | .array_init_dot_comma, | |
| 657 | .struct_init_dot_comma, | |
| 658 | .block_semicolon, | |
| 659 | .container_decl_comma, | |
| 660 | .tagged_union_comma, | |
| 661 | .builtin_call_comma, | |
| 662 | 662 | => { |
| 663 | 663 | assert(datas[n].rhs - datas[n].lhs > 0); |
| 664 | 664 | end_offset += 2; // for the comma/semicolon + rbrace/rparen |
| 665 | 665 | n = tree.extra_data[datas[n].rhs - 1]; // last member |
| 666 | 666 | }, |
| 667 | .CallOne, | |
| 668 | .AsyncCallOne, | |
| 669 | .ArrayAccess, | |
| 667 | .call_one, | |
| 668 | .async_call_one, | |
| 669 | .array_access, | |
| 670 | 670 | => { |
| 671 | 671 | end_offset += 1; // for the rparen/rbracket |
| 672 | 672 | if (datas[n].rhs == 0) { |
| ... | ... | @@ -674,12 +674,12 @@ pub const Tree = struct { |
| 674 | 674 | } |
| 675 | 675 | n = datas[n].rhs; |
| 676 | 676 | }, |
| 677 | .ArrayInitDotTwo, | |
| 678 | .BlockTwo, | |
| 679 | .BuiltinCallTwo, | |
| 680 | .StructInitDotTwo, | |
| 681 | .ContainerDeclTwo, | |
| 682 | .TaggedUnionTwo, | |
| 677 | .array_init_dot_two, | |
| 678 | .block_two, | |
| 679 | .builtin_call_two, | |
| 680 | .struct_init_dot_two, | |
| 681 | .container_decl_two, | |
| 682 | .tagged_union_two, | |
| 683 | 683 | => { |
| 684 | 684 | if (datas[n].rhs != 0) { |
| 685 | 685 | end_offset += 1; // for the rparen/rbrace |
| ... | ... | @@ -689,25 +689,25 @@ pub const Tree = struct { |
| 689 | 689 | n = datas[n].lhs; |
| 690 | 690 | } else { |
| 691 | 691 | switch (tags[n]) { |
| 692 | .ArrayInitDotTwo, | |
| 693 | .BlockTwo, | |
| 694 | .StructInitDotTwo, | |
| 692 | .array_init_dot_two, | |
| 693 | .block_two, | |
| 694 | .struct_init_dot_two, | |
| 695 | 695 | => end_offset += 1, // rbrace |
| 696 | .BuiltinCallTwo, | |
| 697 | .ContainerDeclTwo, | |
| 696 | .builtin_call_two, | |
| 697 | .container_decl_two, | |
| 698 | 698 | => end_offset += 2, // lparen/lbrace + rparen/rbrace |
| 699 | .TaggedUnionTwo => end_offset += 5, // (enum) {} | |
| 699 | .tagged_union_two => end_offset += 5, // (enum) {} | |
| 700 | 700 | else => unreachable, |
| 701 | 701 | } |
| 702 | 702 | return main_tokens[n] + end_offset; |
| 703 | 703 | } |
| 704 | 704 | }, |
| 705 | .ArrayInitDotTwoComma, | |
| 706 | .BuiltinCallTwoComma, | |
| 707 | .BlockTwoSemicolon, | |
| 708 | .StructInitDotTwoComma, | |
| 709 | .ContainerDeclTwoComma, | |
| 710 | .TaggedUnionTwoComma, | |
| 705 | .array_init_dot_two_comma, | |
| 706 | .builtin_call_two_comma, | |
| 707 | .block_two_semicolon, | |
| 708 | .struct_init_dot_two_comma, | |
| 709 | .container_decl_two_comma, | |
| 710 | .tagged_union_two_comma, | |
| 711 | 711 | => { |
| 712 | 712 | end_offset += 2; // for the comma/semicolon + rbrace/rparen |
| 713 | 713 | if (datas[n].rhs != 0) { |
| ... | ... | @@ -718,7 +718,7 @@ pub const Tree = struct { |
| 718 | 718 | unreachable; |
| 719 | 719 | } |
| 720 | 720 | }, |
| 721 | .SimpleVarDecl => { | |
| 721 | .simple_var_decl => { | |
| 722 | 722 | if (datas[n].rhs != 0) { |
| 723 | 723 | n = datas[n].rhs; |
| 724 | 724 | } else if (datas[n].lhs != 0) { |
| ... | ... | @@ -728,7 +728,7 @@ pub const Tree = struct { |
| 728 | 728 | return main_tokens[n] + end_offset; |
| 729 | 729 | } |
| 730 | 730 | }, |
| 731 | .AlignedVarDecl => { | |
| 731 | .aligned_var_decl => { | |
| 732 | 732 | if (datas[n].rhs != 0) { |
| 733 | 733 | n = datas[n].rhs; |
| 734 | 734 | } else if (datas[n].lhs != 0) { |
| ... | ... | @@ -739,7 +739,7 @@ pub const Tree = struct { |
| 739 | 739 | return main_tokens[n] + end_offset; |
| 740 | 740 | } |
| 741 | 741 | }, |
| 742 | .GlobalVarDecl => { | |
| 742 | .global_var_decl => { | |
| 743 | 743 | if (datas[n].rhs != 0) { |
| 744 | 744 | n = datas[n].rhs; |
| 745 | 745 | } else { |
| ... | ... | @@ -758,7 +758,7 @@ pub const Tree = struct { |
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | }, |
| 761 | .LocalVarDecl => { | |
| 761 | .local_var_decl => { | |
| 762 | 762 | if (datas[n].rhs != 0) { |
| 763 | 763 | n = datas[n].rhs; |
| 764 | 764 | } else { |
| ... | ... | @@ -774,7 +774,7 @@ pub const Tree = struct { |
| 774 | 774 | } |
| 775 | 775 | } |
| 776 | 776 | }, |
| 777 | .ContainerFieldInit => { | |
| 777 | .container_field_init => { | |
| 778 | 778 | if (datas[n].rhs != 0) { |
| 779 | 779 | n = datas[n].rhs; |
| 780 | 780 | } else if (datas[n].lhs != 0) { |
| ... | ... | @@ -783,7 +783,7 @@ pub const Tree = struct { |
| 783 | 783 | return main_tokens[n] + end_offset; |
| 784 | 784 | } |
| 785 | 785 | }, |
| 786 | .ContainerFieldAlign => { | |
| 786 | .container_field_align => { | |
| 787 | 787 | if (datas[n].rhs != 0) { |
| 788 | 788 | end_offset += 1; // for the rparen |
| 789 | 789 | n = datas[n].rhs; |
| ... | ... | @@ -793,7 +793,7 @@ pub const Tree = struct { |
| 793 | 793 | return main_tokens[n] + end_offset; |
| 794 | 794 | } |
| 795 | 795 | }, |
| 796 | .ContainerField => { | |
| 796 | .container_field => { | |
| 797 | 797 | const extra = tree.extraData(datas[n].rhs, Node.ContainerField); |
| 798 | 798 | if (extra.value_expr != 0) { |
| 799 | 799 | n = extra.value_expr; |
| ... | ... | @@ -807,8 +807,8 @@ pub const Tree = struct { |
| 807 | 807 | } |
| 808 | 808 | }, |
| 809 | 809 | |
| 810 | .ArrayInitOne, | |
| 811 | .StructInitOne, | |
| 810 | .array_init_one, | |
| 811 | .struct_init_one, | |
| 812 | 812 | => { |
| 813 | 813 | end_offset += 1; // rbrace |
| 814 | 814 | if (datas[n].rhs == 0) { |
| ... | ... | @@ -817,37 +817,37 @@ pub const Tree = struct { |
| 817 | 817 | n = datas[n].rhs; |
| 818 | 818 | } |
| 819 | 819 | }, |
| 820 | .SliceOpen, | |
| 821 | .CallOneComma, | |
| 822 | .AsyncCallOneComma, | |
| 823 | .ArrayInitOneComma, | |
| 824 | .StructInitOneComma, | |
| 820 | .slice_open, | |
| 821 | .call_one_comma, | |
| 822 | .async_call_one_comma, | |
| 823 | .array_init_one_comma, | |
| 824 | .struct_init_one_comma, | |
| 825 | 825 | => { |
| 826 | 826 | end_offset += 2; // ellipsis2 + rbracket, or comma + rparen |
| 827 | 827 | n = datas[n].rhs; |
| 828 | 828 | assert(n != 0); |
| 829 | 829 | }, |
| 830 | .Slice => { | |
| 830 | .slice => { | |
| 831 | 831 | const extra = tree.extraData(datas[n].rhs, Node.Slice); |
| 832 | 832 | assert(extra.end != 0); // should have used SliceOpen |
| 833 | 833 | end_offset += 1; // rbracket |
| 834 | 834 | n = extra.end; |
| 835 | 835 | }, |
| 836 | .SliceSentinel => { | |
| 836 | .slice_sentinel => { | |
| 837 | 837 | const extra = tree.extraData(datas[n].rhs, Node.SliceSentinel); |
| 838 | 838 | assert(extra.sentinel != 0); // should have used Slice |
| 839 | 839 | end_offset += 1; // rbracket |
| 840 | 840 | n = extra.sentinel; |
| 841 | 841 | }, |
| 842 | 842 | |
| 843 | .Continue => { | |
| 843 | .@"continue" => { | |
| 844 | 844 | if (datas[n].lhs != 0) { |
| 845 | 845 | return datas[n].lhs + end_offset; |
| 846 | 846 | } else { |
| 847 | 847 | return main_tokens[n] + end_offset; |
| 848 | 848 | } |
| 849 | 849 | }, |
| 850 | .Break => { | |
| 850 | .@"break" => { | |
| 851 | 851 | if (datas[n].rhs != 0) { |
| 852 | 852 | n = datas[n].rhs; |
| 853 | 853 | } else if (datas[n].lhs != 0) { |
| ... | ... | @@ -856,14 +856,14 @@ pub const Tree = struct { |
| 856 | 856 | return main_tokens[n] + end_offset; |
| 857 | 857 | } |
| 858 | 858 | }, |
| 859 | .FnDecl => { | |
| 859 | .fn_decl => { | |
| 860 | 860 | if (datas[n].rhs != 0) { |
| 861 | 861 | n = datas[n].rhs; |
| 862 | 862 | } else { |
| 863 | 863 | n = datas[n].lhs; |
| 864 | 864 | } |
| 865 | 865 | }, |
| 866 | .FnProtoOne => { | |
| 866 | .fn_proto_one => { | |
| 867 | 867 | const extra = tree.extraData(datas[n].lhs, Node.FnProtoOne); |
| 868 | 868 | // linksection, callconv, align can appear in any order, so we |
| 869 | 869 | // find the last one here. |
| ... | ... | @@ -897,7 +897,7 @@ pub const Tree = struct { |
| 897 | 897 | n = max_node; |
| 898 | 898 | end_offset += max_offset; |
| 899 | 899 | }, |
| 900 | .FnProto => { | |
| 900 | .fn_proto => { | |
| 901 | 901 | const extra = tree.extraData(datas[n].lhs, Node.FnProto); |
| 902 | 902 | // linksection, callconv, align can appear in any order, so we |
| 903 | 903 | // find the last one here. |
| ... | ... | @@ -931,29 +931,29 @@ pub const Tree = struct { |
| 931 | 931 | n = max_node; |
| 932 | 932 | end_offset += max_offset; |
| 933 | 933 | }, |
| 934 | .WhileCont => { | |
| 934 | .while_cont => { | |
| 935 | 935 | const extra = tree.extraData(datas[n].rhs, Node.WhileCont); |
| 936 | 936 | assert(extra.then_expr != 0); |
| 937 | 937 | n = extra.then_expr; |
| 938 | 938 | }, |
| 939 | .While => { | |
| 939 | .@"while" => { | |
| 940 | 940 | const extra = tree.extraData(datas[n].rhs, Node.While); |
| 941 | 941 | assert(extra.else_expr != 0); |
| 942 | 942 | n = extra.else_expr; |
| 943 | 943 | }, |
| 944 | .If, .For => { | |
| 944 | .@"if", .@"for" => { | |
| 945 | 945 | const extra = tree.extraData(datas[n].rhs, Node.If); |
| 946 | 946 | assert(extra.else_expr != 0); |
| 947 | 947 | n = extra.else_expr; |
| 948 | 948 | }, |
| 949 | .Suspend => { | |
| 949 | .@"suspend" => { | |
| 950 | 950 | if (datas[n].lhs != 0) { |
| 951 | 951 | n = datas[n].lhs; |
| 952 | 952 | } else { |
| 953 | 953 | return main_tokens[n] + end_offset; |
| 954 | 954 | } |
| 955 | 955 | }, |
| 956 | .ArrayTypeSentinel => { | |
| 956 | .array_type_sentinel => { | |
| 957 | 957 | const extra = tree.extraData(datas[n].rhs, Node.ArrayTypeSentinel); |
| 958 | 958 | n = extra.elem_type; |
| 959 | 959 | }, |
| ... | ... | @@ -967,7 +967,7 @@ pub const Tree = struct { |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 970 | assert(tree.nodes.items(.tag)[node] == .GlobalVarDecl); | |
| 970 | assert(tree.nodes.items(.tag)[node] == .global_var_decl); | |
| 971 | 971 | const data = tree.nodes.items(.data)[node]; |
| 972 | 972 | const extra = tree.extraData(data.lhs, Node.GlobalVarDecl); |
| 973 | 973 | return tree.fullVarDecl(.{ |
| ... | ... | @@ -980,7 +980,7 @@ pub const Tree = struct { |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 983 | assert(tree.nodes.items(.tag)[node] == .LocalVarDecl); | |
| 983 | assert(tree.nodes.items(.tag)[node] == .local_var_decl); | |
| 984 | 984 | const data = tree.nodes.items(.data)[node]; |
| 985 | 985 | const extra = tree.extraData(data.lhs, Node.LocalVarDecl); |
| 986 | 986 | return tree.fullVarDecl(.{ |
| ... | ... | @@ -993,7 +993,7 @@ pub const Tree = struct { |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 996 | assert(tree.nodes.items(.tag)[node] == .SimpleVarDecl); | |
| 996 | assert(tree.nodes.items(.tag)[node] == .simple_var_decl); | |
| 997 | 997 | const data = tree.nodes.items(.data)[node]; |
| 998 | 998 | return tree.fullVarDecl(.{ |
| 999 | 999 | .type_node = data.lhs, |
| ... | ... | @@ -1005,7 +1005,7 @@ pub const Tree = struct { |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | 1007 | pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl { |
| 1008 | assert(tree.nodes.items(.tag)[node] == .AlignedVarDecl); | |
| 1008 | assert(tree.nodes.items(.tag)[node] == .aligned_var_decl); | |
| 1009 | 1009 | const data = tree.nodes.items(.data)[node]; |
| 1010 | 1010 | return tree.fullVarDecl(.{ |
| 1011 | 1011 | .type_node = 0, |
| ... | ... | @@ -1017,7 +1017,7 @@ pub const Tree = struct { |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | 1019 | pub fn ifSimple(tree: Tree, node: Node.Index) full.If { |
| 1020 | assert(tree.nodes.items(.tag)[node] == .IfSimple); | |
| 1020 | assert(tree.nodes.items(.tag)[node] == .if_simple); | |
| 1021 | 1021 | const data = tree.nodes.items(.data)[node]; |
| 1022 | 1022 | return tree.fullIf(.{ |
| 1023 | 1023 | .cond_expr = data.lhs, |
| ... | ... | @@ -1028,7 +1028,7 @@ pub const Tree = struct { |
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | 1030 | pub fn ifFull(tree: Tree, node: Node.Index) full.If { |
| 1031 | assert(tree.nodes.items(.tag)[node] == .If); | |
| 1031 | assert(tree.nodes.items(.tag)[node] == .@"if"); | |
| 1032 | 1032 | const data = tree.nodes.items(.data)[node]; |
| 1033 | 1033 | const extra = tree.extraData(data.rhs, Node.If); |
| 1034 | 1034 | return tree.fullIf(.{ |
| ... | ... | @@ -1040,7 +1040,7 @@ pub const Tree = struct { |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField { |
| 1043 | assert(tree.nodes.items(.tag)[node] == .ContainerField); | |
| 1043 | assert(tree.nodes.items(.tag)[node] == .container_field); | |
| 1044 | 1044 | const data = tree.nodes.items(.data)[node]; |
| 1045 | 1045 | const extra = tree.extraData(data.rhs, Node.ContainerField); |
| 1046 | 1046 | return tree.fullContainerField(.{ |
| ... | ... | @@ -1052,7 +1052,7 @@ pub const Tree = struct { |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField { |
| 1055 | assert(tree.nodes.items(.tag)[node] == .ContainerFieldInit); | |
| 1055 | assert(tree.nodes.items(.tag)[node] == .container_field_init); | |
| 1056 | 1056 | const data = tree.nodes.items(.data)[node]; |
| 1057 | 1057 | return tree.fullContainerField(.{ |
| 1058 | 1058 | .name_token = tree.nodes.items(.main_token)[node], |
| ... | ... | @@ -1063,7 +1063,7 @@ pub const Tree = struct { |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | 1065 | pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField { |
| 1066 | assert(tree.nodes.items(.tag)[node] == .ContainerFieldAlign); | |
| 1066 | assert(tree.nodes.items(.tag)[node] == .container_field_align); | |
| 1067 | 1067 | const data = tree.nodes.items(.data)[node]; |
| 1068 | 1068 | return tree.fullContainerField(.{ |
| 1069 | 1069 | .name_token = tree.nodes.items(.main_token)[node], |
| ... | ... | @@ -1074,7 +1074,7 @@ pub const Tree = struct { |
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { |
| 1077 | assert(tree.nodes.items(.tag)[node] == .FnProtoSimple); | |
| 1077 | assert(tree.nodes.items(.tag)[node] == .fn_proto_simple); | |
| 1078 | 1078 | const data = tree.nodes.items(.data)[node]; |
| 1079 | 1079 | buffer[0] = data.lhs; |
| 1080 | 1080 | const params = if (data.lhs == 0) buffer[0..0] else buffer[0..1]; |
| ... | ... | @@ -1089,7 +1089,7 @@ pub const Tree = struct { |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto { |
| 1092 | assert(tree.nodes.items(.tag)[node] == .FnProtoMulti); | |
| 1092 | assert(tree.nodes.items(.tag)[node] == .fn_proto_multi); | |
| 1093 | 1093 | const data = tree.nodes.items(.data)[node]; |
| 1094 | 1094 | const params_range = tree.extraData(data.lhs, Node.SubRange); |
| 1095 | 1095 | const params = tree.extra_data[params_range.start..params_range.end]; |
| ... | ... | @@ -1104,7 +1104,7 @@ pub const Tree = struct { |
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto { |
| 1107 | assert(tree.nodes.items(.tag)[node] == .FnProtoOne); | |
| 1107 | assert(tree.nodes.items(.tag)[node] == .fn_proto_one); | |
| 1108 | 1108 | const data = tree.nodes.items(.data)[node]; |
| 1109 | 1109 | const extra = tree.extraData(data.lhs, Node.FnProtoOne); |
| 1110 | 1110 | buffer[0] = extra.param; |
| ... | ... | @@ -1120,7 +1120,7 @@ pub const Tree = struct { |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto { |
| 1123 | assert(tree.nodes.items(.tag)[node] == .FnProto); | |
| 1123 | assert(tree.nodes.items(.tag)[node] == .fn_proto); | |
| 1124 | 1124 | const data = tree.nodes.items(.data)[node]; |
| 1125 | 1125 | const extra = tree.extraData(data.lhs, Node.FnProto); |
| 1126 | 1126 | const params = tree.extra_data[extra.params_start..extra.params_end]; |
| ... | ... | @@ -1135,8 +1135,8 @@ pub const Tree = struct { |
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | 1137 | pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit { |
| 1138 | assert(tree.nodes.items(.tag)[node] == .StructInitOne or | |
| 1139 | tree.nodes.items(.tag)[node] == .StructInitOneComma); | |
| 1138 | assert(tree.nodes.items(.tag)[node] == .struct_init_one or | |
| 1139 | tree.nodes.items(.tag)[node] == .struct_init_one_comma); | |
| 1140 | 1140 | const data = tree.nodes.items(.data)[node]; |
| 1141 | 1141 | buffer[0] = data.rhs; |
| 1142 | 1142 | const fields = if (data.rhs == 0) buffer[0..0] else buffer[0..1]; |
| ... | ... | @@ -1148,8 +1148,8 @@ pub const Tree = struct { |
| 1148 | 1148 | } |
| 1149 | 1149 | |
| 1150 | 1150 | pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit { |
| 1151 | assert(tree.nodes.items(.tag)[node] == .StructInitDotTwo or | |
| 1152 | tree.nodes.items(.tag)[node] == .StructInitDotTwoComma); | |
| 1151 | assert(tree.nodes.items(.tag)[node] == .struct_init_dot_two or | |
| 1152 | tree.nodes.items(.tag)[node] == .struct_init_dot_two_comma); | |
| 1153 | 1153 | const data = tree.nodes.items(.data)[node]; |
| 1154 | 1154 | buffer.* = .{ data.lhs, data.rhs }; |
| 1155 | 1155 | const fields = if (data.rhs != 0) |
| ... | ... | @@ -1166,8 +1166,8 @@ pub const Tree = struct { |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit { |
| 1169 | assert(tree.nodes.items(.tag)[node] == .StructInitDot or | |
| 1170 | tree.nodes.items(.tag)[node] == .StructInitDotComma); | |
| 1169 | assert(tree.nodes.items(.tag)[node] == .struct_init_dot or | |
| 1170 | tree.nodes.items(.tag)[node] == .struct_init_dot_comma); | |
| 1171 | 1171 | const data = tree.nodes.items(.data)[node]; |
| 1172 | 1172 | return tree.fullStructInit(.{ |
| 1173 | 1173 | .lbrace = tree.nodes.items(.main_token)[node], |
| ... | ... | @@ -1177,8 +1177,8 @@ pub const Tree = struct { |
| 1177 | 1177 | } |
| 1178 | 1178 | |
| 1179 | 1179 | pub fn structInit(tree: Tree, node: Node.Index) full.StructInit { |
| 1180 | assert(tree.nodes.items(.tag)[node] == .StructInit or | |
| 1181 | tree.nodes.items(.tag)[node] == .StructInitComma); | |
| 1180 | assert(tree.nodes.items(.tag)[node] == .struct_init or | |
| 1181 | tree.nodes.items(.tag)[node] == .struct_init_comma); | |
| 1182 | 1182 | const data = tree.nodes.items(.data)[node]; |
| 1183 | 1183 | const fields_range = tree.extraData(data.rhs, Node.SubRange); |
| 1184 | 1184 | return tree.fullStructInit(.{ |
| ... | ... | @@ -1189,8 +1189,8 @@ pub const Tree = struct { |
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit { |
| 1192 | assert(tree.nodes.items(.tag)[node] == .ArrayInitOne or | |
| 1193 | tree.nodes.items(.tag)[node] == .ArrayInitOneComma); | |
| 1192 | assert(tree.nodes.items(.tag)[node] == .array_init_one or | |
| 1193 | tree.nodes.items(.tag)[node] == .array_init_one_comma); | |
| 1194 | 1194 | const data = tree.nodes.items(.data)[node]; |
| 1195 | 1195 | buffer[0] = data.rhs; |
| 1196 | 1196 | const elements = if (data.rhs == 0) buffer[0..0] else buffer[0..1]; |
| ... | ... | @@ -1204,8 +1204,8 @@ pub const Tree = struct { |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit { |
| 1207 | assert(tree.nodes.items(.tag)[node] == .ArrayInitDotTwo or | |
| 1208 | tree.nodes.items(.tag)[node] == .ArrayInitDotTwoComma); | |
| 1207 | assert(tree.nodes.items(.tag)[node] == .array_init_dot_two or | |
| 1208 | tree.nodes.items(.tag)[node] == .array_init_dot_two_comma); | |
| 1209 | 1209 | const data = tree.nodes.items(.data)[node]; |
| 1210 | 1210 | buffer.* = .{ data.lhs, data.rhs }; |
| 1211 | 1211 | const elements = if (data.rhs != 0) |
| ... | ... | @@ -1224,8 +1224,8 @@ pub const Tree = struct { |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | 1226 | pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit { |
| 1227 | assert(tree.nodes.items(.tag)[node] == .ArrayInitDot or | |
| 1228 | tree.nodes.items(.tag)[node] == .ArrayInitDotComma); | |
| 1227 | assert(tree.nodes.items(.tag)[node] == .array_init_dot or | |
| 1228 | tree.nodes.items(.tag)[node] == .array_init_dot_comma); | |
| 1229 | 1229 | const data = tree.nodes.items(.data)[node]; |
| 1230 | 1230 | return .{ |
| 1231 | 1231 | .ast = .{ |
| ... | ... | @@ -1237,8 +1237,8 @@ pub const Tree = struct { |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit { |
| 1240 | assert(tree.nodes.items(.tag)[node] == .ArrayInit or | |
| 1241 | tree.nodes.items(.tag)[node] == .ArrayInitComma); | |
| 1240 | assert(tree.nodes.items(.tag)[node] == .array_init or | |
| 1241 | tree.nodes.items(.tag)[node] == .array_init_comma); | |
| 1242 | 1242 | const data = tree.nodes.items(.data)[node]; |
| 1243 | 1243 | const elem_range = tree.extraData(data.rhs, Node.SubRange); |
| 1244 | 1244 | return .{ |
| ... | ... | @@ -1251,7 +1251,7 @@ pub const Tree = struct { |
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | 1253 | pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType { |
| 1254 | assert(tree.nodes.items(.tag)[node] == .ArrayType); | |
| 1254 | assert(tree.nodes.items(.tag)[node] == .array_type); | |
| 1255 | 1255 | const data = tree.nodes.items(.data)[node]; |
| 1256 | 1256 | return .{ |
| 1257 | 1257 | .ast = .{ |
| ... | ... | @@ -1264,7 +1264,7 @@ pub const Tree = struct { |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType { |
| 1267 | assert(tree.nodes.items(.tag)[node] == .ArrayTypeSentinel); | |
| 1267 | assert(tree.nodes.items(.tag)[node] == .array_type_sentinel); | |
| 1268 | 1268 | const data = tree.nodes.items(.data)[node]; |
| 1269 | 1269 | const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel); |
| 1270 | 1270 | return .{ |
| ... | ... | @@ -1278,7 +1278,7 @@ pub const Tree = struct { |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType { |
| 1281 | assert(tree.nodes.items(.tag)[node] == .PtrTypeAligned); | |
| 1281 | assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned); | |
| 1282 | 1282 | const data = tree.nodes.items(.data)[node]; |
| 1283 | 1283 | return tree.fullPtrType(.{ |
| 1284 | 1284 | .main_token = tree.nodes.items(.main_token)[node], |
| ... | ... | @@ -1291,7 +1291,7 @@ pub const Tree = struct { |
| 1291 | 1291 | } |
| 1292 | 1292 | |
| 1293 | 1293 | pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType { |
| 1294 | assert(tree.nodes.items(.tag)[node] == .PtrTypeSentinel); | |
| 1294 | assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel); | |
| 1295 | 1295 | const data = tree.nodes.items(.data)[node]; |
| 1296 | 1296 | return tree.fullPtrType(.{ |
| 1297 | 1297 | .main_token = tree.nodes.items(.main_token)[node], |
| ... | ... | @@ -1304,7 +1304,7 @@ pub const Tree = struct { |
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType { |
| 1307 | assert(tree.nodes.items(.tag)[node] == .PtrType); | |
| 1307 | assert(tree.nodes.items(.tag)[node] == .ptr_type); | |
| 1308 | 1308 | const data = tree.nodes.items(.data)[node]; |
| 1309 | 1309 | const extra = tree.extraData(data.lhs, Node.PtrType); |
| 1310 | 1310 | return tree.fullPtrType(.{ |
| ... | ... | @@ -1318,7 +1318,7 @@ pub const Tree = struct { |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | 1320 | pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType { |
| 1321 | assert(tree.nodes.items(.tag)[node] == .PtrTypeBitRange); | |
| 1321 | assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range); | |
| 1322 | 1322 | const data = tree.nodes.items(.data)[node]; |
| 1323 | 1323 | const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange); |
| 1324 | 1324 | return tree.fullPtrType(.{ |
| ... | ... | @@ -1332,7 +1332,7 @@ pub const Tree = struct { |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice { |
| 1335 | assert(tree.nodes.items(.tag)[node] == .SliceOpen); | |
| 1335 | assert(tree.nodes.items(.tag)[node] == .slice_open); | |
| 1336 | 1336 | const data = tree.nodes.items(.data)[node]; |
| 1337 | 1337 | return .{ |
| 1338 | 1338 | .ast = .{ |
| ... | ... | @@ -1346,7 +1346,7 @@ pub const Tree = struct { |
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | pub fn slice(tree: Tree, node: Node.Index) full.Slice { |
| 1349 | assert(tree.nodes.items(.tag)[node] == .Slice); | |
| 1349 | assert(tree.nodes.items(.tag)[node] == .slice); | |
| 1350 | 1350 | const data = tree.nodes.items(.data)[node]; |
| 1351 | 1351 | const extra = tree.extraData(data.rhs, Node.Slice); |
| 1352 | 1352 | return .{ |
| ... | ... | @@ -1361,7 +1361,7 @@ pub const Tree = struct { |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | 1363 | pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice { |
| 1364 | assert(tree.nodes.items(.tag)[node] == .SliceSentinel); | |
| 1364 | assert(tree.nodes.items(.tag)[node] == .slice_sentinel); | |
| 1365 | 1365 | const data = tree.nodes.items(.data)[node]; |
| 1366 | 1366 | const extra = tree.extraData(data.rhs, Node.SliceSentinel); |
| 1367 | 1367 | return .{ |
| ... | ... | @@ -1376,8 +1376,8 @@ pub const Tree = struct { |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { |
| 1379 | assert(tree.nodes.items(.tag)[node] == .ContainerDeclTwo or | |
| 1380 | tree.nodes.items(.tag)[node] == .ContainerDeclTwoComma); | |
| 1379 | assert(tree.nodes.items(.tag)[node] == .container_decl_two or | |
| 1380 | tree.nodes.items(.tag)[node] == .container_decl_two_comma); | |
| 1381 | 1381 | const data = tree.nodes.items(.data)[node]; |
| 1382 | 1382 | buffer.* = .{ data.lhs, data.rhs }; |
| 1383 | 1383 | const members = if (data.rhs != 0) |
| ... | ... | @@ -1395,8 +1395,8 @@ pub const Tree = struct { |
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1398 | assert(tree.nodes.items(.tag)[node] == .ContainerDecl or | |
| 1399 | tree.nodes.items(.tag)[node] == .ContainerDeclComma); | |
| 1398 | assert(tree.nodes.items(.tag)[node] == .container_decl or | |
| 1399 | tree.nodes.items(.tag)[node] == .container_decl_comma); | |
| 1400 | 1400 | const data = tree.nodes.items(.data)[node]; |
| 1401 | 1401 | return tree.fullContainerDecl(.{ |
| 1402 | 1402 | .main_token = tree.nodes.items(.main_token)[node], |
| ... | ... | @@ -1407,8 +1407,8 @@ pub const Tree = struct { |
| 1407 | 1407 | } |
| 1408 | 1408 | |
| 1409 | 1409 | pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1410 | assert(tree.nodes.items(.tag)[node] == .ContainerDeclArg or | |
| 1411 | tree.nodes.items(.tag)[node] == .ContainerDeclArgComma); | |
| 1410 | assert(tree.nodes.items(.tag)[node] == .container_decl_arg or | |
| 1411 | tree.nodes.items(.tag)[node] == .container_decl_arg_comma); | |
| 1412 | 1412 | const data = tree.nodes.items(.data)[node]; |
| 1413 | 1413 | const members_range = tree.extraData(data.rhs, Node.SubRange); |
| 1414 | 1414 | return tree.fullContainerDecl(.{ |
| ... | ... | @@ -1420,8 +1420,8 @@ pub const Tree = struct { |
| 1420 | 1420 | } |
| 1421 | 1421 | |
| 1422 | 1422 | pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl { |
| 1423 | assert(tree.nodes.items(.tag)[node] == .TaggedUnionTwo or | |
| 1424 | tree.nodes.items(.tag)[node] == .TaggedUnionTwoComma); | |
| 1423 | assert(tree.nodes.items(.tag)[node] == .tagged_union_two or | |
| 1424 | tree.nodes.items(.tag)[node] == .tagged_union_two_comma); | |
| 1425 | 1425 | const data = tree.nodes.items(.data)[node]; |
| 1426 | 1426 | buffer.* = .{ data.lhs, data.rhs }; |
| 1427 | 1427 | const members = if (data.rhs != 0) |
| ... | ... | @@ -1440,8 +1440,8 @@ pub const Tree = struct { |
| 1440 | 1440 | } |
| 1441 | 1441 | |
| 1442 | 1442 | pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1443 | assert(tree.nodes.items(.tag)[node] == .TaggedUnion or | |
| 1444 | tree.nodes.items(.tag)[node] == .TaggedUnionComma); | |
| 1443 | assert(tree.nodes.items(.tag)[node] == .tagged_union or | |
| 1444 | tree.nodes.items(.tag)[node] == .tagged_union_comma); | |
| 1445 | 1445 | const data = tree.nodes.items(.data)[node]; |
| 1446 | 1446 | const main_token = tree.nodes.items(.main_token)[node]; |
| 1447 | 1447 | return tree.fullContainerDecl(.{ |
| ... | ... | @@ -1453,8 +1453,8 @@ pub const Tree = struct { |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | 1455 | pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl { |
| 1456 | assert(tree.nodes.items(.tag)[node] == .TaggedUnionEnumTag or | |
| 1457 | tree.nodes.items(.tag)[node] == .TaggedUnionEnumTagComma); | |
| 1456 | assert(tree.nodes.items(.tag)[node] == .tagged_union_enum_tag or | |
| 1457 | tree.nodes.items(.tag)[node] == .tagged_union_enum_tag_comma); | |
| 1458 | 1458 | const data = tree.nodes.items(.data)[node]; |
| 1459 | 1459 | const members_range = tree.extraData(data.rhs, Node.SubRange); |
| 1460 | 1460 | const main_token = tree.nodes.items(.main_token)[node]; |
| ... | ... | @@ -1765,7 +1765,7 @@ pub const Tree = struct { |
| 1765 | 1765 | } |
| 1766 | 1766 | const outputs_end: usize = for (info.items) |item, i| { |
| 1767 | 1767 | switch (node_tags[item]) { |
| 1768 | .AsmOutput => continue, | |
| 1768 | .asm_output => continue, | |
| 1769 | 1769 | else => break i, |
| 1770 | 1770 | } |
| 1771 | 1771 | } else info.items.len; |
| ... | ... | @@ -2162,7 +2162,7 @@ pub const Error = union(enum) { |
| 2162 | 2162 | |
| 2163 | 2163 | pub fn render(self: ExpectedCall, tree: Tree, stream: anytype) !void { |
| 2164 | 2164 | const node_tag = tree.nodes.items(.tag)[self.node]; |
| 2165 | return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ ", found {s}", .{ | |
| 2165 | return stream.print("expected " ++ @tagName(Node.Tag.call) ++ ", found {s}", .{ | |
| 2166 | 2166 | @tagName(node_tag), |
| 2167 | 2167 | }); |
| 2168 | 2168 | } |
| ... | ... | @@ -2173,8 +2173,8 @@ pub const Error = union(enum) { |
| 2173 | 2173 | |
| 2174 | 2174 | pub fn render(self: ExpectedCallOrFnProto, tree: Tree, stream: anytype) !void { |
| 2175 | 2175 | const node_tag = tree.nodes.items(.tag)[self.node]; |
| 2176 | return stream.print("expected " ++ @tagName(Node.Tag.Call) ++ " or " ++ | |
| 2177 | @tagName(Node.Tag.FnProto) ++ ", found {s}", .{@tagName(node_tag)}); | |
| 2176 | return stream.print("expected " ++ @tagName(Node.Tag.call) ++ " or " ++ | |
| 2177 | @tagName(Node.Tag.fn_proto) ++ ", found {s}", .{@tagName(node_tag)}); | |
| 2178 | 2178 | } |
| 2179 | 2179 | }; |
| 2180 | 2180 | |
| ... | ... | @@ -2305,433 +2305,433 @@ pub const Node = struct { |
| 2305 | 2305 | /// Tree.lastToken() |
| 2306 | 2306 | pub const Tag = enum { |
| 2307 | 2307 | /// sub_list[lhs...rhs] |
| 2308 | Root, | |
| 2308 | root, | |
| 2309 | 2309 | /// `usingnamespace lhs;`. rhs unused. main_token is `usingnamespace`. |
| 2310 | UsingNamespace, | |
| 2310 | @"usingnamespace", | |
| 2311 | 2311 | /// lhs is test name token (must be string literal), if any. |
| 2312 | 2312 | /// rhs is the body node. |
| 2313 | TestDecl, | |
| 2313 | test_decl, | |
| 2314 | 2314 | /// lhs is the index into extra_data. |
| 2315 | 2315 | /// rhs is the initialization expression, if any. |
| 2316 | 2316 | /// main_token is `var` or `const`. |
| 2317 | GlobalVarDecl, | |
| 2317 | global_var_decl, | |
| 2318 | 2318 | /// `var a: x align(y) = rhs` |
| 2319 | 2319 | /// lhs is the index into extra_data. |
| 2320 | 2320 | /// main_token is `var` or `const`. |
| 2321 | LocalVarDecl, | |
| 2321 | local_var_decl, | |
| 2322 | 2322 | /// `var a: lhs = rhs`. lhs and rhs may be unused. |
| 2323 | 2323 | /// Can be local or global. |
| 2324 | 2324 | /// main_token is `var` or `const`. |
| 2325 | SimpleVarDecl, | |
| 2325 | simple_var_decl, | |
| 2326 | 2326 | /// `var a align(lhs) = rhs`. lhs and rhs may be unused. |
| 2327 | 2327 | /// Can be local or global. |
| 2328 | 2328 | /// main_token is `var` or `const`. |
| 2329 | AlignedVarDecl, | |
| 2329 | aligned_var_decl, | |
| 2330 | 2330 | /// lhs is the identifier token payload if any, |
| 2331 | 2331 | /// rhs is the deferred expression. |
| 2332 | ErrDefer, | |
| 2332 | @"errdefer", | |
| 2333 | 2333 | /// lhs is unused. |
| 2334 | 2334 | /// rhs is the deferred expression. |
| 2335 | Defer, | |
| 2335 | @"defer", | |
| 2336 | 2336 | /// lhs catch rhs |
| 2337 | 2337 | /// lhs catch |err| rhs |
| 2338 | 2338 | /// main_token is the catch |
| 2339 | 2339 | /// payload is determined by looking at the prev tokens before rhs. |
| 2340 | Catch, | |
| 2340 | @"catch", | |
| 2341 | 2341 | /// `lhs.a`. main_token is the dot. rhs is the identifier token index. |
| 2342 | FieldAccess, | |
| 2342 | field_access, | |
| 2343 | 2343 | /// `lhs.?`. main_token is the dot. rhs is the `?` token index. |
| 2344 | UnwrapOptional, | |
| 2344 | unwrap_optional, | |
| 2345 | 2345 | /// `lhs == rhs`. main_token is op. |
| 2346 | EqualEqual, | |
| 2346 | equal_equal, | |
| 2347 | 2347 | /// `lhs != rhs`. main_token is op. |
| 2348 | BangEqual, | |
| 2348 | bang_equal, | |
| 2349 | 2349 | /// `lhs < rhs`. main_token is op. |
| 2350 | LessThan, | |
| 2350 | less_than, | |
| 2351 | 2351 | /// `lhs > rhs`. main_token is op. |
| 2352 | GreaterThan, | |
| 2352 | greater_than, | |
| 2353 | 2353 | /// `lhs <= rhs`. main_token is op. |
| 2354 | LessOrEqual, | |
| 2354 | less_or_equal, | |
| 2355 | 2355 | /// `lhs >= rhs`. main_token is op. |
| 2356 | GreaterOrEqual, | |
| 2356 | greater_or_equal, | |
| 2357 | 2357 | /// `lhs *= rhs`. main_token is op. |
| 2358 | AssignMul, | |
| 2358 | assign_mul, | |
| 2359 | 2359 | /// `lhs /= rhs`. main_token is op. |
| 2360 | AssignDiv, | |
| 2360 | assign_div, | |
| 2361 | 2361 | /// `lhs *= rhs`. main_token is op. |
| 2362 | AssignMod, | |
| 2362 | assign_mod, | |
| 2363 | 2363 | /// `lhs += rhs`. main_token is op. |
| 2364 | AssignAdd, | |
| 2364 | assign_add, | |
| 2365 | 2365 | /// `lhs -= rhs`. main_token is op. |
| 2366 | AssignSub, | |
| 2366 | assign_sub, | |
| 2367 | 2367 | /// `lhs <<= rhs`. main_token is op. |
| 2368 | AssignBitShiftLeft, | |
| 2368 | assign_bit_shift_left, | |
| 2369 | 2369 | /// `lhs >>= rhs`. main_token is op. |
| 2370 | AssignBitShiftRight, | |
| 2370 | assign_bit_shift_right, | |
| 2371 | 2371 | /// `lhs &= rhs`. main_token is op. |
| 2372 | AssignBitAnd, | |
| 2372 | assign_bit_and, | |
| 2373 | 2373 | /// `lhs ^= rhs`. main_token is op. |
| 2374 | AssignBitXor, | |
| 2374 | assign_bit_xor, | |
| 2375 | 2375 | /// `lhs |= rhs`. main_token is op. |
| 2376 | AssignBitOr, | |
| 2376 | assign_bit_or, | |
| 2377 | 2377 | /// `lhs *%= rhs`. main_token is op. |
| 2378 | AssignMulWrap, | |
| 2378 | assign_mul_wrap, | |
| 2379 | 2379 | /// `lhs +%= rhs`. main_token is op. |
| 2380 | AssignAddWrap, | |
| 2380 | assign_add_wrap, | |
| 2381 | 2381 | /// `lhs -%= rhs`. main_token is op. |
| 2382 | AssignSubWrap, | |
| 2382 | assign_sub_wrap, | |
| 2383 | 2383 | /// `lhs = rhs`. main_token is op. |
| 2384 | Assign, | |
| 2384 | assign, | |
| 2385 | 2385 | /// `lhs || rhs`. main_token is the `||`. |
| 2386 | MergeErrorSets, | |
| 2386 | merge_error_sets, | |
| 2387 | 2387 | /// `lhs * rhs`. main_token is the `*`. |
| 2388 | Mul, | |
| 2388 | mul, | |
| 2389 | 2389 | /// `lhs / rhs`. main_token is the `/`. |
| 2390 | Div, | |
| 2390 | div, | |
| 2391 | 2391 | /// `lhs % rhs`. main_token is the `%`. |
| 2392 | Mod, | |
| 2392 | mod, | |
| 2393 | 2393 | /// `lhs ** rhs`. main_token is the `**`. |
| 2394 | ArrayMult, | |
| 2394 | array_mult, | |
| 2395 | 2395 | /// `lhs *% rhs`. main_token is the `*%`. |
| 2396 | MulWrap, | |
| 2396 | mul_wrap, | |
| 2397 | 2397 | /// `lhs + rhs`. main_token is the `+`. |
| 2398 | Add, | |
| 2398 | add, | |
| 2399 | 2399 | /// `lhs - rhs`. main_token is the `-`. |
| 2400 | Sub, | |
| 2400 | sub, | |
| 2401 | 2401 | /// `lhs ++ rhs`. main_token is the `++`. |
| 2402 | ArrayCat, | |
| 2402 | array_cat, | |
| 2403 | 2403 | /// `lhs +% rhs`. main_token is the `+%`. |
| 2404 | AddWrap, | |
| 2404 | add_wrap, | |
| 2405 | 2405 | /// `lhs -% rhs`. main_token is the `-%`. |
| 2406 | SubWrap, | |
| 2406 | sub_wrap, | |
| 2407 | 2407 | /// `lhs << rhs`. main_token is the `<<`. |
| 2408 | BitShiftLeft, | |
| 2408 | bit_shift_left, | |
| 2409 | 2409 | /// `lhs >> rhs`. main_token is the `>>`. |
| 2410 | BitShiftRight, | |
| 2410 | bit_shift_right, | |
| 2411 | 2411 | /// `lhs & rhs`. main_token is the `&`. |
| 2412 | BitAnd, | |
| 2412 | bit_and, | |
| 2413 | 2413 | /// `lhs ^ rhs`. main_token is the `^`. |
| 2414 | BitXor, | |
| 2414 | bit_xor, | |
| 2415 | 2415 | /// `lhs | rhs`. main_token is the `|`. |
| 2416 | BitOr, | |
| 2416 | bit_or, | |
| 2417 | 2417 | /// `lhs orelse rhs`. main_token is the `orelse`. |
| 2418 | OrElse, | |
| 2418 | @"orelse", | |
| 2419 | 2419 | /// `lhs and rhs`. main_token is the `and`. |
| 2420 | BoolAnd, | |
| 2420 | bool_and, | |
| 2421 | 2421 | /// `lhs or rhs`. main_token is the `or`. |
| 2422 | BoolOr, | |
| 2422 | bool_or, | |
| 2423 | 2423 | /// `op lhs`. rhs unused. main_token is op. |
| 2424 | BoolNot, | |
| 2424 | bool_not, | |
| 2425 | 2425 | /// `op lhs`. rhs unused. main_token is op. |
| 2426 | Negation, | |
| 2426 | negation, | |
| 2427 | 2427 | /// `op lhs`. rhs unused. main_token is op. |
| 2428 | BitNot, | |
| 2428 | bit_not, | |
| 2429 | 2429 | /// `op lhs`. rhs unused. main_token is op. |
| 2430 | NegationWrap, | |
| 2430 | negation_wrap, | |
| 2431 | 2431 | /// `op lhs`. rhs unused. main_token is op. |
| 2432 | AddressOf, | |
| 2432 | address_of, | |
| 2433 | 2433 | /// `op lhs`. rhs unused. main_token is op. |
| 2434 | Try, | |
| 2434 | @"try", | |
| 2435 | 2435 | /// `op lhs`. rhs unused. main_token is op. |
| 2436 | Await, | |
| 2436 | @"await", | |
| 2437 | 2437 | /// `?lhs`. rhs unused. main_token is the `?`. |
| 2438 | OptionalType, | |
| 2438 | optional_type, | |
| 2439 | 2439 | /// `[lhs]rhs`. lhs can be omitted to make it a slice. |
| 2440 | ArrayType, | |
| 2441 | /// `[lhs:a]b`. `ArrayTypeSentinel[rhs]`. | |
| 2442 | ArrayTypeSentinel, | |
| 2440 | array_type, | |
| 2441 | /// `[lhs:a]b`. `array_type_sentinel[rhs]`. | |
| 2442 | array_type_sentinel, | |
| 2443 | 2443 | /// `[*]align(lhs) rhs`. lhs can be omitted. |
| 2444 | 2444 | /// `*align(lhs) rhs`. lhs can be omitted. |
| 2445 | 2445 | /// `[]rhs`. |
| 2446 | 2446 | /// main_token is the asterisk if a pointer or the lbracket if a slice |
| 2447 | 2447 | /// main_token might be a ** token, which is shared with a parent/child |
| 2448 | 2448 | /// pointer type and may require special handling. |
| 2449 | PtrTypeAligned, | |
| 2449 | ptr_type_aligned, | |
| 2450 | 2450 | /// `[*:lhs]rhs`. lhs can be omitted. |
| 2451 | 2451 | /// `*rhs`. |
| 2452 | 2452 | /// `[:lhs]rhs`. |
| 2453 | 2453 | /// main_token is the asterisk if a pointer or the lbracket if a slice |
| 2454 | 2454 | /// main_token might be a ** token, which is shared with a parent/child |
| 2455 | 2455 | /// pointer type and may require special handling. |
| 2456 | PtrTypeSentinel, | |
| 2457 | /// lhs is index into PtrType. rhs is the element type expression. | |
| 2456 | ptr_type_sentinel, | |
| 2457 | /// lhs is index into ptr_type. rhs is the element type expression. | |
| 2458 | 2458 | /// main_token is the asterisk if a pointer or the lbracket if a slice |
| 2459 | 2459 | /// main_token might be a ** token, which is shared with a parent/child |
| 2460 | 2460 | /// pointer type and may require special handling. |
| 2461 | PtrType, | |
| 2462 | /// lhs is index into PtrTypeBitRange. rhs is the element type expression. | |
| 2461 | ptr_type, | |
| 2462 | /// lhs is index into ptr_type_bit_range. rhs is the element type expression. | |
| 2463 | 2463 | /// main_token is the asterisk if a pointer or the lbracket if a slice |
| 2464 | 2464 | /// main_token might be a ** token, which is shared with a parent/child |
| 2465 | 2465 | /// pointer type and may require special handling. |
| 2466 | PtrTypeBitRange, | |
| 2466 | ptr_type_bit_range, | |
| 2467 | 2467 | /// `lhs[rhs..]` |
| 2468 | 2468 | /// main_token is the lbracket. |
| 2469 | SliceOpen, | |
| 2469 | slice_open, | |
| 2470 | 2470 | /// `lhs[b..c]`. rhs is index into Slice |
| 2471 | 2471 | /// main_token is the lbracket. |
| 2472 | Slice, | |
| 2472 | slice, | |
| 2473 | 2473 | /// `lhs[b..c :d]`. rhs is index into SliceSentinel |
| 2474 | 2474 | /// main_token is the lbracket. |
| 2475 | SliceSentinel, | |
| 2475 | slice_sentinel, | |
| 2476 | 2476 | /// `lhs.*`. rhs is unused. |
| 2477 | Deref, | |
| 2477 | deref, | |
| 2478 | 2478 | /// `lhs[rhs]`. |
| 2479 | ArrayAccess, | |
| 2479 | array_access, | |
| 2480 | 2480 | /// `lhs{rhs}`. rhs can be omitted. |
| 2481 | ArrayInitOne, | |
| 2481 | array_init_one, | |
| 2482 | 2482 | /// `lhs{rhs,}`. rhs can *not* be omitted |
| 2483 | ArrayInitOneComma, | |
| 2483 | array_init_one_comma, | |
| 2484 | 2484 | /// `.{lhs, rhs}`. lhs and rhs can be omitted. |
| 2485 | ArrayInitDotTwo, | |
| 2486 | /// Same as `ArrayInitDotTwo` except there is known to be a trailing comma | |
| 2485 | array_init_dot_two, | |
| 2486 | /// Same as `array_init_dot_two` except there is known to be a trailing comma | |
| 2487 | 2487 | /// before the final rbrace. |
| 2488 | ArrayInitDotTwoComma, | |
| 2488 | array_init_dot_two_comma, | |
| 2489 | 2489 | /// `.{a, b}`. `sub_list[lhs..rhs]`. |
| 2490 | ArrayInitDot, | |
| 2491 | /// Same as `ArrayInitDot` except there is known to be a trailing comma | |
| 2490 | array_init_dot, | |
| 2491 | /// Same as `array_init_dot` except there is known to be a trailing comma | |
| 2492 | 2492 | /// before the final rbrace. |
| 2493 | ArrayInitDotComma, | |
| 2493 | array_init_dot_comma, | |
| 2494 | 2494 | /// `lhs{a, b}`. `sub_range_list[rhs]`. lhs can be omitted which means `.{a, b}`. |
| 2495 | ArrayInit, | |
| 2496 | /// Same as `ArrayInit` except there is known to be a trailing comma | |
| 2495 | array_init, | |
| 2496 | /// Same as `array_init` except there is known to be a trailing comma | |
| 2497 | 2497 | /// before the final rbrace. |
| 2498 | ArrayInitComma, | |
| 2498 | array_init_comma, | |
| 2499 | 2499 | /// `lhs{.a = rhs}`. rhs can be omitted making it empty. |
| 2500 | 2500 | /// main_token is the lbrace. |
| 2501 | StructInitOne, | |
| 2501 | struct_init_one, | |
| 2502 | 2502 | /// `lhs{.a = rhs,}`. rhs can *not* be omitted. |
| 2503 | 2503 | /// main_token is the lbrace. |
| 2504 | StructInitOneComma, | |
| 2504 | struct_init_one_comma, | |
| 2505 | 2505 | /// `.{.a = lhs, .b = rhs}`. lhs and rhs can be omitted. |
| 2506 | 2506 | /// main_token is the lbrace. |
| 2507 | 2507 | /// No trailing comma before the rbrace. |
| 2508 | StructInitDotTwo, | |
| 2509 | /// Same as `StructInitDotTwo` except there is known to be a trailing comma | |
| 2508 | struct_init_dot_two, | |
| 2509 | /// Same as `struct_init_dot_two` except there is known to be a trailing comma | |
| 2510 | 2510 | /// before the final rbrace. |
| 2511 | StructInitDotTwoComma, | |
| 2511 | struct_init_dot_two_comma, | |
| 2512 | 2512 | /// `.{.a = b, .c = d}`. `sub_list[lhs..rhs]`. |
| 2513 | 2513 | /// main_token is the lbrace. |
| 2514 | StructInitDot, | |
| 2515 | /// Same as `StructInitDot` except there is known to be a trailing comma | |
| 2514 | struct_init_dot, | |
| 2515 | /// Same as `struct_init_dot` except there is known to be a trailing comma | |
| 2516 | 2516 | /// before the final rbrace. |
| 2517 | StructInitDotComma, | |
| 2517 | struct_init_dot_comma, | |
| 2518 | 2518 | /// `lhs{.a = b, .c = d}`. `sub_range_list[rhs]`. |
| 2519 | 2519 | /// lhs can be omitted which means `.{.a = b, .c = d}`. |
| 2520 | 2520 | /// main_token is the lbrace. |
| 2521 | StructInit, | |
| 2522 | /// Same as `StructInit` except there is known to be a trailing comma | |
| 2521 | struct_init, | |
| 2522 | /// Same as `struct_init` except there is known to be a trailing comma | |
| 2523 | 2523 | /// before the final rbrace. |
| 2524 | StructInitComma, | |
| 2524 | struct_init_comma, | |
| 2525 | 2525 | /// `lhs(rhs)`. rhs can be omitted. |
| 2526 | CallOne, | |
| 2526 | call_one, | |
| 2527 | 2527 | /// `lhs(rhs,)`. rhs can be omitted. |
| 2528 | CallOneComma, | |
| 2528 | call_one_comma, | |
| 2529 | 2529 | /// `async lhs(rhs)`. rhs can be omitted. |
| 2530 | AsyncCallOne, | |
| 2530 | async_call_one, | |
| 2531 | 2531 | /// `async lhs(rhs,)`. |
| 2532 | AsyncCallOneComma, | |
| 2532 | async_call_one_comma, | |
| 2533 | 2533 | /// `lhs(a, b, c)`. `SubRange[rhs]`. |
| 2534 | 2534 | /// main_token is the `(`. |
| 2535 | Call, | |
| 2535 | call, | |
| 2536 | 2536 | /// `lhs(a, b, c,)`. `SubRange[rhs]`. |
| 2537 | 2537 | /// main_token is the `(`. |
| 2538 | CallComma, | |
| 2538 | call_comma, | |
| 2539 | 2539 | /// `async lhs(a, b, c)`. `SubRange[rhs]`. |
| 2540 | 2540 | /// main_token is the `(`. |
| 2541 | AsyncCall, | |
| 2541 | async_call, | |
| 2542 | 2542 | /// `async lhs(a, b, c,)`. `SubRange[rhs]`. |
| 2543 | 2543 | /// main_token is the `(`. |
| 2544 | AsyncCallComma, | |
| 2544 | async_call_comma, | |
| 2545 | 2545 | /// `switch(lhs) {}`. `SubRange[rhs]`. |
| 2546 | Switch, | |
| 2547 | /// Same as Switch except there is known to be a trailing comma | |
| 2546 | @"switch", | |
| 2547 | /// Same as switch except there is known to be a trailing comma | |
| 2548 | 2548 | /// before the final rbrace |
| 2549 | SwitchComma, | |
| 2549 | switch_comma, | |
| 2550 | 2550 | /// `lhs => rhs`. If lhs is omitted it means `else`. |
| 2551 | 2551 | /// main_token is the `=>` |
| 2552 | SwitchCaseOne, | |
| 2552 | switch_case_one, | |
| 2553 | 2553 | /// `a, b, c => rhs`. `SubRange[lhs]`. |
| 2554 | 2554 | /// main_token is the `=>` |
| 2555 | SwitchCase, | |
| 2555 | switch_case, | |
| 2556 | 2556 | /// `lhs...rhs`. |
| 2557 | SwitchRange, | |
| 2557 | switch_range, | |
| 2558 | 2558 | /// `while (lhs) rhs`. |
| 2559 | 2559 | /// `while (lhs) |x| rhs`. |
| 2560 | WhileSimple, | |
| 2560 | while_simple, | |
| 2561 | 2561 | /// `while (lhs) : (a) b`. `WhileCont[rhs]`. |
| 2562 | 2562 | /// `while (lhs) : (a) b`. `WhileCont[rhs]`. |
| 2563 | WhileCont, | |
| 2563 | while_cont, | |
| 2564 | 2564 | /// `while (lhs) : (a) b else c`. `While[rhs]`. |
| 2565 | 2565 | /// `while (lhs) |x| : (a) b else c`. `While[rhs]`. |
| 2566 | 2566 | /// `while (lhs) |x| : (a) b else |y| c`. `While[rhs]`. |
| 2567 | While, | |
| 2567 | @"while", | |
| 2568 | 2568 | /// `for (lhs) rhs`. |
| 2569 | ForSimple, | |
| 2569 | for_simple, | |
| 2570 | 2570 | /// `for (lhs) a else b`. `if_list[rhs]`. |
| 2571 | For, | |
| 2571 | @"for", | |
| 2572 | 2572 | /// `if (lhs) rhs`. |
| 2573 | 2573 | /// `if (lhs) |a| rhs`. |
| 2574 | IfSimple, | |
| 2574 | if_simple, | |
| 2575 | 2575 | /// `if (lhs) a else b`. `If[rhs]`. |
| 2576 | 2576 | /// `if (lhs) |x| a else b`. `If[rhs]`. |
| 2577 | 2577 | /// `if (lhs) |x| a else |y| b`. `If[rhs]`. |
| 2578 | If, | |
| 2578 | @"if", | |
| 2579 | 2579 | /// `suspend lhs`. lhs can be omitted. rhs is unused. |
| 2580 | Suspend, | |
| 2580 | @"suspend", | |
| 2581 | 2581 | /// `resume lhs`. rhs is unused. |
| 2582 | Resume, | |
| 2582 | @"resume", | |
| 2583 | 2583 | /// `continue`. lhs is token index of label if any. rhs is unused. |
| 2584 | Continue, | |
| 2584 | @"continue", | |
| 2585 | 2585 | /// `break :lhs rhs` |
| 2586 | 2586 | /// both lhs and rhs may be omitted. |
| 2587 | Break, | |
| 2587 | @"break", | |
| 2588 | 2588 | /// `return lhs`. lhs can be omitted. rhs is unused. |
| 2589 | Return, | |
| 2589 | @"return", | |
| 2590 | 2590 | /// `fn(a: lhs) rhs`. lhs can be omitted. |
| 2591 | 2591 | /// anytype and ... parameters are omitted from the AST tree. |
| 2592 | FnProtoSimple, | |
| 2592 | fn_proto_simple, | |
| 2593 | 2593 | /// `fn(a: b, c: d) rhs`. `sub_range_list[lhs]`. |
| 2594 | 2594 | /// anytype and ... parameters are omitted from the AST tree. |
| 2595 | FnProtoMulti, | |
| 2595 | fn_proto_multi, | |
| 2596 | 2596 | /// `fn(a: b) rhs linksection(e) callconv(f)`. `FnProtoOne[lhs]`. |
| 2597 | 2597 | /// zero or one parameters. |
| 2598 | 2598 | /// anytype and ... parameters are omitted from the AST tree. |
| 2599 | FnProtoOne, | |
| 2599 | fn_proto_one, | |
| 2600 | 2600 | /// `fn(a: b, c: d) rhs linksection(e) callconv(f)`. `FnProto[lhs]`. |
| 2601 | 2601 | /// anytype and ... parameters are omitted from the AST tree. |
| 2602 | FnProto, | |
| 2603 | /// lhs is the FnProto. | |
| 2602 | fn_proto, | |
| 2603 | /// lhs is the fn_proto. | |
| 2604 | 2604 | /// rhs is the function body block if non-zero. |
| 2605 | /// if rhs is zero, the funtion decl has no body (e.g. an extern function) | |
| 2606 | FnDecl, | |
| 2605 | /// if rhs is zero, the function decl has no body (e.g. an extern function) | |
| 2606 | fn_decl, | |
| 2607 | 2607 | /// `anyframe->rhs`. main_token is `anyframe`. `lhs` is arrow token index. |
| 2608 | AnyFrameType, | |
| 2608 | anyframe_type, | |
| 2609 | 2609 | /// Both lhs and rhs unused. |
| 2610 | AnyFrameLiteral, | |
| 2610 | anyframe_literal, | |
| 2611 | 2611 | /// Both lhs and rhs unused. |
| 2612 | CharLiteral, | |
| 2612 | char_literal, | |
| 2613 | 2613 | /// Both lhs and rhs unused. |
| 2614 | IntegerLiteral, | |
| 2614 | integer_literal, | |
| 2615 | 2615 | /// Both lhs and rhs unused. |
| 2616 | FloatLiteral, | |
| 2616 | float_literal, | |
| 2617 | 2617 | /// Both lhs and rhs unused. |
| 2618 | FalseLiteral, | |
| 2618 | false_literal, | |
| 2619 | 2619 | /// Both lhs and rhs unused. |
| 2620 | TrueLiteral, | |
| 2620 | true_literal, | |
| 2621 | 2621 | /// Both lhs and rhs unused. |
| 2622 | NullLiteral, | |
| 2622 | null_literal, | |
| 2623 | 2623 | /// Both lhs and rhs unused. |
| 2624 | UndefinedLiteral, | |
| 2624 | undefined_literal, | |
| 2625 | 2625 | /// Both lhs and rhs unused. |
| 2626 | UnreachableLiteral, | |
| 2626 | unreachable_literal, | |
| 2627 | 2627 | /// Both lhs and rhs unused. |
| 2628 | 2628 | /// Most identifiers will not have explicit AST nodes, however for expressions |
| 2629 | 2629 | /// which could be one of many different kinds of AST nodes, there will be an |
| 2630 | /// Identifier AST node for it. | |
| 2631 | Identifier, | |
| 2630 | /// identifier AST node for it. | |
| 2631 | identifier, | |
| 2632 | 2632 | /// lhs is the dot token index, rhs unused, main_token is the identifier. |
| 2633 | EnumLiteral, | |
| 2633 | enum_literal, | |
| 2634 | 2634 | /// main_token is the first token index (redundant with lhs) |
| 2635 | 2635 | /// lhs is the first token index; rhs is the last token index. |
| 2636 | /// Could be a series of MultilineStringLiteralLine tokens, or a single | |
| 2637 | /// StringLiteral token. | |
| 2638 | StringLiteral, | |
| 2636 | /// Could be a series of multiline_string_literal_line tokens, or a single | |
| 2637 | /// string_literal token. | |
| 2638 | string_literal, | |
| 2639 | 2639 | /// `(lhs)`. main_token is the `(`; rhs is the token index of the `)`. |
| 2640 | GroupedExpression, | |
| 2640 | grouped_expression, | |
| 2641 | 2641 | /// `@a(lhs, rhs)`. lhs and rhs may be omitted. |
| 2642 | BuiltinCallTwo, | |
| 2643 | /// Same as BuiltinCallTwo but there is known to be a trailing comma before the rparen. | |
| 2644 | BuiltinCallTwoComma, | |
| 2642 | builtin_call_two, | |
| 2643 | /// Same as builtin_call_two but there is known to be a trailing comma before the rparen. | |
| 2644 | builtin_call_two_comma, | |
| 2645 | 2645 | /// `@a(b, c)`. `sub_list[lhs..rhs]`. |
| 2646 | BuiltinCall, | |
| 2647 | /// Same as BuiltinCall but there is known to be a trailing comma before the rparen. | |
| 2648 | BuiltinCallComma, | |
| 2646 | builtin_call, | |
| 2647 | /// Same as builtin_call but there is known to be a trailing comma before the rparen. | |
| 2648 | builtin_call_comma, | |
| 2649 | 2649 | /// `error{a, b}`. |
| 2650 | 2650 | /// rhs is the rbrace, lhs is unused. |
| 2651 | ErrorSetDecl, | |
| 2651 | error_set_decl, | |
| 2652 | 2652 | /// `struct {}`, `union {}`, `opaque {}`, `enum {}`. `extra_data[lhs..rhs]`. |
| 2653 | 2653 | /// main_token is `struct`, `union`, `opaque`, `enum` keyword. |
| 2654 | ContainerDecl, | |
| 2654 | container_decl, | |
| 2655 | 2655 | /// Same as ContainerDecl but there is known to be a trailing comma before the rbrace. |
| 2656 | ContainerDeclComma, | |
| 2656 | container_decl_comma, | |
| 2657 | 2657 | /// `struct {lhs, rhs}`, `union {lhs, rhs}`, `opaque {lhs, rhs}`, `enum {lhs, rhs}`. |
| 2658 | 2658 | /// lhs or rhs can be omitted. |
| 2659 | 2659 | /// main_token is `struct`, `union`, `opaque`, `enum` keyword. |
| 2660 | ContainerDeclTwo, | |
| 2660 | container_decl_two, | |
| 2661 | 2661 | /// Same as ContainerDeclTwo except there is known to be a trailing comma |
| 2662 | 2662 | /// before the rbrace. |
| 2663 | ContainerDeclTwoComma, | |
| 2663 | container_decl_two_comma, | |
| 2664 | 2664 | /// `union(lhs)` / `enum(lhs)`. `SubRange[rhs]`. |
| 2665 | ContainerDeclArg, | |
| 2666 | /// Same as ContainerDeclArg but there is known to be a trailing comma before the rbrace. | |
| 2667 | ContainerDeclArgComma, | |
| 2665 | container_decl_arg, | |
| 2666 | /// Same as container_decl_arg but there is known to be a trailing comma before the rbrace. | |
| 2667 | container_decl_arg_comma, | |
| 2668 | 2668 | /// `union(enum) {}`. `sub_list[lhs..rhs]`. |
| 2669 | 2669 | /// Note that tagged unions with explicitly provided enums are represented |
| 2670 | /// by `ContainerDeclArg`. | |
| 2671 | TaggedUnion, | |
| 2672 | /// Same as TaggedUnion but there is known to be a trailing comma before the rbrace. | |
| 2673 | TaggedUnionComma, | |
| 2670 | /// by `container_decl_arg`. | |
| 2671 | tagged_union, | |
| 2672 | /// Same as tagged_union but there is known to be a trailing comma before the rbrace. | |
| 2673 | tagged_union_comma, | |
| 2674 | 2674 | /// `union(enum) {lhs, rhs}`. lhs or rhs may be omitted. |
| 2675 | 2675 | /// Note that tagged unions with explicitly provided enums are represented |
| 2676 | /// by `ContainerDeclArg`. | |
| 2677 | TaggedUnionTwo, | |
| 2678 | /// Same as TaggedUnionTwo but there is known to be a trailing comma before the rbrace. | |
| 2679 | TaggedUnionTwoComma, | |
| 2676 | /// by `container_decl_arg`. | |
| 2677 | tagged_union_two, | |
| 2678 | /// Same as tagged_union_two but there is known to be a trailing comma before the rbrace. | |
| 2679 | tagged_union_two_comma, | |
| 2680 | 2680 | /// `union(enum(lhs)) {}`. `SubRange[rhs]`. |
| 2681 | TaggedUnionEnumTag, | |
| 2682 | /// Same as TaggedUnionEnumTag but there is known to be a trailing comma | |
| 2681 | tagged_union_enum_tag, | |
| 2682 | /// Same as tagged_union_enum_tag but there is known to be a trailing comma | |
| 2683 | 2683 | /// before the rbrace. |
| 2684 | TaggedUnionEnumTagComma, | |
| 2684 | tagged_union_enum_tag_comma, | |
| 2685 | 2685 | /// `a: lhs = rhs,`. lhs and rhs can be omitted. |
| 2686 | 2686 | /// main_token is the field name identifier. |
| 2687 | 2687 | /// lastToken() does not include the possible trailing comma. |
| 2688 | ContainerFieldInit, | |
| 2688 | container_field_init, | |
| 2689 | 2689 | /// `a: lhs align(rhs),`. rhs can be omitted. |
| 2690 | 2690 | /// main_token is the field name identifier. |
| 2691 | 2691 | /// lastToken() does not include the possible trailing comma. |
| 2692 | ContainerFieldAlign, | |
| 2692 | container_field_align, | |
| 2693 | 2693 | /// `a: lhs align(c) = d,`. `container_field_list[rhs]`. |
| 2694 | 2694 | /// main_token is the field name identifier. |
| 2695 | 2695 | /// lastToken() does not include the possible trailing comma. |
| 2696 | ContainerField, | |
| 2696 | container_field, | |
| 2697 | 2697 | /// `anytype`. both lhs and rhs unused. |
| 2698 | 2698 | /// Used by `ContainerField`. |
| 2699 | AnyType, | |
| 2699 | @"anytype", | |
| 2700 | 2700 | /// `comptime lhs`. rhs unused. |
| 2701 | Comptime, | |
| 2701 | @"comptime", | |
| 2702 | 2702 | /// `nosuspend lhs`. rhs unused. |
| 2703 | Nosuspend, | |
| 2703 | @"nosuspend", | |
| 2704 | 2704 | /// `{lhs rhs}`. rhs or lhs can be omitted. |
| 2705 | 2705 | /// main_token points at the lbrace. |
| 2706 | BlockTwo, | |
| 2707 | /// Same as BlockTwo but there is known to be a semicolon before the rbrace. | |
| 2708 | BlockTwoSemicolon, | |
| 2706 | block_two, | |
| 2707 | /// Same as block_two but there is known to be a semicolon before the rbrace. | |
| 2708 | block_two_semicolon, | |
| 2709 | 2709 | /// `{}`. `sub_list[lhs..rhs]`. |
| 2710 | 2710 | /// main_token points at the lbrace. |
| 2711 | Block, | |
| 2712 | /// Same as Block but there is known to be a semicolon before the rbrace. | |
| 2713 | BlockSemicolon, | |
| 2711 | block, | |
| 2712 | /// Same as block but there is known to be a semicolon before the rbrace. | |
| 2713 | block_semicolon, | |
| 2714 | 2714 | /// `asm(lhs)`. rhs is the token index of the rparen. |
| 2715 | AsmSimple, | |
| 2715 | asm_simple, | |
| 2716 | 2716 | /// `asm(lhs, a)`. `Asm[rhs]`. |
| 2717 | Asm, | |
| 2717 | @"asm", | |
| 2718 | 2718 | /// `[a] "b" (c)`. lhs is 0, rhs is token index of the rparen. |
| 2719 | 2719 | /// `[a] "b" (-> lhs)`. rhs is token index of the rparen. |
| 2720 | 2720 | /// main_token is `a`. |
| 2721 | AsmOutput, | |
| 2721 | asm_output, | |
| 2722 | 2722 | /// `[a] "b" (lhs)`. rhs is token index of the rparen. |
| 2723 | 2723 | /// main_token is `a`. |
| 2724 | AsmInput, | |
| 2724 | asm_input, | |
| 2725 | 2725 | /// `error.a`. lhs is token index of `.`. rhs is token index of `a`. |
| 2726 | ErrorValue, | |
| 2726 | error_value, | |
| 2727 | 2727 | /// `lhs!rhs`. main_token is the `!`. |
| 2728 | ErrorUnion, | |
| 2728 | error_union, | |
| 2729 | 2729 | |
| 2730 | 2730 | pub fn isContainerField(tag: Tag) bool { |
| 2731 | 2731 | return switch (tag) { |
| 2732 | .ContainerFieldInit, | |
| 2733 | .ContainerFieldAlign, | |
| 2734 | .ContainerField, | |
| 2732 | .container_field_init, | |
| 2733 | .container_field_align, | |
| 2734 | .container_field, | |
| 2735 | 2735 | => true, |
| 2736 | 2736 | |
| 2737 | 2737 | else => false, |
lib/std/zig/parse.zig+199-199| ... | ... | @@ -57,7 +57,7 @@ pub fn parse(gpa: *Allocator, source: []const u8) Allocator.Error!Tree { |
| 57 | 57 | // Root node must be index 0. |
| 58 | 58 | // Root <- skip ContainerMembers eof |
| 59 | 59 | parser.nodes.appendAssumeCapacity(.{ |
| 60 | .tag = .Root, | |
| 60 | .tag = .root, | |
| 61 | 61 | .main_token = 0, |
| 62 | 62 | .data = .{ |
| 63 | 63 | .lhs = undefined, |
| ... | ... | @@ -251,7 +251,7 @@ const Parser = struct { |
| 251 | 251 | }; |
| 252 | 252 | if (block != 0) { |
| 253 | 253 | const comptime_node = try p.addNode(.{ |
| 254 | .tag = .Comptime, | |
| 254 | .tag = .@"comptime", | |
| 255 | 255 | .main_token = comptime_token, |
| 256 | 256 | .data = .{ |
| 257 | 257 | .lhs = block, |
| ... | ... | @@ -477,7 +477,7 @@ const Parser = struct { |
| 477 | 477 | const block_node = try p.parseBlock(); |
| 478 | 478 | if (block_node == 0) return p.fail(.{ .ExpectedLBrace = .{ .token = p.tok_i } }); |
| 479 | 479 | return p.addNode(.{ |
| 480 | .tag = .TestDecl, | |
| 480 | .tag = .test_decl, | |
| 481 | 481 | .main_token = test_token, |
| 482 | 482 | .data = .{ |
| 483 | 483 | .lhs = name_token orelse 0, |
| ... | ... | @@ -517,7 +517,7 @@ const Parser = struct { |
| 517 | 517 | const semicolon_token = p.nextToken(); |
| 518 | 518 | try p.parseAppendedDocComment(semicolon_token); |
| 519 | 519 | return p.addNode(.{ |
| 520 | .tag = .FnDecl, | |
| 520 | .tag = .fn_decl, | |
| 521 | 521 | .main_token = p.nodes.items(.main_token)[fn_proto], |
| 522 | 522 | .data = .{ |
| 523 | 523 | .lhs = fn_proto, |
| ... | ... | @@ -529,7 +529,7 @@ const Parser = struct { |
| 529 | 529 | const body_block = try p.parseBlock(); |
| 530 | 530 | assert(body_block != 0); |
| 531 | 531 | return p.addNode(.{ |
| 532 | .tag = .FnDecl, | |
| 532 | .tag = .fn_decl, | |
| 533 | 533 | .main_token = p.nodes.items(.main_token)[fn_proto], |
| 534 | 534 | .data = .{ |
| 535 | 535 | .lhs = fn_proto, |
| ... | ... | @@ -587,7 +587,7 @@ const Parser = struct { |
| 587 | 587 | const semicolon_token = try p.expectToken(.semicolon); |
| 588 | 588 | try p.parseAppendedDocComment(semicolon_token); |
| 589 | 589 | return p.addNode(.{ |
| 590 | .tag = .UsingNamespace, | |
| 590 | .tag = .@"usingnamespace", | |
| 591 | 591 | .main_token = usingnamespace_token, |
| 592 | 592 | .data = .{ |
| 593 | 593 | .lhs = expr, |
| ... | ... | @@ -627,7 +627,7 @@ const Parser = struct { |
| 627 | 627 | if (align_expr == 0 and section_expr == 0 and callconv_expr == 0) { |
| 628 | 628 | switch (params) { |
| 629 | 629 | .zero_or_one => |param| return p.addNode(.{ |
| 630 | .tag = .FnProtoSimple, | |
| 630 | .tag = .fn_proto_simple, | |
| 631 | 631 | .main_token = fn_token, |
| 632 | 632 | .data = .{ |
| 633 | 633 | .lhs = param, |
| ... | ... | @@ -637,7 +637,7 @@ const Parser = struct { |
| 637 | 637 | .multi => |list| { |
| 638 | 638 | const span = try p.listToSpan(list); |
| 639 | 639 | return p.addNode(.{ |
| 640 | .tag = .FnProtoMulti, | |
| 640 | .tag = .fn_proto_multi, | |
| 641 | 641 | .main_token = fn_token, |
| 642 | 642 | .data = .{ |
| 643 | 643 | .lhs = try p.addExtra(Node.SubRange{ |
| ... | ... | @@ -652,7 +652,7 @@ const Parser = struct { |
| 652 | 652 | } |
| 653 | 653 | switch (params) { |
| 654 | 654 | .zero_or_one => |param| return p.addNode(.{ |
| 655 | .tag = .FnProtoOne, | |
| 655 | .tag = .fn_proto_one, | |
| 656 | 656 | .main_token = fn_token, |
| 657 | 657 | .data = .{ |
| 658 | 658 | .lhs = try p.addExtra(Node.FnProtoOne{ |
| ... | ... | @@ -667,7 +667,7 @@ const Parser = struct { |
| 667 | 667 | .multi => |list| { |
| 668 | 668 | const span = try p.listToSpan(list); |
| 669 | 669 | return p.addNode(.{ |
| 670 | .tag = .FnProto, | |
| 670 | .tag = .fn_proto, | |
| 671 | 671 | .main_token = fn_token, |
| 672 | 672 | .data = .{ |
| 673 | 673 | .lhs = try p.addExtra(Node.FnProto{ |
| ... | ... | @@ -698,7 +698,7 @@ const Parser = struct { |
| 698 | 698 | if (section_node == 0) { |
| 699 | 699 | if (align_node == 0) { |
| 700 | 700 | return p.addNode(.{ |
| 701 | .tag = .SimpleVarDecl, | |
| 701 | .tag = .simple_var_decl, | |
| 702 | 702 | .main_token = mut_token, |
| 703 | 703 | .data = .{ |
| 704 | 704 | .lhs = type_node, |
| ... | ... | @@ -707,7 +707,7 @@ const Parser = struct { |
| 707 | 707 | }); |
| 708 | 708 | } else if (type_node == 0) { |
| 709 | 709 | return p.addNode(.{ |
| 710 | .tag = .AlignedVarDecl, | |
| 710 | .tag = .aligned_var_decl, | |
| 711 | 711 | .main_token = mut_token, |
| 712 | 712 | .data = .{ |
| 713 | 713 | .lhs = align_node, |
| ... | ... | @@ -716,7 +716,7 @@ const Parser = struct { |
| 716 | 716 | }); |
| 717 | 717 | } else { |
| 718 | 718 | return p.addNode(.{ |
| 719 | .tag = .LocalVarDecl, | |
| 719 | .tag = .local_var_decl, | |
| 720 | 720 | .main_token = mut_token, |
| 721 | 721 | .data = .{ |
| 722 | 722 | .lhs = try p.addExtra(Node.LocalVarDecl{ |
| ... | ... | @@ -729,7 +729,7 @@ const Parser = struct { |
| 729 | 729 | } |
| 730 | 730 | } else { |
| 731 | 731 | return p.addNode(.{ |
| 732 | .tag = .GlobalVarDecl, | |
| 732 | .tag = .global_var_decl, | |
| 733 | 733 | .main_token = mut_token, |
| 734 | 734 | .data = .{ |
| 735 | 735 | .lhs = try p.addExtra(Node.GlobalVarDecl{ |
| ... | ... | @@ -753,7 +753,7 @@ const Parser = struct { |
| 753 | 753 | if (p.eatToken(.colon)) |_| { |
| 754 | 754 | if (p.eatToken(.keyword_anytype)) |anytype_tok| { |
| 755 | 755 | type_expr = try p.addNode(.{ |
| 756 | .tag = .AnyType, | |
| 756 | .tag = .@"anytype", | |
| 757 | 757 | .main_token = anytype_tok, |
| 758 | 758 | .data = .{ |
| 759 | 759 | .lhs = undefined, |
| ... | ... | @@ -770,7 +770,7 @@ const Parser = struct { |
| 770 | 770 | |
| 771 | 771 | if (align_expr == 0) { |
| 772 | 772 | return p.addNode(.{ |
| 773 | .tag = .ContainerFieldInit, | |
| 773 | .tag = .container_field_init, | |
| 774 | 774 | .main_token = name_token, |
| 775 | 775 | .data = .{ |
| 776 | 776 | .lhs = type_expr, |
| ... | ... | @@ -779,7 +779,7 @@ const Parser = struct { |
| 779 | 779 | }); |
| 780 | 780 | } else if (value_expr == 0) { |
| 781 | 781 | return p.addNode(.{ |
| 782 | .tag = .ContainerFieldAlign, | |
| 782 | .tag = .container_field_align, | |
| 783 | 783 | .main_token = name_token, |
| 784 | 784 | .data = .{ |
| 785 | 785 | .lhs = type_expr, |
| ... | ... | @@ -788,7 +788,7 @@ const Parser = struct { |
| 788 | 788 | }); |
| 789 | 789 | } else { |
| 790 | 790 | return p.addNode(.{ |
| 791 | .tag = .ContainerField, | |
| 791 | .tag = .container_field, | |
| 792 | 792 | .main_token = name_token, |
| 793 | 793 | .data = .{ |
| 794 | 794 | .lhs = type_expr, |
| ... | ... | @@ -833,7 +833,7 @@ const Parser = struct { |
| 833 | 833 | |
| 834 | 834 | if (comptime_token) |token| { |
| 835 | 835 | return p.addNode(.{ |
| 836 | .tag = .Comptime, | |
| 836 | .tag = .@"comptime", | |
| 837 | 837 | .main_token = token, |
| 838 | 838 | .data = .{ |
| 839 | 839 | .lhs = try p.expectBlockExprStatement(), |
| ... | ... | @@ -845,7 +845,7 @@ const Parser = struct { |
| 845 | 845 | switch (p.token_tags[p.tok_i]) { |
| 846 | 846 | .keyword_nosuspend => { |
| 847 | 847 | return p.addNode(.{ |
| 848 | .tag = .Nosuspend, | |
| 848 | .tag = .@"nosuspend", | |
| 849 | 849 | .main_token = p.nextToken(), |
| 850 | 850 | .data = .{ |
| 851 | 851 | .lhs = try p.expectBlockExprStatement(), |
| ... | ... | @@ -860,7 +860,7 @@ const Parser = struct { |
| 860 | 860 | else |
| 861 | 861 | try p.expectBlockExprStatement(); |
| 862 | 862 | return p.addNode(.{ |
| 863 | .tag = .Suspend, | |
| 863 | .tag = .@"suspend", | |
| 864 | 864 | .main_token = token, |
| 865 | 865 | .data = .{ |
| 866 | 866 | .lhs = block_expr, |
| ... | ... | @@ -869,7 +869,7 @@ const Parser = struct { |
| 869 | 869 | }); |
| 870 | 870 | }, |
| 871 | 871 | .keyword_defer => return p.addNode(.{ |
| 872 | .tag = .Defer, | |
| 872 | .tag = .@"defer", | |
| 873 | 873 | .main_token = p.nextToken(), |
| 874 | 874 | .data = .{ |
| 875 | 875 | .lhs = undefined, |
| ... | ... | @@ -877,7 +877,7 @@ const Parser = struct { |
| 877 | 877 | }, |
| 878 | 878 | }), |
| 879 | 879 | .keyword_errdefer => return p.addNode(.{ |
| 880 | .tag = .ErrDefer, | |
| 880 | .tag = .@"errdefer", | |
| 881 | 881 | .main_token = p.nextToken(), |
| 882 | 882 | .data = .{ |
| 883 | 883 | .lhs = try p.parsePayload(), |
| ... | ... | @@ -947,7 +947,7 @@ const Parser = struct { |
| 947 | 947 | } |
| 948 | 948 | if (p.eatToken(.semicolon)) |_| { |
| 949 | 949 | return p.addNode(.{ |
| 950 | .tag = .IfSimple, | |
| 950 | .tag = .if_simple, | |
| 951 | 951 | .main_token = if_token, |
| 952 | 952 | .data = .{ |
| 953 | 953 | .lhs = condition, |
| ... | ... | @@ -963,7 +963,7 @@ const Parser = struct { |
| 963 | 963 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); |
| 964 | 964 | } |
| 965 | 965 | return p.addNode(.{ |
| 966 | .tag = .IfSimple, | |
| 966 | .tag = .if_simple, | |
| 967 | 967 | .main_token = if_token, |
| 968 | 968 | .data = .{ |
| 969 | 969 | .lhs = condition, |
| ... | ... | @@ -974,7 +974,7 @@ const Parser = struct { |
| 974 | 974 | const else_payload = try p.parsePayload(); |
| 975 | 975 | const else_expr = try p.expectStatement(); |
| 976 | 976 | return p.addNode(.{ |
| 977 | .tag = .If, | |
| 977 | .tag = .@"if", | |
| 978 | 978 | .main_token = if_token, |
| 979 | 979 | .data = .{ |
| 980 | 980 | .lhs = condition, |
| ... | ... | @@ -1041,7 +1041,7 @@ const Parser = struct { |
| 1041 | 1041 | } |
| 1042 | 1042 | if (p.eatToken(.semicolon)) |_| { |
| 1043 | 1043 | return p.addNode(.{ |
| 1044 | .tag = .ForSimple, | |
| 1044 | .tag = .for_simple, | |
| 1045 | 1045 | .main_token = for_token, |
| 1046 | 1046 | .data = .{ |
| 1047 | 1047 | .lhs = array_expr, |
| ... | ... | @@ -1057,7 +1057,7 @@ const Parser = struct { |
| 1057 | 1057 | return p.fail(.{ .ExpectedSemiOrElse = .{ .token = p.tok_i } }); |
| 1058 | 1058 | } |
| 1059 | 1059 | return p.addNode(.{ |
| 1060 | .tag = .ForSimple, | |
| 1060 | .tag = .for_simple, | |
| 1061 | 1061 | .main_token = for_token, |
| 1062 | 1062 | .data = .{ |
| 1063 | 1063 | .lhs = array_expr, |
| ... | ... | @@ -1066,7 +1066,7 @@ const Parser = struct { |
| 1066 | 1066 | }); |
| 1067 | 1067 | }; |
| 1068 | 1068 | return p.addNode(.{ |
| 1069 | .tag = .For, | |
| 1069 | .tag = .@"for", | |
| 1070 | 1070 | .main_token = for_token, |
| 1071 | 1071 | .data = .{ |
| 1072 | 1072 | .lhs = array_expr, |
| ... | ... | @@ -1103,7 +1103,7 @@ const Parser = struct { |
| 1103 | 1103 | if (p.eatToken(.semicolon)) |_| { |
| 1104 | 1104 | if (cont_expr == 0) { |
| 1105 | 1105 | return p.addNode(.{ |
| 1106 | .tag = .WhileSimple, | |
| 1106 | .tag = .while_simple, | |
| 1107 | 1107 | .main_token = while_token, |
| 1108 | 1108 | .data = .{ |
| 1109 | 1109 | .lhs = condition, |
| ... | ... | @@ -1112,7 +1112,7 @@ const Parser = struct { |
| 1112 | 1112 | }); |
| 1113 | 1113 | } else { |
| 1114 | 1114 | return p.addNode(.{ |
| 1115 | .tag = .WhileCont, | |
| 1115 | .tag = .while_cont, | |
| 1116 | 1116 | .main_token = while_token, |
| 1117 | 1117 | .data = .{ |
| 1118 | 1118 | .lhs = condition, |
| ... | ... | @@ -1133,7 +1133,7 @@ const Parser = struct { |
| 1133 | 1133 | } |
| 1134 | 1134 | if (cont_expr == 0) { |
| 1135 | 1135 | return p.addNode(.{ |
| 1136 | .tag = .WhileSimple, | |
| 1136 | .tag = .while_simple, | |
| 1137 | 1137 | .main_token = while_token, |
| 1138 | 1138 | .data = .{ |
| 1139 | 1139 | .lhs = condition, |
| ... | ... | @@ -1142,7 +1142,7 @@ const Parser = struct { |
| 1142 | 1142 | }); |
| 1143 | 1143 | } else { |
| 1144 | 1144 | return p.addNode(.{ |
| 1145 | .tag = .WhileCont, | |
| 1145 | .tag = .while_cont, | |
| 1146 | 1146 | .main_token = while_token, |
| 1147 | 1147 | .data = .{ |
| 1148 | 1148 | .lhs = condition, |
| ... | ... | @@ -1157,7 +1157,7 @@ const Parser = struct { |
| 1157 | 1157 | const else_payload = try p.parsePayload(); |
| 1158 | 1158 | const else_expr = try p.expectStatement(); |
| 1159 | 1159 | return p.addNode(.{ |
| 1160 | .tag = .While, | |
| 1160 | .tag = .@"while", | |
| 1161 | 1161 | .main_token = while_token, |
| 1162 | 1162 | .data = .{ |
| 1163 | 1163 | .lhs = condition, |
| ... | ... | @@ -1233,20 +1233,20 @@ const Parser = struct { |
| 1233 | 1233 | if (expr == 0) return null_node; |
| 1234 | 1234 | |
| 1235 | 1235 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1236 | .asterisk_equal => .AssignMul, | |
| 1237 | .slash_equal => .AssignDiv, | |
| 1238 | .percent_equal => .AssignMod, | |
| 1239 | .plus_equal => .AssignAdd, | |
| 1240 | .minus_equal => .AssignSub, | |
| 1241 | .angle_bracket_angle_bracket_left_equal => .AssignBitShiftLeft, | |
| 1242 | .angle_bracket_angle_bracket_right_equal => .AssignBitShiftRight, | |
| 1243 | .ampersand_equal => .AssignBitAnd, | |
| 1244 | .caret_equal => .AssignBitXor, | |
| 1245 | .pipe_equal => .AssignBitOr, | |
| 1246 | .asterisk_percent_equal => .AssignMulWrap, | |
| 1247 | .plus_percent_equal => .AssignAddWrap, | |
| 1248 | .minus_percent_equal => .AssignSubWrap, | |
| 1249 | .equal => .Assign, | |
| 1236 | .asterisk_equal => .assign_mul, | |
| 1237 | .slash_equal => .assign_div, | |
| 1238 | .percent_equal => .assign_mod, | |
| 1239 | .plus_equal => .assign_add, | |
| 1240 | .minus_equal => .assign_sub, | |
| 1241 | .angle_bracket_angle_bracket_left_equal => .assign_bit_shift_left, | |
| 1242 | .angle_bracket_angle_bracket_right_equal => .assign_bit_shift_right, | |
| 1243 | .ampersand_equal => .assign_bit_and, | |
| 1244 | .caret_equal => .assign_bit_xor, | |
| 1245 | .pipe_equal => .assign_bit_or, | |
| 1246 | .asterisk_percent_equal => .assign_mul_wrap, | |
| 1247 | .plus_percent_equal => .assign_add_wrap, | |
| 1248 | .minus_percent_equal => .assign_sub_wrap, | |
| 1249 | .equal => .assign, | |
| 1250 | 1250 | else => return expr, |
| 1251 | 1251 | }; |
| 1252 | 1252 | return p.addNode(.{ |
| ... | ... | @@ -1295,7 +1295,7 @@ const Parser = struct { |
| 1295 | 1295 | return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } }); |
| 1296 | 1296 | } |
| 1297 | 1297 | res = try p.addNode(.{ |
| 1298 | .tag = .BoolOr, | |
| 1298 | .tag = .bool_or, | |
| 1299 | 1299 | .main_token = or_token, |
| 1300 | 1300 | .data = .{ |
| 1301 | 1301 | .lhs = res, |
| ... | ... | @@ -1322,7 +1322,7 @@ const Parser = struct { |
| 1322 | 1322 | return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } }); |
| 1323 | 1323 | } |
| 1324 | 1324 | res = try p.addNode(.{ |
| 1325 | .tag = .BoolAnd, | |
| 1325 | .tag = .bool_and, | |
| 1326 | 1326 | .main_token = and_token, |
| 1327 | 1327 | .data = .{ |
| 1328 | 1328 | .lhs = res, |
| ... | ... | @@ -1348,12 +1348,12 @@ const Parser = struct { |
| 1348 | 1348 | if (expr == 0) return null_node; |
| 1349 | 1349 | |
| 1350 | 1350 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1351 | .equal_equal => .EqualEqual, | |
| 1352 | .bang_equal => .BangEqual, | |
| 1353 | .angle_bracket_left => .LessThan, | |
| 1354 | .angle_bracket_right => .GreaterThan, | |
| 1355 | .angle_bracket_left_equal => .LessOrEqual, | |
| 1356 | .angle_bracket_right_equal => .GreaterOrEqual, | |
| 1351 | .equal_equal => .equal_equal, | |
| 1352 | .bang_equal => .bang_equal, | |
| 1353 | .angle_bracket_left => .less_than, | |
| 1354 | .angle_bracket_right => .greater_than, | |
| 1355 | .angle_bracket_left_equal => .less_or_equal, | |
| 1356 | .angle_bracket_right_equal => .greater_or_equal, | |
| 1357 | 1357 | else => return expr, |
| 1358 | 1358 | }; |
| 1359 | 1359 | return p.addNode(.{ |
| ... | ... | @@ -1379,10 +1379,10 @@ const Parser = struct { |
| 1379 | 1379 | |
| 1380 | 1380 | while (true) { |
| 1381 | 1381 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1382 | .ampersand => .BitAnd, | |
| 1383 | .caret => .BitXor, | |
| 1384 | .pipe => .BitOr, | |
| 1385 | .keyword_orelse => .OrElse, | |
| 1382 | .ampersand => .bit_and, | |
| 1383 | .caret => .bit_xor, | |
| 1384 | .pipe => .bit_or, | |
| 1385 | .keyword_orelse => .@"orelse", | |
| 1386 | 1386 | .keyword_catch => { |
| 1387 | 1387 | const catch_token = p.nextToken(); |
| 1388 | 1388 | _ = try p.parsePayload(); |
| ... | ... | @@ -1391,7 +1391,7 @@ const Parser = struct { |
| 1391 | 1391 | return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } }); |
| 1392 | 1392 | } |
| 1393 | 1393 | res = try p.addNode(.{ |
| 1394 | .tag = .Catch, | |
| 1394 | .tag = .@"catch", | |
| 1395 | 1395 | .main_token = catch_token, |
| 1396 | 1396 | .data = .{ |
| 1397 | 1397 | .lhs = res, |
| ... | ... | @@ -1432,8 +1432,8 @@ const Parser = struct { |
| 1432 | 1432 | |
| 1433 | 1433 | while (true) { |
| 1434 | 1434 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1435 | .angle_bracket_angle_bracket_left => .BitShiftLeft, | |
| 1436 | .angle_bracket_angle_bracket_right => .BitShiftRight, | |
| 1435 | .angle_bracket_angle_bracket_left => .bit_shift_left, | |
| 1436 | .angle_bracket_angle_bracket_right => .bit_shift_right, | |
| 1437 | 1437 | else => return res, |
| 1438 | 1438 | }; |
| 1439 | 1439 | res = try p.addNode(.{ |
| ... | ... | @@ -1469,11 +1469,11 @@ const Parser = struct { |
| 1469 | 1469 | |
| 1470 | 1470 | while (true) { |
| 1471 | 1471 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1472 | .plus => .Add, | |
| 1473 | .minus => .Sub, | |
| 1474 | .plus_plus => .ArrayCat, | |
| 1475 | .plus_percent => .AddWrap, | |
| 1476 | .minus_percent => .SubWrap, | |
| 1472 | .plus => .add, | |
| 1473 | .minus => .sub, | |
| 1474 | .plus_plus => .array_cat, | |
| 1475 | .plus_percent => .add_wrap, | |
| 1476 | .minus_percent => .sub_wrap, | |
| 1477 | 1477 | else => return res, |
| 1478 | 1478 | }; |
| 1479 | 1479 | res = try p.addNode(.{ |
| ... | ... | @@ -1509,12 +1509,12 @@ const Parser = struct { |
| 1509 | 1509 | |
| 1510 | 1510 | while (true) { |
| 1511 | 1511 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1512 | .pipe_pipe => .MergeErrorSets, | |
| 1513 | .asterisk => .Mul, | |
| 1514 | .slash => .Div, | |
| 1515 | .percent => .Mod, | |
| 1516 | .asterisk_asterisk => .ArrayMult, | |
| 1517 | .asterisk_percent => .MulWrap, | |
| 1512 | .pipe_pipe => .merge_error_sets, | |
| 1513 | .asterisk => .mul, | |
| 1514 | .slash => .div, | |
| 1515 | .percent => .mod, | |
| 1516 | .asterisk_asterisk => .array_mult, | |
| 1517 | .asterisk_percent => .mul_wrap, | |
| 1518 | 1518 | else => return res, |
| 1519 | 1519 | }; |
| 1520 | 1520 | res = try p.addNode(.{ |
| ... | ... | @@ -1547,13 +1547,13 @@ const Parser = struct { |
| 1547 | 1547 | /// / KEYWORD_await |
| 1548 | 1548 | fn parsePrefixExpr(p: *Parser) Error!Node.Index { |
| 1549 | 1549 | const tag: Node.Tag = switch (p.token_tags[p.tok_i]) { |
| 1550 | .bang => .BoolNot, | |
| 1551 | .minus => .Negation, | |
| 1552 | .tilde => .BitNot, | |
| 1553 | .minus_percent => .NegationWrap, | |
| 1554 | .ampersand => .AddressOf, | |
| 1555 | .keyword_try => .Try, | |
| 1556 | .keyword_await => .Await, | |
| 1550 | .bang => .bool_not, | |
| 1551 | .minus => .negation, | |
| 1552 | .tilde => .bit_not, | |
| 1553 | .minus_percent => .negation_wrap, | |
| 1554 | .ampersand => .address_of, | |
| 1555 | .keyword_try => .@"try", | |
| 1556 | .keyword_await => .@"await", | |
| 1557 | 1557 | else => return p.parsePrimaryExpr(), |
| 1558 | 1558 | }; |
| 1559 | 1559 | return p.addNode(.{ |
| ... | ... | @@ -1588,7 +1588,7 @@ const Parser = struct { |
| 1588 | 1588 | fn parseTypeExpr(p: *Parser) Error!Node.Index { |
| 1589 | 1589 | switch (p.token_tags[p.tok_i]) { |
| 1590 | 1590 | .question_mark => return p.addNode(.{ |
| 1591 | .tag = .OptionalType, | |
| 1591 | .tag = .optional_type, | |
| 1592 | 1592 | .main_token = p.nextToken(), |
| 1593 | 1593 | .data = .{ |
| 1594 | 1594 | .lhs = try p.expectTypeExpr(), |
| ... | ... | @@ -1597,7 +1597,7 @@ const Parser = struct { |
| 1597 | 1597 | }), |
| 1598 | 1598 | .keyword_anyframe => switch (p.token_tags[p.tok_i + 1]) { |
| 1599 | 1599 | .arrow => return p.addNode(.{ |
| 1600 | .tag = .AnyFrameType, | |
| 1600 | .tag = .anyframe_type, | |
| 1601 | 1601 | .main_token = p.nextToken(), |
| 1602 | 1602 | .data = .{ |
| 1603 | 1603 | .lhs = p.nextToken(), |
| ... | ... | @@ -1612,7 +1612,7 @@ const Parser = struct { |
| 1612 | 1612 | const elem_type = try p.expectTypeExpr(); |
| 1613 | 1613 | if (mods.bit_range_start == 0) { |
| 1614 | 1614 | return p.addNode(.{ |
| 1615 | .tag = .PtrTypeAligned, | |
| 1615 | .tag = .ptr_type_aligned, | |
| 1616 | 1616 | .main_token = asterisk, |
| 1617 | 1617 | .data = .{ |
| 1618 | 1618 | .lhs = mods.align_node, |
| ... | ... | @@ -1621,7 +1621,7 @@ const Parser = struct { |
| 1621 | 1621 | }); |
| 1622 | 1622 | } else { |
| 1623 | 1623 | return p.addNode(.{ |
| 1624 | .tag = .PtrTypeBitRange, | |
| 1624 | .tag = .ptr_type_bit_range, | |
| 1625 | 1625 | .main_token = asterisk, |
| 1626 | 1626 | .data = .{ |
| 1627 | 1627 | .lhs = try p.addExtra(Node.PtrTypeBitRange{ |
| ... | ... | @@ -1642,7 +1642,7 @@ const Parser = struct { |
| 1642 | 1642 | const inner: Node.Index = inner: { |
| 1643 | 1643 | if (mods.bit_range_start == 0) { |
| 1644 | 1644 | break :inner try p.addNode(.{ |
| 1645 | .tag = .PtrTypeAligned, | |
| 1645 | .tag = .ptr_type_aligned, | |
| 1646 | 1646 | .main_token = asterisk, |
| 1647 | 1647 | .data = .{ |
| 1648 | 1648 | .lhs = mods.align_node, |
| ... | ... | @@ -1651,7 +1651,7 @@ const Parser = struct { |
| 1651 | 1651 | }); |
| 1652 | 1652 | } else { |
| 1653 | 1653 | break :inner try p.addNode(.{ |
| 1654 | .tag = .PtrTypeBitRange, | |
| 1654 | .tag = .ptr_type_bit_range, | |
| 1655 | 1655 | .main_token = asterisk, |
| 1656 | 1656 | .data = .{ |
| 1657 | 1657 | .lhs = try p.addExtra(Node.PtrTypeBitRange{ |
| ... | ... | @@ -1666,7 +1666,7 @@ const Parser = struct { |
| 1666 | 1666 | } |
| 1667 | 1667 | }; |
| 1668 | 1668 | return p.addNode(.{ |
| 1669 | .tag = .PtrTypeAligned, | |
| 1669 | .tag = .ptr_type_aligned, | |
| 1670 | 1670 | .main_token = asterisk, |
| 1671 | 1671 | .data = .{ |
| 1672 | 1672 | .lhs = 0, |
| ... | ... | @@ -1698,7 +1698,7 @@ const Parser = struct { |
| 1698 | 1698 | if (mods.bit_range_start == 0) { |
| 1699 | 1699 | if (sentinel == 0) { |
| 1700 | 1700 | return p.addNode(.{ |
| 1701 | .tag = .PtrTypeAligned, | |
| 1701 | .tag = .ptr_type_aligned, | |
| 1702 | 1702 | .main_token = asterisk, |
| 1703 | 1703 | .data = .{ |
| 1704 | 1704 | .lhs = mods.align_node, |
| ... | ... | @@ -1707,7 +1707,7 @@ const Parser = struct { |
| 1707 | 1707 | }); |
| 1708 | 1708 | } else if (mods.align_node == 0) { |
| 1709 | 1709 | return p.addNode(.{ |
| 1710 | .tag = .PtrTypeSentinel, | |
| 1710 | .tag = .ptr_type_sentinel, | |
| 1711 | 1711 | .main_token = asterisk, |
| 1712 | 1712 | .data = .{ |
| 1713 | 1713 | .lhs = sentinel, |
| ... | ... | @@ -1716,7 +1716,7 @@ const Parser = struct { |
| 1716 | 1716 | }); |
| 1717 | 1717 | } else { |
| 1718 | 1718 | return p.addNode(.{ |
| 1719 | .tag = .PtrType, | |
| 1719 | .tag = .ptr_type, | |
| 1720 | 1720 | .main_token = asterisk, |
| 1721 | 1721 | .data = .{ |
| 1722 | 1722 | .lhs = try p.addExtra(Node.PtrType{ |
| ... | ... | @@ -1729,7 +1729,7 @@ const Parser = struct { |
| 1729 | 1729 | } |
| 1730 | 1730 | } else { |
| 1731 | 1731 | return p.addNode(.{ |
| 1732 | .tag = .PtrTypeBitRange, | |
| 1732 | .tag = .ptr_type_bit_range, | |
| 1733 | 1733 | .main_token = asterisk, |
| 1734 | 1734 | .data = .{ |
| 1735 | 1735 | .lhs = try p.addExtra(Node.PtrTypeBitRange{ |
| ... | ... | @@ -1762,7 +1762,7 @@ const Parser = struct { |
| 1762 | 1762 | if (len_expr == 0) { |
| 1763 | 1763 | if (sentinel == 0) { |
| 1764 | 1764 | return p.addNode(.{ |
| 1765 | .tag = .PtrTypeAligned, | |
| 1765 | .tag = .ptr_type_aligned, | |
| 1766 | 1766 | .main_token = lbracket, |
| 1767 | 1767 | .data = .{ |
| 1768 | 1768 | .lhs = mods.align_node, |
| ... | ... | @@ -1771,7 +1771,7 @@ const Parser = struct { |
| 1771 | 1771 | }); |
| 1772 | 1772 | } else if (mods.align_node == 0) { |
| 1773 | 1773 | return p.addNode(.{ |
| 1774 | .tag = .PtrTypeSentinel, | |
| 1774 | .tag = .ptr_type_sentinel, | |
| 1775 | 1775 | .main_token = lbracket, |
| 1776 | 1776 | .data = .{ |
| 1777 | 1777 | .lhs = sentinel, |
| ... | ... | @@ -1780,7 +1780,7 @@ const Parser = struct { |
| 1780 | 1780 | }); |
| 1781 | 1781 | } else { |
| 1782 | 1782 | return p.addNode(.{ |
| 1783 | .tag = .PtrType, | |
| 1783 | .tag = .ptr_type, | |
| 1784 | 1784 | .main_token = lbracket, |
| 1785 | 1785 | .data = .{ |
| 1786 | 1786 | .lhs = try p.addExtra(Node.PtrType{ |
| ... | ... | @@ -1800,7 +1800,7 @@ const Parser = struct { |
| 1800 | 1800 | } |
| 1801 | 1801 | if (sentinel == 0) { |
| 1802 | 1802 | return p.addNode(.{ |
| 1803 | .tag = .ArrayType, | |
| 1803 | .tag = .array_type, | |
| 1804 | 1804 | .main_token = lbracket, |
| 1805 | 1805 | .data = .{ |
| 1806 | 1806 | .lhs = len_expr, |
| ... | ... | @@ -1809,7 +1809,7 @@ const Parser = struct { |
| 1809 | 1809 | }); |
| 1810 | 1810 | } else { |
| 1811 | 1811 | return p.addNode(.{ |
| 1812 | .tag = .ArrayTypeSentinel, | |
| 1812 | .tag = .array_type_sentinel, | |
| 1813 | 1813 | .main_token = lbracket, |
| 1814 | 1814 | .data = .{ |
| 1815 | 1815 | .lhs = len_expr, |
| ... | ... | @@ -1854,7 +1854,7 @@ const Parser = struct { |
| 1854 | 1854 | .keyword_break => { |
| 1855 | 1855 | p.tok_i += 1; |
| 1856 | 1856 | return p.addNode(.{ |
| 1857 | .tag = .Break, | |
| 1857 | .tag = .@"break", | |
| 1858 | 1858 | .main_token = p.tok_i - 1, |
| 1859 | 1859 | .data = .{ |
| 1860 | 1860 | .lhs = try p.parseBreakLabel(), |
| ... | ... | @@ -1865,7 +1865,7 @@ const Parser = struct { |
| 1865 | 1865 | .keyword_continue => { |
| 1866 | 1866 | p.tok_i += 1; |
| 1867 | 1867 | return p.addNode(.{ |
| 1868 | .tag = .Continue, | |
| 1868 | .tag = .@"continue", | |
| 1869 | 1869 | .main_token = p.tok_i - 1, |
| 1870 | 1870 | .data = .{ |
| 1871 | 1871 | .lhs = try p.parseBreakLabel(), |
| ... | ... | @@ -1876,7 +1876,7 @@ const Parser = struct { |
| 1876 | 1876 | .keyword_comptime => { |
| 1877 | 1877 | p.tok_i += 1; |
| 1878 | 1878 | return p.addNode(.{ |
| 1879 | .tag = .Comptime, | |
| 1879 | .tag = .@"comptime", | |
| 1880 | 1880 | .main_token = p.tok_i - 1, |
| 1881 | 1881 | .data = .{ |
| 1882 | 1882 | .lhs = try p.expectExpr(), |
| ... | ... | @@ -1887,7 +1887,7 @@ const Parser = struct { |
| 1887 | 1887 | .keyword_nosuspend => { |
| 1888 | 1888 | p.tok_i += 1; |
| 1889 | 1889 | return p.addNode(.{ |
| 1890 | .tag = .Nosuspend, | |
| 1890 | .tag = .@"nosuspend", | |
| 1891 | 1891 | .main_token = p.tok_i - 1, |
| 1892 | 1892 | .data = .{ |
| 1893 | 1893 | .lhs = try p.expectExpr(), |
| ... | ... | @@ -1898,7 +1898,7 @@ const Parser = struct { |
| 1898 | 1898 | .keyword_resume => { |
| 1899 | 1899 | p.tok_i += 1; |
| 1900 | 1900 | return p.addNode(.{ |
| 1901 | .tag = .Resume, | |
| 1901 | .tag = .@"resume", | |
| 1902 | 1902 | .main_token = p.tok_i - 1, |
| 1903 | 1903 | .data = .{ |
| 1904 | 1904 | .lhs = try p.expectExpr(), |
| ... | ... | @@ -1909,7 +1909,7 @@ const Parser = struct { |
| 1909 | 1909 | .keyword_return => { |
| 1910 | 1910 | p.tok_i += 1; |
| 1911 | 1911 | return p.addNode(.{ |
| 1912 | .tag = .Return, | |
| 1912 | .tag = .@"return", | |
| 1913 | 1913 | .main_token = p.tok_i - 1, |
| 1914 | 1914 | .data = .{ |
| 1915 | 1915 | .lhs = try p.parseExpr(), |
| ... | ... | @@ -1976,7 +1976,7 @@ const Parser = struct { |
| 1976 | 1976 | |
| 1977 | 1977 | if (p.eatToken(.r_brace)) |_| { |
| 1978 | 1978 | return p.addNode(.{ |
| 1979 | .tag = .BlockTwo, | |
| 1979 | .tag = .block_two, | |
| 1980 | 1980 | .main_token = lbrace, |
| 1981 | 1981 | .data = .{ |
| 1982 | 1982 | .lhs = 0, |
| ... | ... | @@ -1989,7 +1989,7 @@ const Parser = struct { |
| 1989 | 1989 | if (p.eatToken(.r_brace)) |_| { |
| 1990 | 1990 | const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; |
| 1991 | 1991 | return p.addNode(.{ |
| 1992 | .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo, | |
| 1992 | .tag = if (semicolon) .block_two_semicolon else .block_two, | |
| 1993 | 1993 | .main_token = lbrace, |
| 1994 | 1994 | .data = .{ |
| 1995 | 1995 | .lhs = stmt_one, |
| ... | ... | @@ -2001,7 +2001,7 @@ const Parser = struct { |
| 2001 | 2001 | if (p.eatToken(.r_brace)) |_| { |
| 2002 | 2002 | const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; |
| 2003 | 2003 | return p.addNode(.{ |
| 2004 | .tag = if (semicolon) .BlockTwoSemicolon else .BlockTwo, | |
| 2004 | .tag = if (semicolon) .block_two_semicolon else .block_two, | |
| 2005 | 2005 | .main_token = lbrace, |
| 2006 | 2006 | .data = .{ |
| 2007 | 2007 | .lhs = stmt_one, |
| ... | ... | @@ -2025,7 +2025,7 @@ const Parser = struct { |
| 2025 | 2025 | const semicolon = p.token_tags[p.tok_i - 2] == .semicolon; |
| 2026 | 2026 | const statements_span = try p.listToSpan(statements.items); |
| 2027 | 2027 | return p.addNode(.{ |
| 2028 | .tag = if (semicolon) .BlockSemicolon else .Block, | |
| 2028 | .tag = if (semicolon) .block_semicolon else .block, | |
| 2029 | 2029 | .main_token = lbrace, |
| 2030 | 2030 | .data = .{ |
| 2031 | 2031 | .lhs = statements_span.start, |
| ... | ... | @@ -2046,7 +2046,7 @@ const Parser = struct { |
| 2046 | 2046 | const then_expr = try p.expectExpr(); |
| 2047 | 2047 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2048 | 2048 | return p.addNode(.{ |
| 2049 | .tag = .ForSimple, | |
| 2049 | .tag = .for_simple, | |
| 2050 | 2050 | .main_token = for_token, |
| 2051 | 2051 | .data = .{ |
| 2052 | 2052 | .lhs = array_expr, |
| ... | ... | @@ -2056,7 +2056,7 @@ const Parser = struct { |
| 2056 | 2056 | }; |
| 2057 | 2057 | const else_expr = try p.expectExpr(); |
| 2058 | 2058 | return p.addNode(.{ |
| 2059 | .tag = .For, | |
| 2059 | .tag = .@"for", | |
| 2060 | 2060 | .main_token = for_token, |
| 2061 | 2061 | .data = .{ |
| 2062 | 2062 | .lhs = array_expr, |
| ... | ... | @@ -2082,7 +2082,7 @@ const Parser = struct { |
| 2082 | 2082 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2083 | 2083 | if (cont_expr == 0) { |
| 2084 | 2084 | return p.addNode(.{ |
| 2085 | .tag = .WhileSimple, | |
| 2085 | .tag = .while_simple, | |
| 2086 | 2086 | .main_token = while_token, |
| 2087 | 2087 | .data = .{ |
| 2088 | 2088 | .lhs = condition, |
| ... | ... | @@ -2091,7 +2091,7 @@ const Parser = struct { |
| 2091 | 2091 | }); |
| 2092 | 2092 | } else { |
| 2093 | 2093 | return p.addNode(.{ |
| 2094 | .tag = .WhileCont, | |
| 2094 | .tag = .while_cont, | |
| 2095 | 2095 | .main_token = while_token, |
| 2096 | 2096 | .data = .{ |
| 2097 | 2097 | .lhs = condition, |
| ... | ... | @@ -2106,7 +2106,7 @@ const Parser = struct { |
| 2106 | 2106 | const else_payload = try p.parsePayload(); |
| 2107 | 2107 | const else_expr = try p.expectExpr(); |
| 2108 | 2108 | return p.addNode(.{ |
| 2109 | .tag = .While, | |
| 2109 | .tag = .@"while", | |
| 2110 | 2110 | .main_token = while_token, |
| 2111 | 2111 | .data = .{ |
| 2112 | 2112 | .lhs = condition, |
| ... | ... | @@ -2134,7 +2134,7 @@ const Parser = struct { |
| 2134 | 2134 | |
| 2135 | 2135 | if (p.eatToken(.r_brace)) |_| { |
| 2136 | 2136 | return p.addNode(.{ |
| 2137 | .tag = .StructInitOne, | |
| 2137 | .tag = .struct_init_one, | |
| 2138 | 2138 | .main_token = lbrace, |
| 2139 | 2139 | .data = .{ |
| 2140 | 2140 | .lhs = lhs, |
| ... | ... | @@ -2147,7 +2147,7 @@ const Parser = struct { |
| 2147 | 2147 | const comma_one = p.eatToken(.comma); |
| 2148 | 2148 | if (p.eatToken(.r_brace)) |_| { |
| 2149 | 2149 | return p.addNode(.{ |
| 2150 | .tag = if (comma_one != null) .StructInitOneComma else .StructInitOne, | |
| 2150 | .tag = if (comma_one != null) .struct_init_one_comma else .struct_init_one, | |
| 2151 | 2151 | .main_token = lbrace, |
| 2152 | 2152 | .data = .{ |
| 2153 | 2153 | .lhs = lhs, |
| ... | ... | @@ -2192,7 +2192,7 @@ const Parser = struct { |
| 2192 | 2192 | } |
| 2193 | 2193 | const span = try p.listToSpan(init_list.items); |
| 2194 | 2194 | return p.addNode(.{ |
| 2195 | .tag = if (p.token_tags[p.tok_i - 2] == .comma) .StructInitComma else .StructInit, | |
| 2195 | .tag = if (p.token_tags[p.tok_i - 2] == .comma) .struct_init_comma else .struct_init, | |
| 2196 | 2196 | .main_token = lbrace, |
| 2197 | 2197 | .data = .{ |
| 2198 | 2198 | .lhs = lhs, |
| ... | ... | @@ -2208,7 +2208,7 @@ const Parser = struct { |
| 2208 | 2208 | const comma_one = p.eatToken(.comma); |
| 2209 | 2209 | if (p.eatToken(.r_brace)) |_| { |
| 2210 | 2210 | return p.addNode(.{ |
| 2211 | .tag = if (comma_one != null) .ArrayInitOneComma else .ArrayInitOne, | |
| 2211 | .tag = if (comma_one != null) .array_init_one_comma else .array_init_one, | |
| 2212 | 2212 | .main_token = lbrace, |
| 2213 | 2213 | .data = .{ |
| 2214 | 2214 | .lhs = lhs, |
| ... | ... | @@ -2239,7 +2239,7 @@ const Parser = struct { |
| 2239 | 2239 | _ = try p.expectToken(.r_brace); |
| 2240 | 2240 | const span = try p.listToSpan(init_list.items); |
| 2241 | 2241 | return p.addNode(.{ |
| 2242 | .tag = if (trailing_comma) .ArrayInitComma else .ArrayInit, | |
| 2242 | .tag = if (trailing_comma) .array_init_comma else .array_init, | |
| 2243 | 2243 | .main_token = lbrace, |
| 2244 | 2244 | .data = .{ |
| 2245 | 2245 | .lhs = lhs, |
| ... | ... | @@ -2257,7 +2257,7 @@ const Parser = struct { |
| 2257 | 2257 | if (suffix_expr == 0) return null_node; |
| 2258 | 2258 | const bang = p.eatToken(.bang) orelse return suffix_expr; |
| 2259 | 2259 | return p.addNode(.{ |
| 2260 | .tag = .ErrorUnion, | |
| 2260 | .tag = .error_union, | |
| 2261 | 2261 | .main_token = bang, |
| 2262 | 2262 | .data = .{ |
| 2263 | 2263 | .lhs = suffix_expr, |
| ... | ... | @@ -2286,7 +2286,7 @@ const Parser = struct { |
| 2286 | 2286 | }; |
| 2287 | 2287 | if (p.eatToken(.r_paren)) |_| { |
| 2288 | 2288 | return p.addNode(.{ |
| 2289 | .tag = .AsyncCallOne, | |
| 2289 | .tag = .async_call_one, | |
| 2290 | 2290 | .main_token = lparen, |
| 2291 | 2291 | .data = .{ |
| 2292 | 2292 | .lhs = res, |
| ... | ... | @@ -2298,7 +2298,7 @@ const Parser = struct { |
| 2298 | 2298 | const comma_one = p.eatToken(.comma); |
| 2299 | 2299 | if (p.eatToken(.r_paren)) |_| { |
| 2300 | 2300 | return p.addNode(.{ |
| 2301 | .tag = if (comma_one == null) .AsyncCallOne else .AsyncCallOneComma, | |
| 2301 | .tag = if (comma_one == null) .async_call_one else .async_call_one_comma, | |
| 2302 | 2302 | .main_token = lparen, |
| 2303 | 2303 | .data = .{ |
| 2304 | 2304 | .lhs = res, |
| ... | ... | @@ -2325,7 +2325,7 @@ const Parser = struct { |
| 2325 | 2325 | if (p.eatToken(.r_paren)) |_| { |
| 2326 | 2326 | const span = try p.listToSpan(param_list.items); |
| 2327 | 2327 | return p.addNode(.{ |
| 2328 | .tag = .AsyncCallComma, | |
| 2328 | .tag = .async_call_comma, | |
| 2329 | 2329 | .main_token = lparen, |
| 2330 | 2330 | .data = .{ |
| 2331 | 2331 | .lhs = res, |
| ... | ... | @@ -2342,7 +2342,7 @@ const Parser = struct { |
| 2342 | 2342 | .r_paren => { |
| 2343 | 2343 | const span = try p.listToSpan(param_list.items); |
| 2344 | 2344 | return p.addNode(.{ |
| 2345 | .tag = .AsyncCall, | |
| 2345 | .tag = .async_call, | |
| 2346 | 2346 | .main_token = lparen, |
| 2347 | 2347 | .data = .{ |
| 2348 | 2348 | .lhs = res, |
| ... | ... | @@ -2387,7 +2387,7 @@ const Parser = struct { |
| 2387 | 2387 | const lparen = p.eatToken(.l_paren) orelse return res; |
| 2388 | 2388 | if (p.eatToken(.r_paren)) |_| { |
| 2389 | 2389 | break :res try p.addNode(.{ |
| 2390 | .tag = .CallOne, | |
| 2390 | .tag = .call_one, | |
| 2391 | 2391 | .main_token = lparen, |
| 2392 | 2392 | .data = .{ |
| 2393 | 2393 | .lhs = res, |
| ... | ... | @@ -2399,7 +2399,7 @@ const Parser = struct { |
| 2399 | 2399 | const comma_one = p.eatToken(.comma); |
| 2400 | 2400 | if (p.eatToken(.r_paren)) |_| { |
| 2401 | 2401 | break :res try p.addNode(.{ |
| 2402 | .tag = if (comma_one == null) .CallOne else .CallOneComma, | |
| 2402 | .tag = if (comma_one == null) .call_one else .call_one_comma, | |
| 2403 | 2403 | .main_token = lparen, |
| 2404 | 2404 | .data = .{ |
| 2405 | 2405 | .lhs = res, |
| ... | ... | @@ -2426,7 +2426,7 @@ const Parser = struct { |
| 2426 | 2426 | if (p.eatToken(.r_paren)) |_| { |
| 2427 | 2427 | const span = try p.listToSpan(param_list.items); |
| 2428 | 2428 | break :res try p.addNode(.{ |
| 2429 | .tag = .CallComma, | |
| 2429 | .tag = .call_comma, | |
| 2430 | 2430 | .main_token = lparen, |
| 2431 | 2431 | .data = .{ |
| 2432 | 2432 | .lhs = res, |
| ... | ... | @@ -2443,7 +2443,7 @@ const Parser = struct { |
| 2443 | 2443 | .r_paren => { |
| 2444 | 2444 | const span = try p.listToSpan(param_list.items); |
| 2445 | 2445 | break :res try p.addNode(.{ |
| 2446 | .tag = .Call, | |
| 2446 | .tag = .call, | |
| 2447 | 2447 | .main_token = lparen, |
| 2448 | 2448 | .data = .{ |
| 2449 | 2449 | .lhs = res, |
| ... | ... | @@ -2518,7 +2518,7 @@ const Parser = struct { |
| 2518 | 2518 | fn parsePrimaryTypeExpr(p: *Parser) !Node.Index { |
| 2519 | 2519 | switch (p.token_tags[p.tok_i]) { |
| 2520 | 2520 | .char_literal => return p.addNode(.{ |
| 2521 | .tag = .CharLiteral, | |
| 2521 | .tag = .char_literal, | |
| 2522 | 2522 | .main_token = p.nextToken(), |
| 2523 | 2523 | .data = .{ |
| 2524 | 2524 | .lhs = undefined, |
| ... | ... | @@ -2526,7 +2526,7 @@ const Parser = struct { |
| 2526 | 2526 | }, |
| 2527 | 2527 | }), |
| 2528 | 2528 | .integer_literal => return p.addNode(.{ |
| 2529 | .tag = .IntegerLiteral, | |
| 2529 | .tag = .integer_literal, | |
| 2530 | 2530 | .main_token = p.nextToken(), |
| 2531 | 2531 | .data = .{ |
| 2532 | 2532 | .lhs = undefined, |
| ... | ... | @@ -2534,7 +2534,7 @@ const Parser = struct { |
| 2534 | 2534 | }, |
| 2535 | 2535 | }), |
| 2536 | 2536 | .float_literal => return p.addNode(.{ |
| 2537 | .tag = .FloatLiteral, | |
| 2537 | .tag = .float_literal, | |
| 2538 | 2538 | .main_token = p.nextToken(), |
| 2539 | 2539 | .data = .{ |
| 2540 | 2540 | .lhs = undefined, |
| ... | ... | @@ -2542,7 +2542,7 @@ const Parser = struct { |
| 2542 | 2542 | }, |
| 2543 | 2543 | }), |
| 2544 | 2544 | .keyword_false => return p.addNode(.{ |
| 2545 | .tag = .FalseLiteral, | |
| 2545 | .tag = .false_literal, | |
| 2546 | 2546 | .main_token = p.nextToken(), |
| 2547 | 2547 | .data = .{ |
| 2548 | 2548 | .lhs = undefined, |
| ... | ... | @@ -2550,7 +2550,7 @@ const Parser = struct { |
| 2550 | 2550 | }, |
| 2551 | 2551 | }), |
| 2552 | 2552 | .keyword_true => return p.addNode(.{ |
| 2553 | .tag = .TrueLiteral, | |
| 2553 | .tag = .true_literal, | |
| 2554 | 2554 | .main_token = p.nextToken(), |
| 2555 | 2555 | .data = .{ |
| 2556 | 2556 | .lhs = undefined, |
| ... | ... | @@ -2558,7 +2558,7 @@ const Parser = struct { |
| 2558 | 2558 | }, |
| 2559 | 2559 | }), |
| 2560 | 2560 | .keyword_null => return p.addNode(.{ |
| 2561 | .tag = .NullLiteral, | |
| 2561 | .tag = .null_literal, | |
| 2562 | 2562 | .main_token = p.nextToken(), |
| 2563 | 2563 | .data = .{ |
| 2564 | 2564 | .lhs = undefined, |
| ... | ... | @@ -2566,7 +2566,7 @@ const Parser = struct { |
| 2566 | 2566 | }, |
| 2567 | 2567 | }), |
| 2568 | 2568 | .keyword_undefined => return p.addNode(.{ |
| 2569 | .tag = .UndefinedLiteral, | |
| 2569 | .tag = .undefined_literal, | |
| 2570 | 2570 | .main_token = p.nextToken(), |
| 2571 | 2571 | .data = .{ |
| 2572 | 2572 | .lhs = undefined, |
| ... | ... | @@ -2574,7 +2574,7 @@ const Parser = struct { |
| 2574 | 2574 | }, |
| 2575 | 2575 | }), |
| 2576 | 2576 | .keyword_unreachable => return p.addNode(.{ |
| 2577 | .tag = .UnreachableLiteral, | |
| 2577 | .tag = .unreachable_literal, | |
| 2578 | 2578 | .main_token = p.nextToken(), |
| 2579 | 2579 | .data = .{ |
| 2580 | 2580 | .lhs = undefined, |
| ... | ... | @@ -2582,7 +2582,7 @@ const Parser = struct { |
| 2582 | 2582 | }, |
| 2583 | 2583 | }), |
| 2584 | 2584 | .keyword_anyframe => return p.addNode(.{ |
| 2585 | .tag = .AnyFrameLiteral, | |
| 2585 | .tag = .anyframe_literal, | |
| 2586 | 2586 | .main_token = p.nextToken(), |
| 2587 | 2587 | .data = .{ |
| 2588 | 2588 | .lhs = undefined, |
| ... | ... | @@ -2592,7 +2592,7 @@ const Parser = struct { |
| 2592 | 2592 | .string_literal => { |
| 2593 | 2593 | const main_token = p.nextToken(); |
| 2594 | 2594 | return p.addNode(.{ |
| 2595 | .tag = .StringLiteral, | |
| 2595 | .tag = .string_literal, | |
| 2596 | 2596 | .main_token = main_token, |
| 2597 | 2597 | .data = .{ |
| 2598 | 2598 | .lhs = main_token, |
| ... | ... | @@ -2620,7 +2620,7 @@ const Parser = struct { |
| 2620 | 2620 | => return p.parseContainerDeclAuto(), |
| 2621 | 2621 | |
| 2622 | 2622 | .keyword_comptime => return p.addNode(.{ |
| 2623 | .tag = .Comptime, | |
| 2623 | .tag = .@"comptime", | |
| 2624 | 2624 | .main_token = p.nextToken(), |
| 2625 | 2625 | .data = .{ |
| 2626 | 2626 | .lhs = try p.expectTypeExpr(), |
| ... | ... | @@ -2633,7 +2633,7 @@ const Parser = struct { |
| 2633 | 2633 | p.tok_i += 1; |
| 2634 | 2634 | } |
| 2635 | 2635 | return p.addNode(.{ |
| 2636 | .tag = .StringLiteral, | |
| 2636 | .tag = .string_literal, | |
| 2637 | 2637 | .main_token = first_line, |
| 2638 | 2638 | .data = .{ |
| 2639 | 2639 | .lhs = first_line, |
| ... | ... | @@ -2662,7 +2662,7 @@ const Parser = struct { |
| 2662 | 2662 | return p.parseWhileTypeExpr(); |
| 2663 | 2663 | }, |
| 2664 | 2664 | else => return p.addNode(.{ |
| 2665 | .tag = .Identifier, | |
| 2665 | .tag = .identifier, | |
| 2666 | 2666 | .main_token = p.nextToken(), |
| 2667 | 2667 | .data = .{ |
| 2668 | 2668 | .lhs = undefined, |
| ... | ... | @@ -2671,7 +2671,7 @@ const Parser = struct { |
| 2671 | 2671 | }), |
| 2672 | 2672 | }, |
| 2673 | 2673 | else => return p.addNode(.{ |
| 2674 | .tag = .Identifier, | |
| 2674 | .tag = .identifier, | |
| 2675 | 2675 | .main_token = p.nextToken(), |
| 2676 | 2676 | .data = .{ |
| 2677 | 2677 | .lhs = undefined, |
| ... | ... | @@ -2681,7 +2681,7 @@ const Parser = struct { |
| 2681 | 2681 | }, |
| 2682 | 2682 | .period => switch (p.token_tags[p.tok_i + 1]) { |
| 2683 | 2683 | .identifier => return p.addNode(.{ |
| 2684 | .tag = .EnumLiteral, | |
| 2684 | .tag = .enum_literal, | |
| 2685 | 2685 | .data = .{ |
| 2686 | 2686 | .lhs = p.nextToken(), // dot |
| 2687 | 2687 | .rhs = undefined, |
| ... | ... | @@ -2697,7 +2697,7 @@ const Parser = struct { |
| 2697 | 2697 | |
| 2698 | 2698 | if (p.eatToken(.r_brace)) |_| { |
| 2699 | 2699 | return p.addNode(.{ |
| 2700 | .tag = .StructInitDotTwo, | |
| 2700 | .tag = .struct_init_dot_two, | |
| 2701 | 2701 | .main_token = lbrace, |
| 2702 | 2702 | .data = .{ |
| 2703 | 2703 | .lhs = 0, |
| ... | ... | @@ -2710,7 +2710,7 @@ const Parser = struct { |
| 2710 | 2710 | const comma_one = p.eatToken(.comma); |
| 2711 | 2711 | if (p.eatToken(.r_brace)) |_| { |
| 2712 | 2712 | return p.addNode(.{ |
| 2713 | .tag = if (comma_one != null) .StructInitDotTwoComma else .StructInitDotTwo, | |
| 2713 | .tag = if (comma_one != null) .struct_init_dot_two_comma else .struct_init_dot_two, | |
| 2714 | 2714 | .main_token = lbrace, |
| 2715 | 2715 | .data = .{ |
| 2716 | 2716 | .lhs = field_init_one, |
| ... | ... | @@ -2727,7 +2727,7 @@ const Parser = struct { |
| 2727 | 2727 | const comma_two = p.eatToken(.comma); |
| 2728 | 2728 | if (p.eatToken(.r_brace)) |_| { |
| 2729 | 2729 | return p.addNode(.{ |
| 2730 | .tag = if (comma_two != null) .StructInitDotTwoComma else .StructInitDotTwo, | |
| 2730 | .tag = if (comma_two != null) .struct_init_dot_two_comma else .struct_init_dot_two, | |
| 2731 | 2731 | .main_token = lbrace, |
| 2732 | 2732 | .data = .{ |
| 2733 | 2733 | .lhs = field_init_one, |
| ... | ... | @@ -2778,7 +2778,7 @@ const Parser = struct { |
| 2778 | 2778 | const span = try p.listToSpan(init_list.items); |
| 2779 | 2779 | const trailing_comma = p.token_tags[p.tok_i - 2] == .comma; |
| 2780 | 2780 | return p.addNode(.{ |
| 2781 | .tag = if (trailing_comma) .StructInitDotComma else .StructInitDot, | |
| 2781 | .tag = if (trailing_comma) .struct_init_dot_comma else .struct_init_dot, | |
| 2782 | 2782 | .main_token = lbrace, |
| 2783 | 2783 | .data = .{ |
| 2784 | 2784 | .lhs = span.start, |
| ... | ... | @@ -2791,7 +2791,7 @@ const Parser = struct { |
| 2791 | 2791 | const comma_one = p.eatToken(.comma); |
| 2792 | 2792 | if (p.eatToken(.r_brace)) |_| { |
| 2793 | 2793 | return p.addNode(.{ |
| 2794 | .tag = if (comma_one != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo, | |
| 2794 | .tag = if (comma_one != null) .array_init_dot_two_comma else .array_init_dot_two, | |
| 2795 | 2795 | .main_token = lbrace, |
| 2796 | 2796 | .data = .{ |
| 2797 | 2797 | .lhs = elem_init_one, |
| ... | ... | @@ -2808,7 +2808,7 @@ const Parser = struct { |
| 2808 | 2808 | const comma_two = p.eatToken(.comma); |
| 2809 | 2809 | if (p.eatToken(.r_brace)) |_| { |
| 2810 | 2810 | return p.addNode(.{ |
| 2811 | .tag = if (comma_two != null) .ArrayInitDotTwoComma else .ArrayInitDotTwo, | |
| 2811 | .tag = if (comma_two != null) .array_init_dot_two_comma else .array_init_dot_two, | |
| 2812 | 2812 | .main_token = lbrace, |
| 2813 | 2813 | .data = .{ |
| 2814 | 2814 | .lhs = elem_init_one, |
| ... | ... | @@ -2858,7 +2858,7 @@ const Parser = struct { |
| 2858 | 2858 | } |
| 2859 | 2859 | const span = try p.listToSpan(init_list.items); |
| 2860 | 2860 | return p.addNode(.{ |
| 2861 | .tag = if (p.token_tags[p.tok_i - 2] == .comma) .ArrayInitDotComma else .ArrayInitDot, | |
| 2861 | .tag = if (p.token_tags[p.tok_i - 2] == .comma) .array_init_dot_comma else .array_init_dot, | |
| 2862 | 2862 | .main_token = lbrace, |
| 2863 | 2863 | .data = .{ |
| 2864 | 2864 | .lhs = span.start, |
| ... | ... | @@ -2875,7 +2875,7 @@ const Parser = struct { |
| 2875 | 2875 | |
| 2876 | 2876 | if (p.eatToken(.r_brace)) |rbrace| { |
| 2877 | 2877 | return p.addNode(.{ |
| 2878 | .tag = .ErrorSetDecl, | |
| 2878 | .tag = .error_set_decl, | |
| 2879 | 2879 | .main_token = error_token, |
| 2880 | 2880 | .data = .{ |
| 2881 | 2881 | .lhs = undefined, |
| ... | ... | @@ -2913,7 +2913,7 @@ const Parser = struct { |
| 2913 | 2913 | } |
| 2914 | 2914 | } |
| 2915 | 2915 | return p.addNode(.{ |
| 2916 | .tag = .ErrorSetDecl, | |
| 2916 | .tag = .error_set_decl, | |
| 2917 | 2917 | .main_token = error_token, |
| 2918 | 2918 | .data = .{ |
| 2919 | 2919 | .lhs = undefined, |
| ... | ... | @@ -2922,7 +2922,7 @@ const Parser = struct { |
| 2922 | 2922 | }); |
| 2923 | 2923 | }, |
| 2924 | 2924 | else => return p.addNode(.{ |
| 2925 | .tag = .ErrorValue, | |
| 2925 | .tag = .error_value, | |
| 2926 | 2926 | .main_token = p.nextToken(), |
| 2927 | 2927 | .data = .{ |
| 2928 | 2928 | .lhs = try p.expectToken(.period), |
| ... | ... | @@ -2931,7 +2931,7 @@ const Parser = struct { |
| 2931 | 2931 | }), |
| 2932 | 2932 | }, |
| 2933 | 2933 | .l_paren => return p.addNode(.{ |
| 2934 | .tag = .GroupedExpression, | |
| 2934 | .tag = .grouped_expression, | |
| 2935 | 2935 | .main_token = p.nextToken(), |
| 2936 | 2936 | .data = .{ |
| 2937 | 2937 | .lhs = try p.expectExpr(), |
| ... | ... | @@ -2962,7 +2962,7 @@ const Parser = struct { |
| 2962 | 2962 | const then_expr = try p.expectExpr(); |
| 2963 | 2963 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2964 | 2964 | return p.addNode(.{ |
| 2965 | .tag = .ForSimple, | |
| 2965 | .tag = .for_simple, | |
| 2966 | 2966 | .main_token = for_token, |
| 2967 | 2967 | .data = .{ |
| 2968 | 2968 | .lhs = array_expr, |
| ... | ... | @@ -2972,7 +2972,7 @@ const Parser = struct { |
| 2972 | 2972 | }; |
| 2973 | 2973 | const else_expr = try p.expectTypeExpr(); |
| 2974 | 2974 | return p.addNode(.{ |
| 2975 | .tag = .For, | |
| 2975 | .tag = .@"for", | |
| 2976 | 2976 | .main_token = for_token, |
| 2977 | 2977 | .data = .{ |
| 2978 | 2978 | .lhs = array_expr, |
| ... | ... | @@ -2998,7 +2998,7 @@ const Parser = struct { |
| 2998 | 2998 | const else_token = p.eatToken(.keyword_else) orelse { |
| 2999 | 2999 | if (cont_expr == 0) { |
| 3000 | 3000 | return p.addNode(.{ |
| 3001 | .tag = .WhileSimple, | |
| 3001 | .tag = .while_simple, | |
| 3002 | 3002 | .main_token = while_token, |
| 3003 | 3003 | .data = .{ |
| 3004 | 3004 | .lhs = condition, |
| ... | ... | @@ -3007,7 +3007,7 @@ const Parser = struct { |
| 3007 | 3007 | }); |
| 3008 | 3008 | } else { |
| 3009 | 3009 | return p.addNode(.{ |
| 3010 | .tag = .WhileCont, | |
| 3010 | .tag = .while_cont, | |
| 3011 | 3011 | .main_token = while_token, |
| 3012 | 3012 | .data = .{ |
| 3013 | 3013 | .lhs = condition, |
| ... | ... | @@ -3022,7 +3022,7 @@ const Parser = struct { |
| 3022 | 3022 | const else_payload = try p.parsePayload(); |
| 3023 | 3023 | const else_expr = try p.expectTypeExpr(); |
| 3024 | 3024 | return p.addNode(.{ |
| 3025 | .tag = .While, | |
| 3025 | .tag = .@"while", | |
| 3026 | 3026 | .main_token = while_token, |
| 3027 | 3027 | .data = .{ |
| 3028 | 3028 | .lhs = condition, |
| ... | ... | @@ -3047,7 +3047,7 @@ const Parser = struct { |
| 3047 | 3047 | _ = try p.expectToken(.r_brace); |
| 3048 | 3048 | |
| 3049 | 3049 | return p.addNode(.{ |
| 3050 | .tag = if (trailing_comma) .SwitchComma else .Switch, | |
| 3050 | .tag = if (trailing_comma) .switch_comma else .@"switch", | |
| 3051 | 3051 | .main_token = switch_token, |
| 3052 | 3052 | .data = .{ |
| 3053 | 3053 | .lhs = expr_node, |
| ... | ... | @@ -3074,7 +3074,7 @@ const Parser = struct { |
| 3074 | 3074 | |
| 3075 | 3075 | if (p.eatToken(.r_paren)) |rparen| { |
| 3076 | 3076 | return p.addNode(.{ |
| 3077 | .tag = .AsmSimple, | |
| 3077 | .tag = .asm_simple, | |
| 3078 | 3078 | .main_token = asm_token, |
| 3079 | 3079 | .data = .{ |
| 3080 | 3080 | .lhs = template, |
| ... | ... | @@ -3140,7 +3140,7 @@ const Parser = struct { |
| 3140 | 3140 | const rparen = try p.expectToken(.r_paren); |
| 3141 | 3141 | const span = try p.listToSpan(list.items); |
| 3142 | 3142 | return p.addNode(.{ |
| 3143 | .tag = .Asm, | |
| 3143 | .tag = .@"asm", | |
| 3144 | 3144 | .main_token = asm_token, |
| 3145 | 3145 | .data = .{ |
| 3146 | 3146 | .lhs = template, |
| ... | ... | @@ -3170,7 +3170,7 @@ const Parser = struct { |
| 3170 | 3170 | }; |
| 3171 | 3171 | const rparen = try p.expectToken(.r_paren); |
| 3172 | 3172 | return p.addNode(.{ |
| 3173 | .tag = .AsmOutput, | |
| 3173 | .tag = .asm_output, | |
| 3174 | 3174 | .main_token = identifier, |
| 3175 | 3175 | .data = .{ |
| 3176 | 3176 | .lhs = type_expr, |
| ... | ... | @@ -3189,7 +3189,7 @@ const Parser = struct { |
| 3189 | 3189 | const expr = try p.expectExpr(); |
| 3190 | 3190 | const rparen = try p.expectToken(.r_paren); |
| 3191 | 3191 | return p.addNode(.{ |
| 3192 | .tag = .AsmInput, | |
| 3192 | .tag = .asm_input, | |
| 3193 | 3193 | .main_token = identifier, |
| 3194 | 3194 | .data = .{ |
| 3195 | 3195 | .lhs = expr, |
| ... | ... | @@ -3336,7 +3336,7 @@ const Parser = struct { |
| 3336 | 3336 | const arrow_token = try p.expectToken(.equal_angle_bracket_right); |
| 3337 | 3337 | _ = try p.parsePtrPayload(); |
| 3338 | 3338 | return p.addNode(.{ |
| 3339 | .tag = .SwitchCaseOne, | |
| 3339 | .tag = .switch_case_one, | |
| 3340 | 3340 | .main_token = arrow_token, |
| 3341 | 3341 | .data = .{ |
| 3342 | 3342 | .lhs = 0, |
| ... | ... | @@ -3350,7 +3350,7 @@ const Parser = struct { |
| 3350 | 3350 | if (p.eatToken(.equal_angle_bracket_right)) |arrow_token| { |
| 3351 | 3351 | _ = try p.parsePtrPayload(); |
| 3352 | 3352 | return p.addNode(.{ |
| 3353 | .tag = .SwitchCaseOne, | |
| 3353 | .tag = .switch_case_one, | |
| 3354 | 3354 | .main_token = arrow_token, |
| 3355 | 3355 | .data = .{ |
| 3356 | 3356 | .lhs = first_item, |
| ... | ... | @@ -3372,7 +3372,7 @@ const Parser = struct { |
| 3372 | 3372 | const arrow_token = try p.expectToken(.equal_angle_bracket_right); |
| 3373 | 3373 | _ = try p.parsePtrPayload(); |
| 3374 | 3374 | return p.addNode(.{ |
| 3375 | .tag = .SwitchCase, | |
| 3375 | .tag = .switch_case, | |
| 3376 | 3376 | .main_token = arrow_token, |
| 3377 | 3377 | .data = .{ |
| 3378 | 3378 | .lhs = try p.addExtra(Node.SubRange{ |
| ... | ... | @@ -3391,7 +3391,7 @@ const Parser = struct { |
| 3391 | 3391 | |
| 3392 | 3392 | if (p.eatToken(.ellipsis3)) |token| { |
| 3393 | 3393 | return p.addNode(.{ |
| 3394 | .tag = .SwitchRange, | |
| 3394 | .tag = .switch_range, | |
| 3395 | 3395 | .main_token = token, |
| 3396 | 3396 | .data = .{ |
| 3397 | 3397 | .lhs = expr, |
| ... | ... | @@ -3485,7 +3485,7 @@ const Parser = struct { |
| 3485 | 3485 | if (end_expr == 0) { |
| 3486 | 3486 | _ = try p.expectToken(.r_bracket); |
| 3487 | 3487 | return p.addNode(.{ |
| 3488 | .tag = .SliceOpen, | |
| 3488 | .tag = .slice_open, | |
| 3489 | 3489 | .main_token = lbracket, |
| 3490 | 3490 | .data = .{ |
| 3491 | 3491 | .lhs = lhs, |
| ... | ... | @@ -3497,7 +3497,7 @@ const Parser = struct { |
| 3497 | 3497 | const sentinel = try p.parseExpr(); |
| 3498 | 3498 | _ = try p.expectToken(.r_bracket); |
| 3499 | 3499 | return p.addNode(.{ |
| 3500 | .tag = .SliceSentinel, | |
| 3500 | .tag = .slice_sentinel, | |
| 3501 | 3501 | .main_token = lbracket, |
| 3502 | 3502 | .data = .{ |
| 3503 | 3503 | .lhs = lhs, |
| ... | ... | @@ -3511,7 +3511,7 @@ const Parser = struct { |
| 3511 | 3511 | } else { |
| 3512 | 3512 | _ = try p.expectToken(.r_bracket); |
| 3513 | 3513 | return p.addNode(.{ |
| 3514 | .tag = .Slice, | |
| 3514 | .tag = .slice, | |
| 3515 | 3515 | .main_token = lbracket, |
| 3516 | 3516 | .data = .{ |
| 3517 | 3517 | .lhs = lhs, |
| ... | ... | @@ -3525,7 +3525,7 @@ const Parser = struct { |
| 3525 | 3525 | } |
| 3526 | 3526 | _ = try p.expectToken(.r_bracket); |
| 3527 | 3527 | return p.addNode(.{ |
| 3528 | .tag = .ArrayAccess, | |
| 3528 | .tag = .array_access, | |
| 3529 | 3529 | .main_token = lbracket, |
| 3530 | 3530 | .data = .{ |
| 3531 | 3531 | .lhs = lhs, |
| ... | ... | @@ -3534,7 +3534,7 @@ const Parser = struct { |
| 3534 | 3534 | }); |
| 3535 | 3535 | }, |
| 3536 | 3536 | .period_asterisk => return p.addNode(.{ |
| 3537 | .tag = .Deref, | |
| 3537 | .tag = .deref, | |
| 3538 | 3538 | .main_token = p.nextToken(), |
| 3539 | 3539 | .data = .{ |
| 3540 | 3540 | .lhs = lhs, |
| ... | ... | @@ -3545,7 +3545,7 @@ const Parser = struct { |
| 3545 | 3545 | const period_asterisk = p.nextToken(); |
| 3546 | 3546 | try p.warn(.{ .AsteriskAfterPointerDereference = .{ .token = period_asterisk } }); |
| 3547 | 3547 | return p.addNode(.{ |
| 3548 | .tag = .Deref, | |
| 3548 | .tag = .deref, | |
| 3549 | 3549 | .main_token = period_asterisk, |
| 3550 | 3550 | .data = .{ |
| 3551 | 3551 | .lhs = lhs, |
| ... | ... | @@ -3555,7 +3555,7 @@ const Parser = struct { |
| 3555 | 3555 | }, |
| 3556 | 3556 | .period => switch (p.token_tags[p.tok_i + 1]) { |
| 3557 | 3557 | .identifier => return p.addNode(.{ |
| 3558 | .tag = .FieldAccess, | |
| 3558 | .tag = .field_access, | |
| 3559 | 3559 | .main_token = p.nextToken(), |
| 3560 | 3560 | .data = .{ |
| 3561 | 3561 | .lhs = lhs, |
| ... | ... | @@ -3563,7 +3563,7 @@ const Parser = struct { |
| 3563 | 3563 | }, |
| 3564 | 3564 | }), |
| 3565 | 3565 | .question_mark => return p.addNode(.{ |
| 3566 | .tag = .UnwrapOptional, | |
| 3566 | .tag = .unwrap_optional, | |
| 3567 | 3567 | .main_token = p.nextToken(), |
| 3568 | 3568 | .data = .{ |
| 3569 | 3569 | .lhs = lhs, |
| ... | ... | @@ -3613,8 +3613,8 @@ const Parser = struct { |
| 3613 | 3613 | _ = try p.expectToken(.r_brace); |
| 3614 | 3614 | return p.addNode(.{ |
| 3615 | 3615 | .tag = switch (members.trailing_comma) { |
| 3616 | true => .TaggedUnionEnumTagComma, | |
| 3617 | false => .TaggedUnionEnumTag, | |
| 3616 | true => .tagged_union_enum_tag_comma, | |
| 3617 | false => .tagged_union_enum_tag, | |
| 3618 | 3618 | }, |
| 3619 | 3619 | .main_token = main_token, |
| 3620 | 3620 | .data = .{ |
| ... | ... | @@ -3631,8 +3631,8 @@ const Parser = struct { |
| 3631 | 3631 | if (members.len <= 2) { |
| 3632 | 3632 | return p.addNode(.{ |
| 3633 | 3633 | .tag = switch (members.trailing_comma) { |
| 3634 | true => .TaggedUnionTwoComma, | |
| 3635 | false => .TaggedUnionTwo, | |
| 3634 | true => .tagged_union_two_comma, | |
| 3635 | false => .tagged_union_two, | |
| 3636 | 3636 | }, |
| 3637 | 3637 | .main_token = main_token, |
| 3638 | 3638 | .data = .{ |
| ... | ... | @@ -3644,8 +3644,8 @@ const Parser = struct { |
| 3644 | 3644 | const span = try members.toSpan(p); |
| 3645 | 3645 | return p.addNode(.{ |
| 3646 | 3646 | .tag = switch (members.trailing_comma) { |
| 3647 | true => .TaggedUnionComma, | |
| 3648 | false => .TaggedUnion, | |
| 3647 | true => .tagged_union_comma, | |
| 3648 | false => .tagged_union, | |
| 3649 | 3649 | }, |
| 3650 | 3650 | .main_token = main_token, |
| 3651 | 3651 | .data = .{ |
| ... | ... | @@ -3673,8 +3673,8 @@ const Parser = struct { |
| 3673 | 3673 | if (members.len <= 2) { |
| 3674 | 3674 | return p.addNode(.{ |
| 3675 | 3675 | .tag = switch (members.trailing_comma) { |
| 3676 | true => .ContainerDeclTwoComma, | |
| 3677 | false => .ContainerDeclTwo, | |
| 3676 | true => .container_decl_two_comma, | |
| 3677 | false => .container_decl_two, | |
| 3678 | 3678 | }, |
| 3679 | 3679 | .main_token = main_token, |
| 3680 | 3680 | .data = .{ |
| ... | ... | @@ -3686,8 +3686,8 @@ const Parser = struct { |
| 3686 | 3686 | const span = try members.toSpan(p); |
| 3687 | 3687 | return p.addNode(.{ |
| 3688 | 3688 | .tag = switch (members.trailing_comma) { |
| 3689 | true => .ContainerDeclComma, | |
| 3690 | false => .ContainerDecl, | |
| 3689 | true => .container_decl_comma, | |
| 3690 | false => .container_decl, | |
| 3691 | 3691 | }, |
| 3692 | 3692 | .main_token = main_token, |
| 3693 | 3693 | .data = .{ |
| ... | ... | @@ -3700,8 +3700,8 @@ const Parser = struct { |
| 3700 | 3700 | const span = try members.toSpan(p); |
| 3701 | 3701 | return p.addNode(.{ |
| 3702 | 3702 | .tag = switch (members.trailing_comma) { |
| 3703 | true => .ContainerDeclArgComma, | |
| 3704 | false => .ContainerDeclArg, | |
| 3703 | true => .container_decl_arg_comma, | |
| 3704 | false => .container_decl_arg, | |
| 3705 | 3705 | }, |
| 3706 | 3706 | .main_token = main_token, |
| 3707 | 3707 | .data = .{ |
| ... | ... | @@ -3860,7 +3860,7 @@ const Parser = struct { |
| 3860 | 3860 | }); |
| 3861 | 3861 | // Pretend this was an identifier so we can continue parsing. |
| 3862 | 3862 | return p.addNode(.{ |
| 3863 | .tag = .Identifier, | |
| 3863 | .tag = .identifier, | |
| 3864 | 3864 | .main_token = builtin_token, |
| 3865 | 3865 | .data = .{ |
| 3866 | 3866 | .lhs = undefined, |
| ... | ... | @@ -3870,7 +3870,7 @@ const Parser = struct { |
| 3870 | 3870 | }; |
| 3871 | 3871 | if (p.eatToken(.r_paren)) |_| { |
| 3872 | 3872 | return p.addNode(.{ |
| 3873 | .tag = .BuiltinCallTwo, | |
| 3873 | .tag = .builtin_call_two, | |
| 3874 | 3874 | .main_token = builtin_token, |
| 3875 | 3875 | .data = .{ |
| 3876 | 3876 | .lhs = 0, |
| ... | ... | @@ -3883,7 +3883,7 @@ const Parser = struct { |
| 3883 | 3883 | .comma => { |
| 3884 | 3884 | if (p.eatToken(.r_paren)) |_| { |
| 3885 | 3885 | return p.addNode(.{ |
| 3886 | .tag = .BuiltinCallTwoComma, | |
| 3886 | .tag = .builtin_call_two_comma, | |
| 3887 | 3887 | .main_token = builtin_token, |
| 3888 | 3888 | .data = .{ |
| 3889 | 3889 | .lhs = param_one, |
| ... | ... | @@ -3893,7 +3893,7 @@ const Parser = struct { |
| 3893 | 3893 | } |
| 3894 | 3894 | }, |
| 3895 | 3895 | .r_paren => return p.addNode(.{ |
| 3896 | .tag = .BuiltinCallTwo, | |
| 3896 | .tag = .builtin_call_two, | |
| 3897 | 3897 | .main_token = builtin_token, |
| 3898 | 3898 | .data = .{ |
| 3899 | 3899 | .lhs = param_one, |
| ... | ... | @@ -3914,7 +3914,7 @@ const Parser = struct { |
| 3914 | 3914 | .comma => { |
| 3915 | 3915 | if (p.eatToken(.r_paren)) |_| { |
| 3916 | 3916 | return p.addNode(.{ |
| 3917 | .tag = .BuiltinCallTwoComma, | |
| 3917 | .tag = .builtin_call_two_comma, | |
| 3918 | 3918 | .main_token = builtin_token, |
| 3919 | 3919 | .data = .{ |
| 3920 | 3920 | .lhs = param_one, |
| ... | ... | @@ -3924,7 +3924,7 @@ const Parser = struct { |
| 3924 | 3924 | } |
| 3925 | 3925 | }, |
| 3926 | 3926 | .r_paren => return p.addNode(.{ |
| 3927 | .tag = .BuiltinCallTwo, | |
| 3927 | .tag = .builtin_call_two, | |
| 3928 | 3928 | .main_token = builtin_token, |
| 3929 | 3929 | .data = .{ |
| 3930 | 3930 | .lhs = param_one, |
| ... | ... | @@ -3954,7 +3954,7 @@ const Parser = struct { |
| 3954 | 3954 | if (p.eatToken(.r_paren)) |_| { |
| 3955 | 3955 | const params = try p.listToSpan(list.items); |
| 3956 | 3956 | return p.addNode(.{ |
| 3957 | .tag = .BuiltinCallComma, | |
| 3957 | .tag = .builtin_call_comma, | |
| 3958 | 3958 | .main_token = builtin_token, |
| 3959 | 3959 | .data = .{ |
| 3960 | 3960 | .lhs = params.start, |
| ... | ... | @@ -3967,7 +3967,7 @@ const Parser = struct { |
| 3967 | 3967 | .r_paren => { |
| 3968 | 3968 | const params = try p.listToSpan(list.items); |
| 3969 | 3969 | return p.addNode(.{ |
| 3970 | .tag = .BuiltinCall, | |
| 3970 | .tag = .builtin_call, | |
| 3971 | 3971 | .main_token = builtin_token, |
| 3972 | 3972 | .data = .{ |
| 3973 | 3973 | .lhs = params.start, |
| ... | ... | @@ -3993,7 +3993,7 @@ const Parser = struct { |
| 3993 | 3993 | .string_literal => { |
| 3994 | 3994 | const main_token = p.nextToken(); |
| 3995 | 3995 | return p.addNode(.{ |
| 3996 | .tag = .StringLiteral, | |
| 3996 | .tag = .string_literal, | |
| 3997 | 3997 | .main_token = main_token, |
| 3998 | 3998 | .data = .{ |
| 3999 | 3999 | .lhs = main_token, |
| ... | ... | @@ -4007,7 +4007,7 @@ const Parser = struct { |
| 4007 | 4007 | p.tok_i += 1; |
| 4008 | 4008 | } |
| 4009 | 4009 | return p.addNode(.{ |
| 4010 | .tag = .StringLiteral, | |
| 4010 | .tag = .string_literal, | |
| 4011 | 4011 | .main_token = first_line, |
| 4012 | 4012 | .data = .{ |
| 4013 | 4013 | .lhs = first_line, |
| ... | ... | @@ -4029,7 +4029,7 @@ const Parser = struct { |
| 4029 | 4029 | |
| 4030 | 4030 | fn expectIntegerLiteral(p: *Parser) !Node.Index { |
| 4031 | 4031 | return p.addNode(.{ |
| 4032 | .tag = .IntegerLiteral, | |
| 4032 | .tag = .integer_literal, | |
| 4033 | 4033 | .main_token = try p.expectToken(.integer_literal), |
| 4034 | 4034 | .data = .{ |
| 4035 | 4035 | .lhs = undefined, |
| ... | ... | @@ -4050,7 +4050,7 @@ const Parser = struct { |
| 4050 | 4050 | if (then_expr == 0) return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } }); |
| 4051 | 4051 | |
| 4052 | 4052 | const else_token = p.eatToken(.keyword_else) orelse return p.addNode(.{ |
| 4053 | .tag = .IfSimple, | |
| 4053 | .tag = .if_simple, | |
| 4054 | 4054 | .main_token = if_token, |
| 4055 | 4055 | .data = .{ |
| 4056 | 4056 | .lhs = condition, |
| ... | ... | @@ -4062,7 +4062,7 @@ const Parser = struct { |
| 4062 | 4062 | if (else_expr == 0) return p.fail(.{ .InvalidToken = .{ .token = p.tok_i } }); |
| 4063 | 4063 | |
| 4064 | 4064 | return p.addNode(.{ |
| 4065 | .tag = .If, | |
| 4065 | .tag = .@"if", | |
| 4066 | 4066 | .main_token = if_token, |
| 4067 | 4067 | .data = .{ |
| 4068 | 4068 | .lhs = condition, |
lib/std/zig/render.zig+228-228| ... | ... | @@ -96,7 +96,7 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 96 | 96 | const datas = tree.nodes.items(.data); |
| 97 | 97 | try renderDocComments(ais, tree, tree.firstToken(decl)); |
| 98 | 98 | switch (tree.nodes.items(.tag)[decl]) { |
| 99 | .FnDecl => { | |
| 99 | .fn_decl => { | |
| 100 | 100 | // Some examples: |
| 101 | 101 | // pub extern "foo" fn ... |
| 102 | 102 | // export fn ... |
| ... | ... | @@ -132,16 +132,16 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 132 | 132 | return renderToken(ais, tree, tree.lastToken(fn_proto) + 1, space); // semicolon |
| 133 | 133 | } |
| 134 | 134 | }, |
| 135 | .FnProtoSimple, | |
| 136 | .FnProtoMulti, | |
| 137 | .FnProtoOne, | |
| 138 | .FnProto, | |
| 135 | .fn_proto_simple, | |
| 136 | .fn_proto_multi, | |
| 137 | .fn_proto_one, | |
| 138 | .fn_proto, | |
| 139 | 139 | => { |
| 140 | 140 | try renderExpression(ais, tree, decl, .None); |
| 141 | 141 | return renderToken(ais, tree, tree.lastToken(decl) + 1, space); // semicolon |
| 142 | 142 | }, |
| 143 | 143 | |
| 144 | .UsingNamespace => { | |
| 144 | .@"usingnamespace" => { | |
| 145 | 145 | const main_token = main_tokens[decl]; |
| 146 | 146 | const expr = datas[decl].lhs; |
| 147 | 147 | if (main_token > 0 and token_tags[main_token - 1] == .keyword_pub) { |
| ... | ... | @@ -152,12 +152,12 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 152 | 152 | return renderToken(ais, tree, tree.lastToken(expr) + 1, space); // ; |
| 153 | 153 | }, |
| 154 | 154 | |
| 155 | .GlobalVarDecl => return renderVarDecl(ais, tree, tree.globalVarDecl(decl)), | |
| 156 | .LocalVarDecl => return renderVarDecl(ais, tree, tree.localVarDecl(decl)), | |
| 157 | .SimpleVarDecl => return renderVarDecl(ais, tree, tree.simpleVarDecl(decl)), | |
| 158 | .AlignedVarDecl => return renderVarDecl(ais, tree, tree.alignedVarDecl(decl)), | |
| 155 | .global_var_decl => return renderVarDecl(ais, tree, tree.globalVarDecl(decl)), | |
| 156 | .local_var_decl => return renderVarDecl(ais, tree, tree.localVarDecl(decl)), | |
| 157 | .simple_var_decl => return renderVarDecl(ais, tree, tree.simpleVarDecl(decl)), | |
| 158 | .aligned_var_decl => return renderVarDecl(ais, tree, tree.alignedVarDecl(decl)), | |
| 159 | 159 | |
| 160 | .TestDecl => { | |
| 160 | .test_decl => { | |
| 161 | 161 | const test_token = main_tokens[decl]; |
| 162 | 162 | try renderToken(ais, tree, test_token, .Space); |
| 163 | 163 | if (token_tags[test_token + 1] == .string_literal) { |
| ... | ... | @@ -166,12 +166,12 @@ fn renderMember(ais: *Ais, tree: ast.Tree, decl: ast.Node.Index, space: Space) E |
| 166 | 166 | try renderExpression(ais, tree, datas[decl].rhs, space); |
| 167 | 167 | }, |
| 168 | 168 | |
| 169 | .ContainerFieldInit => return renderContainerField(ais, tree, tree.containerFieldInit(decl), space), | |
| 170 | .ContainerFieldAlign => return renderContainerField(ais, tree, tree.containerFieldAlign(decl), space), | |
| 171 | .ContainerField => return renderContainerField(ais, tree, tree.containerField(decl), space), | |
| 172 | .Comptime => return renderExpression(ais, tree, decl, space), | |
| 169 | .container_field_init => return renderContainerField(ais, tree, tree.containerFieldInit(decl), space), | |
| 170 | .container_field_align => return renderContainerField(ais, tree, tree.containerFieldAlign(decl), space), | |
| 171 | .container_field => return renderContainerField(ais, tree, tree.containerField(decl), space), | |
| 172 | .@"comptime" => return renderExpression(ais, tree, decl, space), | |
| 173 | 173 | |
| 174 | .Root => unreachable, | |
| 174 | .root => unreachable, | |
| 175 | 175 | else => unreachable, |
| 176 | 176 | } |
| 177 | 177 | } |
| ... | ... | @@ -182,29 +182,29 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 182 | 182 | const node_tags = tree.nodes.items(.tag); |
| 183 | 183 | const datas = tree.nodes.items(.data); |
| 184 | 184 | switch (node_tags[node]) { |
| 185 | .Identifier, | |
| 186 | .IntegerLiteral, | |
| 187 | .FloatLiteral, | |
| 188 | .StringLiteral, | |
| 189 | .CharLiteral, | |
| 190 | .TrueLiteral, | |
| 191 | .FalseLiteral, | |
| 192 | .NullLiteral, | |
| 193 | .UnreachableLiteral, | |
| 194 | .UndefinedLiteral, | |
| 195 | .AnyFrameLiteral, | |
| 185 | .identifier, | |
| 186 | .integer_literal, | |
| 187 | .float_literal, | |
| 188 | .string_literal, | |
| 189 | .char_literal, | |
| 190 | .true_literal, | |
| 191 | .false_literal, | |
| 192 | .null_literal, | |
| 193 | .unreachable_literal, | |
| 194 | .undefined_literal, | |
| 195 | .anyframe_literal, | |
| 196 | 196 | => return renderToken(ais, tree, main_tokens[node], space), |
| 197 | 197 | |
| 198 | .ErrorValue => { | |
| 198 | .error_value => { | |
| 199 | 199 | try renderToken(ais, tree, main_tokens[node], .None); |
| 200 | 200 | try renderToken(ais, tree, main_tokens[node] + 1, .None); |
| 201 | 201 | return renderToken(ais, tree, main_tokens[node] + 2, space); |
| 202 | 202 | }, |
| 203 | 203 | |
| 204 | .AnyType => return renderToken(ais, tree, main_tokens[node], space), | |
| 204 | .@"anytype" => return renderToken(ais, tree, main_tokens[node], space), | |
| 205 | 205 | |
| 206 | .BlockTwo, | |
| 207 | .BlockTwoSemicolon, | |
| 206 | .block_two, | |
| 207 | .block_two_semicolon, | |
| 208 | 208 | => { |
| 209 | 209 | const statements = [2]ast.Node.Index{ datas[node].lhs, datas[node].rhs }; |
| 210 | 210 | if (datas[node].lhs == 0) { |
| ... | ... | @@ -215,14 +215,14 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 215 | 215 | return renderBlock(ais, tree, node, statements[0..2], space); |
| 216 | 216 | } |
| 217 | 217 | }, |
| 218 | .Block, | |
| 219 | .BlockSemicolon, | |
| 218 | .block, | |
| 219 | .block_semicolon, | |
| 220 | 220 | => { |
| 221 | 221 | const statements = tree.extra_data[datas[node].lhs..datas[node].rhs]; |
| 222 | 222 | return renderBlock(ais, tree, node, statements, space); |
| 223 | 223 | }, |
| 224 | 224 | |
| 225 | .ErrDefer => { | |
| 225 | .@"errdefer" => { | |
| 226 | 226 | const defer_token = main_tokens[node]; |
| 227 | 227 | const payload_token = datas[node].lhs; |
| 228 | 228 | const expr = datas[node].rhs; |
| ... | ... | @@ -236,20 +236,20 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 236 | 236 | return renderExpression(ais, tree, expr, space); |
| 237 | 237 | }, |
| 238 | 238 | |
| 239 | .Defer => { | |
| 239 | .@"defer" => { | |
| 240 | 240 | const defer_token = main_tokens[node]; |
| 241 | 241 | const expr = datas[node].rhs; |
| 242 | 242 | try renderToken(ais, tree, defer_token, .Space); |
| 243 | 243 | return renderExpression(ais, tree, expr, space); |
| 244 | 244 | }, |
| 245 | .Comptime, .Nosuspend => { | |
| 245 | .@"comptime", .@"nosuspend" => { | |
| 246 | 246 | const comptime_token = main_tokens[node]; |
| 247 | 247 | const block = datas[node].lhs; |
| 248 | 248 | try renderToken(ais, tree, comptime_token, .Space); |
| 249 | 249 | return renderExpression(ais, tree, block, space); |
| 250 | 250 | }, |
| 251 | 251 | |
| 252 | .Suspend => { | |
| 252 | .@"suspend" => { | |
| 253 | 253 | const suspend_token = main_tokens[node]; |
| 254 | 254 | const body = datas[node].lhs; |
| 255 | 255 | if (body != 0) { |
| ... | ... | @@ -260,7 +260,7 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 260 | 260 | } |
| 261 | 261 | }, |
| 262 | 262 | |
| 263 | .Catch => { | |
| 263 | .@"catch" => { | |
| 264 | 264 | const main_token = main_tokens[node]; |
| 265 | 265 | const fallback_first = tree.firstToken(datas[node].rhs); |
| 266 | 266 | |
| ... | ... | @@ -283,15 +283,15 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 283 | 283 | try renderExpression(ais, tree, datas[node].rhs, space); // fallback |
| 284 | 284 | }, |
| 285 | 285 | |
| 286 | .FieldAccess => { | |
| 286 | .field_access => { | |
| 287 | 287 | const field_access = datas[node]; |
| 288 | 288 | try renderExpression(ais, tree, field_access.lhs, .None); |
| 289 | 289 | try renderToken(ais, tree, main_tokens[node], .None); |
| 290 | 290 | return renderToken(ais, tree, field_access.rhs, space); |
| 291 | 291 | }, |
| 292 | 292 | |
| 293 | .ErrorUnion, | |
| 294 | .SwitchRange, | |
| 293 | .error_union, | |
| 294 | .switch_range, | |
| 295 | 295 | => { |
| 296 | 296 | const infix = datas[node]; |
| 297 | 297 | try renderExpression(ais, tree, infix.lhs, .None); |
| ... | ... | @@ -299,45 +299,45 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 299 | 299 | return renderExpression(ais, tree, infix.rhs, space); |
| 300 | 300 | }, |
| 301 | 301 | |
| 302 | .Add, | |
| 303 | .AddWrap, | |
| 304 | .ArrayCat, | |
| 305 | .ArrayMult, | |
| 306 | .Assign, | |
| 307 | .AssignBitAnd, | |
| 308 | .AssignBitOr, | |
| 309 | .AssignBitShiftLeft, | |
| 310 | .AssignBitShiftRight, | |
| 311 | .AssignBitXor, | |
| 312 | .AssignDiv, | |
| 313 | .AssignSub, | |
| 314 | .AssignSubWrap, | |
| 315 | .AssignMod, | |
| 316 | .AssignAdd, | |
| 317 | .AssignAddWrap, | |
| 318 | .AssignMul, | |
| 319 | .AssignMulWrap, | |
| 320 | .BangEqual, | |
| 321 | .BitAnd, | |
| 322 | .BitOr, | |
| 323 | .BitShiftLeft, | |
| 324 | .BitShiftRight, | |
| 325 | .BitXor, | |
| 326 | .BoolAnd, | |
| 327 | .BoolOr, | |
| 328 | .Div, | |
| 329 | .EqualEqual, | |
| 330 | .GreaterOrEqual, | |
| 331 | .GreaterThan, | |
| 332 | .LessOrEqual, | |
| 333 | .LessThan, | |
| 334 | .MergeErrorSets, | |
| 335 | .Mod, | |
| 336 | .Mul, | |
| 337 | .MulWrap, | |
| 338 | .Sub, | |
| 339 | .SubWrap, | |
| 340 | .OrElse, | |
| 302 | .add, | |
| 303 | .add_wrap, | |
| 304 | .array_cat, | |
| 305 | .array_mult, | |
| 306 | .assign, | |
| 307 | .assign_bit_and, | |
| 308 | .assign_bit_or, | |
| 309 | .assign_bit_shift_left, | |
| 310 | .assign_bit_shift_right, | |
| 311 | .assign_bit_xor, | |
| 312 | .assign_div, | |
| 313 | .assign_sub, | |
| 314 | .assign_sub_wrap, | |
| 315 | .assign_mod, | |
| 316 | .assign_add, | |
| 317 | .assign_add_wrap, | |
| 318 | .assign_mul, | |
| 319 | .assign_mul_wrap, | |
| 320 | .bang_equal, | |
| 321 | .bit_and, | |
| 322 | .bit_or, | |
| 323 | .bit_shift_left, | |
| 324 | .bit_shift_right, | |
| 325 | .bit_xor, | |
| 326 | .bool_and, | |
| 327 | .bool_or, | |
| 328 | .div, | |
| 329 | .equal_equal, | |
| 330 | .greater_or_equal, | |
| 331 | .greater_than, | |
| 332 | .less_or_equal, | |
| 333 | .less_than, | |
| 334 | .merge_error_sets, | |
| 335 | .mod, | |
| 336 | .mul, | |
| 337 | .mul_wrap, | |
| 338 | .sub, | |
| 339 | .sub_wrap, | |
| 340 | .@"orelse", | |
| 341 | 341 | => { |
| 342 | 342 | const infix = datas[node]; |
| 343 | 343 | try renderExpression(ais, tree, infix.lhs, .Space); |
| ... | ... | @@ -353,75 +353,75 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 353 | 353 | return renderExpression(ais, tree, infix.rhs, space); |
| 354 | 354 | }, |
| 355 | 355 | |
| 356 | .BitNot, | |
| 357 | .BoolNot, | |
| 358 | .Negation, | |
| 359 | .NegationWrap, | |
| 360 | .OptionalType, | |
| 361 | .AddressOf, | |
| 356 | .bit_not, | |
| 357 | .bool_not, | |
| 358 | .negation, | |
| 359 | .negation_wrap, | |
| 360 | .optional_type, | |
| 361 | .address_of, | |
| 362 | 362 | => { |
| 363 | 363 | try renderToken(ais, tree, main_tokens[node], .None); |
| 364 | 364 | return renderExpression(ais, tree, datas[node].lhs, space); |
| 365 | 365 | }, |
| 366 | 366 | |
| 367 | .Try, | |
| 368 | .Resume, | |
| 369 | .Await, | |
| 367 | .@"try", | |
| 368 | .@"resume", | |
| 369 | .@"await", | |
| 370 | 370 | => { |
| 371 | 371 | try renderToken(ais, tree, main_tokens[node], .Space); |
| 372 | 372 | return renderExpression(ais, tree, datas[node].lhs, space); |
| 373 | 373 | }, |
| 374 | 374 | |
| 375 | .ArrayType => return renderArrayType(ais, tree, tree.arrayType(node), space), | |
| 376 | .ArrayTypeSentinel => return renderArrayType(ais, tree, tree.arrayTypeSentinel(node), space), | |
| 375 | .array_type => return renderArrayType(ais, tree, tree.arrayType(node), space), | |
| 376 | .array_type_sentinel => return renderArrayType(ais, tree, tree.arrayTypeSentinel(node), space), | |
| 377 | 377 | |
| 378 | .PtrTypeAligned => return renderPtrType(ais, tree, tree.ptrTypeAligned(node), space), | |
| 379 | .PtrTypeSentinel => return renderPtrType(ais, tree, tree.ptrTypeSentinel(node), space), | |
| 380 | .PtrType => return renderPtrType(ais, tree, tree.ptrType(node), space), | |
| 381 | .PtrTypeBitRange => return renderPtrType(ais, tree, tree.ptrTypeBitRange(node), space), | |
| 378 | .ptr_type_aligned => return renderPtrType(ais, tree, tree.ptrTypeAligned(node), space), | |
| 379 | .ptr_type_sentinel => return renderPtrType(ais, tree, tree.ptrTypeSentinel(node), space), | |
| 380 | .ptr_type => return renderPtrType(ais, tree, tree.ptrType(node), space), | |
| 381 | .ptr_type_bit_range => return renderPtrType(ais, tree, tree.ptrTypeBitRange(node), space), | |
| 382 | 382 | |
| 383 | .ArrayInitOne, .ArrayInitOneComma => { | |
| 383 | .array_init_one, .array_init_one_comma => { | |
| 384 | 384 | var elements: [1]ast.Node.Index = undefined; |
| 385 | 385 | return renderArrayInit(ais, tree, tree.arrayInitOne(&elements, node), space); |
| 386 | 386 | }, |
| 387 | .ArrayInitDotTwo, .ArrayInitDotTwoComma => { | |
| 387 | .array_init_dot_two, .array_init_dot_two_comma => { | |
| 388 | 388 | var elements: [2]ast.Node.Index = undefined; |
| 389 | 389 | return renderArrayInit(ais, tree, tree.arrayInitDotTwo(&elements, node), space); |
| 390 | 390 | }, |
| 391 | .ArrayInitDot, | |
| 392 | .ArrayInitDotComma, | |
| 391 | .array_init_dot, | |
| 392 | .array_init_dot_comma, | |
| 393 | 393 | => return renderArrayInit(ais, tree, tree.arrayInitDot(node), space), |
| 394 | .ArrayInit, | |
| 395 | .ArrayInitComma, | |
| 394 | .array_init, | |
| 395 | .array_init_comma, | |
| 396 | 396 | => return renderArrayInit(ais, tree, tree.arrayInit(node), space), |
| 397 | 397 | |
| 398 | .StructInitOne, .StructInitOneComma => { | |
| 398 | .struct_init_one, .struct_init_one_comma => { | |
| 399 | 399 | var fields: [1]ast.Node.Index = undefined; |
| 400 | 400 | return renderStructInit(ais, tree, tree.structInitOne(&fields, node), space); |
| 401 | 401 | }, |
| 402 | .StructInitDotTwo, .StructInitDotTwoComma => { | |
| 402 | .struct_init_dot_two, .struct_init_dot_two_comma => { | |
| 403 | 403 | var fields: [2]ast.Node.Index = undefined; |
| 404 | 404 | return renderStructInit(ais, tree, tree.structInitDotTwo(&fields, node), space); |
| 405 | 405 | }, |
| 406 | .StructInitDot, | |
| 407 | .StructInitDotComma, | |
| 406 | .struct_init_dot, | |
| 407 | .struct_init_dot_comma, | |
| 408 | 408 | => return renderStructInit(ais, tree, tree.structInitDot(node), space), |
| 409 | .StructInit, | |
| 410 | .StructInitComma, | |
| 409 | .struct_init, | |
| 410 | .struct_init_comma, | |
| 411 | 411 | => return renderStructInit(ais, tree, tree.structInit(node), space), |
| 412 | 412 | |
| 413 | .CallOne, .CallOneComma, .AsyncCallOne, .AsyncCallOneComma => { | |
| 413 | .call_one, .call_one_comma, .async_call_one, .async_call_one_comma => { | |
| 414 | 414 | var params: [1]ast.Node.Index = undefined; |
| 415 | 415 | return renderCall(ais, tree, tree.callOne(&params, node), space); |
| 416 | 416 | }, |
| 417 | 417 | |
| 418 | .Call, | |
| 419 | .CallComma, | |
| 420 | .AsyncCall, | |
| 421 | .AsyncCallComma, | |
| 418 | .call, | |
| 419 | .call_comma, | |
| 420 | .async_call, | |
| 421 | .async_call_comma, | |
| 422 | 422 | => return renderCall(ais, tree, tree.callFull(node), space), |
| 423 | 423 | |
| 424 | .ArrayAccess => { | |
| 424 | .array_access => { | |
| 425 | 425 | const suffix = datas[node]; |
| 426 | 426 | const lbracket = tree.firstToken(suffix.rhs) - 1; |
| 427 | 427 | const rbracket = tree.lastToken(suffix.rhs) + 1; |
| ... | ... | @@ -431,22 +431,22 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 431 | 431 | return renderToken(ais, tree, rbracket, space); // ] |
| 432 | 432 | }, |
| 433 | 433 | |
| 434 | .SliceOpen => try renderSlice(ais, tree, tree.sliceOpen(node), space), | |
| 435 | .Slice => try renderSlice(ais, tree, tree.slice(node), space), | |
| 436 | .SliceSentinel => try renderSlice(ais, tree, tree.sliceSentinel(node), space), | |
| 434 | .slice_open => try renderSlice(ais, tree, tree.sliceOpen(node), space), | |
| 435 | .slice => try renderSlice(ais, tree, tree.slice(node), space), | |
| 436 | .slice_sentinel => try renderSlice(ais, tree, tree.sliceSentinel(node), space), | |
| 437 | 437 | |
| 438 | .Deref => { | |
| 438 | .deref => { | |
| 439 | 439 | try renderExpression(ais, tree, datas[node].lhs, .None); |
| 440 | 440 | return renderToken(ais, tree, main_tokens[node], space); |
| 441 | 441 | }, |
| 442 | 442 | |
| 443 | .UnwrapOptional => { | |
| 443 | .unwrap_optional => { | |
| 444 | 444 | try renderExpression(ais, tree, datas[node].lhs, .None); |
| 445 | 445 | try renderToken(ais, tree, main_tokens[node], .None); |
| 446 | 446 | return renderToken(ais, tree, datas[node].rhs, space); |
| 447 | 447 | }, |
| 448 | 448 | |
| 449 | .Break => { | |
| 449 | .@"break" => { | |
| 450 | 450 | const main_token = main_tokens[node]; |
| 451 | 451 | const label_token = datas[node].lhs; |
| 452 | 452 | const target = datas[node].rhs; |
| ... | ... | @@ -467,7 +467,7 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 467 | 467 | } |
| 468 | 468 | }, |
| 469 | 469 | |
| 470 | .Continue => { | |
| 470 | .@"continue" => { | |
| 471 | 471 | const main_token = main_tokens[node]; |
| 472 | 472 | const label = datas[node].lhs; |
| 473 | 473 | if (label != 0) { |
| ... | ... | @@ -479,7 +479,7 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 479 | 479 | } |
| 480 | 480 | }, |
| 481 | 481 | |
| 482 | .Return => { | |
| 482 | .@"return" => { | |
| 483 | 483 | if (datas[node].lhs != 0) { |
| 484 | 484 | try renderToken(ais, tree, main_tokens[node], .Space); |
| 485 | 485 | try renderExpression(ais, tree, datas[node].lhs, space); |
| ... | ... | @@ -488,7 +488,7 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 488 | 488 | } |
| 489 | 489 | }, |
| 490 | 490 | |
| 491 | .GroupedExpression => { | |
| 491 | .grouped_expression => { | |
| 492 | 492 | ais.pushIndentNextLine(); |
| 493 | 493 | try renderToken(ais, tree, main_tokens[node], .None); // lparen |
| 494 | 494 | try renderExpression(ais, tree, datas[node].lhs, .None); |
| ... | ... | @@ -496,32 +496,32 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 496 | 496 | return renderToken(ais, tree, datas[node].rhs, space); // rparen |
| 497 | 497 | }, |
| 498 | 498 | |
| 499 | .ContainerDecl, | |
| 500 | .ContainerDeclComma, | |
| 499 | .container_decl, | |
| 500 | .container_decl_comma, | |
| 501 | 501 | => return renderContainerDecl(ais, tree, tree.containerDecl(node), space), |
| 502 | 502 | |
| 503 | .ContainerDeclTwo, .ContainerDeclTwoComma => { | |
| 503 | .container_decl_two, .container_decl_two_comma => { | |
| 504 | 504 | var buffer: [2]ast.Node.Index = undefined; |
| 505 | 505 | return renderContainerDecl(ais, tree, tree.containerDeclTwo(&buffer, node), space); |
| 506 | 506 | }, |
| 507 | .ContainerDeclArg, | |
| 508 | .ContainerDeclArgComma, | |
| 507 | .container_decl_arg, | |
| 508 | .container_decl_arg_comma, | |
| 509 | 509 | => return renderContainerDecl(ais, tree, tree.containerDeclArg(node), space), |
| 510 | 510 | |
| 511 | .TaggedUnion, | |
| 512 | .TaggedUnionComma, | |
| 511 | .tagged_union, | |
| 512 | .tagged_union_comma, | |
| 513 | 513 | => return renderContainerDecl(ais, tree, tree.taggedUnion(node), space), |
| 514 | 514 | |
| 515 | .TaggedUnionTwo, .TaggedUnionTwoComma => { | |
| 515 | .tagged_union_two, .tagged_union_two_comma => { | |
| 516 | 516 | var buffer: [2]ast.Node.Index = undefined; |
| 517 | 517 | return renderContainerDecl(ais, tree, tree.taggedUnionTwo(&buffer, node), space); |
| 518 | 518 | }, |
| 519 | .TaggedUnionEnumTag, | |
| 520 | .TaggedUnionEnumTagComma, | |
| 519 | .tagged_union_enum_tag, | |
| 520 | .tagged_union_enum_tag_comma, | |
| 521 | 521 | => return renderContainerDecl(ais, tree, tree.taggedUnionEnumTag(node), space), |
| 522 | 522 | |
| 523 | 523 | // TODO: handle comments properly |
| 524 | .ErrorSetDecl => { | |
| 524 | .error_set_decl => { | |
| 525 | 525 | const error_token = main_tokens[node]; |
| 526 | 526 | const lbrace = error_token + 1; |
| 527 | 527 | const rbrace = datas[node].rhs; |
| ... | ... | @@ -569,7 +569,7 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 569 | 569 | } |
| 570 | 570 | }, |
| 571 | 571 | |
| 572 | .BuiltinCallTwo, .BuiltinCallTwoComma => { | |
| 572 | .builtin_call_two, .builtin_call_two_comma => { | |
| 573 | 573 | if (datas[node].lhs == 0) { |
| 574 | 574 | const params = [_]ast.Node.Index{}; |
| 575 | 575 | return renderBuiltinCall(ais, tree, main_tokens[node], &params, space); |
| ... | ... | @@ -581,23 +581,23 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 581 | 581 | return renderBuiltinCall(ais, tree, main_tokens[node], &params, space); |
| 582 | 582 | } |
| 583 | 583 | }, |
| 584 | .BuiltinCall, .BuiltinCallComma => { | |
| 584 | .builtin_call, .builtin_call_comma => { | |
| 585 | 585 | const params = tree.extra_data[datas[node].lhs..datas[node].rhs]; |
| 586 | 586 | return renderBuiltinCall(ais, tree, main_tokens[node], params, space); |
| 587 | 587 | }, |
| 588 | 588 | |
| 589 | .FnProtoSimple => { | |
| 589 | .fn_proto_simple => { | |
| 590 | 590 | var params: [1]ast.Node.Index = undefined; |
| 591 | 591 | return renderFnProto(ais, tree, tree.fnProtoSimple(&params, node), space); |
| 592 | 592 | }, |
| 593 | .FnProtoMulti => return renderFnProto(ais, tree, tree.fnProtoMulti(node), space), | |
| 594 | .FnProtoOne => { | |
| 593 | .fn_proto_multi => return renderFnProto(ais, tree, tree.fnProtoMulti(node), space), | |
| 594 | .fn_proto_one => { | |
| 595 | 595 | var params: [1]ast.Node.Index = undefined; |
| 596 | 596 | return renderFnProto(ais, tree, tree.fnProtoOne(&params, node), space); |
| 597 | 597 | }, |
| 598 | .FnProto => return renderFnProto(ais, tree, tree.fnProto(node), space), | |
| 598 | .fn_proto => return renderFnProto(ais, tree, tree.fnProto(node), space), | |
| 599 | 599 | |
| 600 | .AnyFrameType => { | |
| 600 | .anyframe_type => { | |
| 601 | 601 | const main_token = main_tokens[node]; |
| 602 | 602 | if (datas[node].rhs != 0) { |
| 603 | 603 | try renderToken(ais, tree, main_token, .None); // anyframe |
| ... | ... | @@ -608,8 +608,8 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 608 | 608 | } |
| 609 | 609 | }, |
| 610 | 610 | |
| 611 | .Switch, | |
| 612 | .SwitchComma, | |
| 611 | .@"switch", | |
| 612 | .switch_comma, | |
| 613 | 613 | => { |
| 614 | 614 | const switch_token = main_tokens[node]; |
| 615 | 615 | const condition = datas[node].lhs; |
| ... | ... | @@ -635,39 +635,39 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac |
| 635 | 635 | return renderToken(ais, tree, tree.lastToken(node), space); // rbrace |
| 636 | 636 | }, |
| 637 | 637 | |
| 638 | .SwitchCaseOne => return renderSwitchCase(ais, tree, tree.switchCaseOne(node), space), | |
| 639 | .SwitchCase => return renderSwitchCase(ais, tree, tree.switchCase(node), space), | |
| 638 | .switch_case_one => return renderSwitchCase(ais, tree, tree.switchCaseOne(node), space), | |
| 639 | .switch_case => return renderSwitchCase(ais, tree, tree.switchCase(node), space), | |
| 640 | 640 | |
| 641 | .WhileSimple => return renderWhile(ais, tree, tree.whileSimple(node), space), | |
| 642 | .WhileCont => return renderWhile(ais, tree, tree.whileCont(node), space), | |
| 643 | .While => return renderWhile(ais, tree, tree.whileFull(node), space), | |
| 644 | .ForSimple => return renderWhile(ais, tree, tree.forSimple(node), space), | |
| 645 | .For => return renderWhile(ais, tree, tree.forFull(node), space), | |
| 641 | .while_simple => return renderWhile(ais, tree, tree.whileSimple(node), space), | |
| 642 | .while_cont => return renderWhile(ais, tree, tree.whileCont(node), space), | |
| 643 | .@"while" => return renderWhile(ais, tree, tree.whileFull(node), space), | |
| 644 | .for_simple => return renderWhile(ais, tree, tree.forSimple(node), space), | |
| 645 | .@"for" => return renderWhile(ais, tree, tree.forFull(node), space), | |
| 646 | 646 | |
| 647 | .IfSimple => return renderIf(ais, tree, tree.ifSimple(node), space), | |
| 648 | .If => return renderIf(ais, tree, tree.ifFull(node), space), | |
| 647 | .if_simple => return renderIf(ais, tree, tree.ifSimple(node), space), | |
| 648 | .@"if" => return renderIf(ais, tree, tree.ifFull(node), space), | |
| 649 | 649 | |
| 650 | .AsmSimple => return renderAsm(ais, tree, tree.asmSimple(node), space), | |
| 651 | .Asm => return renderAsm(ais, tree, tree.asmFull(node), space), | |
| 650 | .asm_simple => return renderAsm(ais, tree, tree.asmSimple(node), space), | |
| 651 | .@"asm" => return renderAsm(ais, tree, tree.asmFull(node), space), | |
| 652 | 652 | |
| 653 | .EnumLiteral => { | |
| 653 | .enum_literal => { | |
| 654 | 654 | try renderToken(ais, tree, main_tokens[node] - 1, .None); // . |
| 655 | 655 | return renderToken(ais, tree, main_tokens[node], space); // name |
| 656 | 656 | }, |
| 657 | 657 | |
| 658 | .FnDecl => unreachable, | |
| 659 | .ContainerField => unreachable, | |
| 660 | .ContainerFieldInit => unreachable, | |
| 661 | .ContainerFieldAlign => unreachable, | |
| 662 | .Root => unreachable, | |
| 663 | .GlobalVarDecl => unreachable, | |
| 664 | .LocalVarDecl => unreachable, | |
| 665 | .SimpleVarDecl => unreachable, | |
| 666 | .AlignedVarDecl => unreachable, | |
| 667 | .UsingNamespace => unreachable, | |
| 668 | .TestDecl => unreachable, | |
| 669 | .AsmOutput => unreachable, | |
| 670 | .AsmInput => unreachable, | |
| 658 | .fn_decl => unreachable, | |
| 659 | .container_field => unreachable, | |
| 660 | .container_field_init => unreachable, | |
| 661 | .container_field_align => unreachable, | |
| 662 | .root => unreachable, | |
| 663 | .global_var_decl => unreachable, | |
| 664 | .local_var_decl => unreachable, | |
| 665 | .simple_var_decl => unreachable, | |
| 666 | .aligned_var_decl => unreachable, | |
| 667 | .@"usingnamespace" => unreachable, | |
| 668 | .test_decl => unreachable, | |
| 669 | .asm_output => unreachable, | |
| 670 | .asm_input => unreachable, | |
| 671 | 671 | } |
| 672 | 672 | } |
| 673 | 673 | |
| ... | ... | @@ -814,7 +814,7 @@ fn renderAsmOutput( |
| 814 | 814 | const node_tags = tree.nodes.items(.tag); |
| 815 | 815 | const main_tokens = tree.nodes.items(.main_token); |
| 816 | 816 | const datas = tree.nodes.items(.data); |
| 817 | assert(node_tags[asm_output] == .AsmOutput); | |
| 817 | assert(node_tags[asm_output] == .asm_output); | |
| 818 | 818 | const symbolic_name = main_tokens[asm_output]; |
| 819 | 819 | |
| 820 | 820 | try renderToken(ais, tree, symbolic_name - 1, .None); // lbracket |
| ... | ... | @@ -842,7 +842,7 @@ fn renderAsmInput( |
| 842 | 842 | const node_tags = tree.nodes.items(.tag); |
| 843 | 843 | const main_tokens = tree.nodes.items(.main_token); |
| 844 | 844 | const datas = tree.nodes.items(.data); |
| 845 | assert(node_tags[asm_input] == .AsmInput); | |
| 845 | assert(node_tags[asm_input] == .asm_input); | |
| 846 | 846 | const symbolic_name = main_tokens[asm_input]; |
| 847 | 847 | |
| 848 | 848 | try renderToken(ais, tree, symbolic_name - 1, .None); // lbracket |
| ... | ... | @@ -1516,10 +1516,10 @@ fn renderBlock( |
| 1516 | 1516 | try renderToken(ais, tree, lbrace, .Newline); |
| 1517 | 1517 | for (statements) |stmt, i| { |
| 1518 | 1518 | switch (node_tags[stmt]) { |
| 1519 | .GlobalVarDecl => try renderVarDecl(ais, tree, tree.globalVarDecl(stmt)), | |
| 1520 | .LocalVarDecl => try renderVarDecl(ais, tree, tree.localVarDecl(stmt)), | |
| 1521 | .SimpleVarDecl => try renderVarDecl(ais, tree, tree.simpleVarDecl(stmt)), | |
| 1522 | .AlignedVarDecl => try renderVarDecl(ais, tree, tree.alignedVarDecl(stmt)), | |
| 1519 | .global_var_decl => try renderVarDecl(ais, tree, tree.globalVarDecl(stmt)), | |
| 1520 | .local_var_decl => try renderVarDecl(ais, tree, tree.localVarDecl(stmt)), | |
| 1521 | .simple_var_decl => try renderVarDecl(ais, tree, tree.simpleVarDecl(stmt)), | |
| 1522 | .aligned_var_decl => try renderVarDecl(ais, tree, tree.alignedVarDecl(stmt)), | |
| 1523 | 1523 | else => try renderExpression(ais, tree, stmt, .Semicolon), |
| 1524 | 1524 | } |
| 1525 | 1525 | } |
| ... | ... | @@ -1867,7 +1867,7 @@ fn renderCall( |
| 1867 | 1867 | try renderExpression(ais, tree, param_node, Space.None); |
| 1868 | 1868 | |
| 1869 | 1869 | // Unindent the comma for multiline string literals |
| 1870 | const is_multiline_string = node_tags[param_node] == .StringLiteral and | |
| 1870 | const is_multiline_string = node_tags[param_node] == .string_literal and | |
| 1871 | 1871 | token_tags[main_tokens[param_node]] == .multiline_string_literal_line; |
| 1872 | 1872 | if (is_multiline_string) ais.popIndent(); |
| 1873 | 1873 | |
| ... | ... | @@ -2031,19 +2031,19 @@ fn renderDocComments(ais: *Ais, tree: ast.Tree, end_token: ast.TokenIndex) Error |
| 2031 | 2031 | |
| 2032 | 2032 | fn nodeIsBlock(tag: ast.Node.Tag) bool { |
| 2033 | 2033 | return switch (tag) { |
| 2034 | .Block, | |
| 2035 | .BlockSemicolon, | |
| 2036 | .BlockTwo, | |
| 2037 | .BlockTwoSemicolon, | |
| 2038 | .If, | |
| 2039 | .IfSimple, | |
| 2040 | .For, | |
| 2041 | .ForSimple, | |
| 2042 | .While, | |
| 2043 | .WhileSimple, | |
| 2044 | .WhileCont, | |
| 2045 | .Switch, | |
| 2046 | .SwitchComma, | |
| 2034 | .block, | |
| 2035 | .block_semicolon, | |
| 2036 | .block_two, | |
| 2037 | .block_two_semicolon, | |
| 2038 | .@"if", | |
| 2039 | .if_simple, | |
| 2040 | .@"for", | |
| 2041 | .for_simple, | |
| 2042 | .@"while", | |
| 2043 | .while_simple, | |
| 2044 | .while_cont, | |
| 2045 | .@"switch", | |
| 2046 | .switch_comma, | |
| 2047 | 2047 | => true, |
| 2048 | 2048 | else => false, |
| 2049 | 2049 | }; |
| ... | ... | @@ -2051,47 +2051,47 @@ fn nodeIsBlock(tag: ast.Node.Tag) bool { |
| 2051 | 2051 | |
| 2052 | 2052 | fn nodeCausesSliceOpSpace(tag: ast.Node.Tag) bool { |
| 2053 | 2053 | return switch (tag) { |
| 2054 | .Catch, | |
| 2055 | .Add, | |
| 2056 | .AddWrap, | |
| 2057 | .ArrayCat, | |
| 2058 | .ArrayMult, | |
| 2059 | .Assign, | |
| 2060 | .AssignBitAnd, | |
| 2061 | .AssignBitOr, | |
| 2062 | .AssignBitShiftLeft, | |
| 2063 | .AssignBitShiftRight, | |
| 2064 | .AssignBitXor, | |
| 2065 | .AssignDiv, | |
| 2066 | .AssignSub, | |
| 2067 | .AssignSubWrap, | |
| 2068 | .AssignMod, | |
| 2069 | .AssignAdd, | |
| 2070 | .AssignAddWrap, | |
| 2071 | .AssignMul, | |
| 2072 | .AssignMulWrap, | |
| 2073 | .BangEqual, | |
| 2074 | .BitAnd, | |
| 2075 | .BitOr, | |
| 2076 | .BitShiftLeft, | |
| 2077 | .BitShiftRight, | |
| 2078 | .BitXor, | |
| 2079 | .BoolAnd, | |
| 2080 | .BoolOr, | |
| 2081 | .Div, | |
| 2082 | .EqualEqual, | |
| 2083 | .ErrorUnion, | |
| 2084 | .GreaterOrEqual, | |
| 2085 | .GreaterThan, | |
| 2086 | .LessOrEqual, | |
| 2087 | .LessThan, | |
| 2088 | .MergeErrorSets, | |
| 2089 | .Mod, | |
| 2090 | .Mul, | |
| 2091 | .MulWrap, | |
| 2092 | .Sub, | |
| 2093 | .SubWrap, | |
| 2094 | .OrElse, | |
| 2054 | .@"catch", | |
| 2055 | .add, | |
| 2056 | .add_wrap, | |
| 2057 | .array_cat, | |
| 2058 | .array_mult, | |
| 2059 | .assign, | |
| 2060 | .assign_bit_and, | |
| 2061 | .assign_bit_or, | |
| 2062 | .assign_bit_shift_left, | |
| 2063 | .assign_bit_shift_right, | |
| 2064 | .assign_bit_xor, | |
| 2065 | .assign_div, | |
| 2066 | .assign_sub, | |
| 2067 | .assign_sub_wrap, | |
| 2068 | .assign_mod, | |
| 2069 | .assign_add, | |
| 2070 | .assign_add_wrap, | |
| 2071 | .assign_mul, | |
| 2072 | .assign_mul_wrap, | |
| 2073 | .bang_equal, | |
| 2074 | .bit_and, | |
| 2075 | .bit_or, | |
| 2076 | .bit_shift_left, | |
| 2077 | .bit_shift_right, | |
| 2078 | .bit_xor, | |
| 2079 | .bool_and, | |
| 2080 | .bool_or, | |
| 2081 | .div, | |
| 2082 | .equal_equal, | |
| 2083 | .error_union, | |
| 2084 | .greater_or_equal, | |
| 2085 | .greater_than, | |
| 2086 | .less_or_equal, | |
| 2087 | .less_than, | |
| 2088 | .merge_error_sets, | |
| 2089 | .mod, | |
| 2090 | .mul, | |
| 2091 | .mul_wrap, | |
| 2092 | .sub, | |
| 2093 | .sub_wrap, | |
| 2094 | .@"orelse", | |
| 2095 | 2095 | => true, |
| 2096 | 2096 | |
| 2097 | 2097 | else => false, |