ast.go (137866B)
1 // Code generated by yy. DO NOT EDIT. 2 3 // Copyright 2019 The CC Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 package cc 8 9 import ( 10 "fmt" 11 12 "modernc.org/token" 13 ) 14 15 // AbstractDeclaratorCase represents case numbers of production AbstractDeclarator 16 type AbstractDeclaratorCase int 17 18 // Values of type AbstractDeclaratorCase 19 const ( 20 AbstractDeclaratorPtr AbstractDeclaratorCase = iota 21 AbstractDeclaratorDecl 22 ) 23 24 // String implements fmt.Stringer 25 func (n AbstractDeclaratorCase) String() string { 26 switch n { 27 case AbstractDeclaratorPtr: 28 return "AbstractDeclaratorPtr" 29 case AbstractDeclaratorDecl: 30 return "AbstractDeclaratorDecl" 31 default: 32 return fmt.Sprintf("AbstractDeclaratorCase(%v)", int(n)) 33 } 34 } 35 36 // AbstractDeclarator represents data reduced by productions: 37 // 38 // AbstractDeclarator: 39 // Pointer // Case AbstractDeclaratorPtr 40 // | Pointer DirectAbstractDeclarator // Case AbstractDeclaratorDecl 41 type AbstractDeclarator struct { 42 typ Type 43 Case AbstractDeclaratorCase `PrettyPrint:"stringer,zero"` 44 DirectAbstractDeclarator *DirectAbstractDeclarator 45 Pointer *Pointer 46 } 47 48 // String implements fmt.Stringer. 49 func (n *AbstractDeclarator) String() string { return PrettyString(n) } 50 51 // Position reports the position of the first component of n, if available. 52 func (n *AbstractDeclarator) Position() (r token.Position) { 53 if n == nil { 54 return r 55 } 56 57 switch n.Case { 58 case 0: 59 return n.Pointer.Position() 60 case 1: 61 if p := n.Pointer.Position(); p.IsValid() { 62 return p 63 } 64 65 return n.DirectAbstractDeclarator.Position() 66 default: 67 panic("internal error") 68 } 69 } 70 71 // AdditiveExpressionCase represents case numbers of production AdditiveExpression 72 type AdditiveExpressionCase int 73 74 // Values of type AdditiveExpressionCase 75 const ( 76 AdditiveExpressionMul AdditiveExpressionCase = iota 77 AdditiveExpressionAdd 78 AdditiveExpressionSub 79 ) 80 81 // String implements fmt.Stringer 82 func (n AdditiveExpressionCase) String() string { 83 switch n { 84 case AdditiveExpressionMul: 85 return "AdditiveExpressionMul" 86 case AdditiveExpressionAdd: 87 return "AdditiveExpressionAdd" 88 case AdditiveExpressionSub: 89 return "AdditiveExpressionSub" 90 default: 91 return fmt.Sprintf("AdditiveExpressionCase(%v)", int(n)) 92 } 93 } 94 95 // AdditiveExpression represents data reduced by productions: 96 // 97 // AdditiveExpression: 98 // MultiplicativeExpression // Case AdditiveExpressionMul 99 // | AdditiveExpression '+' MultiplicativeExpression // Case AdditiveExpressionAdd 100 // | AdditiveExpression '-' MultiplicativeExpression // Case AdditiveExpressionSub 101 type AdditiveExpression struct { 102 lexicalScope Scope 103 Operand Operand 104 promote Type 105 IsSideEffectsFree bool 106 AdditiveExpression *AdditiveExpression 107 Case AdditiveExpressionCase `PrettyPrint:"stringer,zero"` 108 MultiplicativeExpression *MultiplicativeExpression 109 Token Token 110 } 111 112 // String implements fmt.Stringer. 113 func (n *AdditiveExpression) String() string { return PrettyString(n) } 114 115 // Position reports the position of the first component of n, if available. 116 func (n *AdditiveExpression) Position() (r token.Position) { 117 if n == nil { 118 return r 119 } 120 121 switch n.Case { 122 case 1, 2: 123 if p := n.AdditiveExpression.Position(); p.IsValid() { 124 return p 125 } 126 127 if p := n.Token.Position(); p.IsValid() { 128 return p 129 } 130 131 return n.MultiplicativeExpression.Position() 132 case 0: 133 return n.MultiplicativeExpression.Position() 134 default: 135 panic("internal error") 136 } 137 } 138 139 // AlignmentSpecifierCase represents case numbers of production AlignmentSpecifier 140 type AlignmentSpecifierCase int 141 142 // Values of type AlignmentSpecifierCase 143 const ( 144 AlignmentSpecifierAlignasType AlignmentSpecifierCase = iota 145 AlignmentSpecifierAlignasExpr 146 ) 147 148 // String implements fmt.Stringer 149 func (n AlignmentSpecifierCase) String() string { 150 switch n { 151 case AlignmentSpecifierAlignasType: 152 return "AlignmentSpecifierAlignasType" 153 case AlignmentSpecifierAlignasExpr: 154 return "AlignmentSpecifierAlignasExpr" 155 default: 156 return fmt.Sprintf("AlignmentSpecifierCase(%v)", int(n)) 157 } 158 } 159 160 // AlignmentSpecifier represents data reduced by productions: 161 // 162 // AlignmentSpecifier: 163 // "_Alignas" '(' TypeName ')' // Case AlignmentSpecifierAlignasType 164 // | "_Alignas" '(' ConstantExpression ')' // Case AlignmentSpecifierAlignasExpr 165 type AlignmentSpecifier struct { 166 Case AlignmentSpecifierCase `PrettyPrint:"stringer,zero"` 167 ConstantExpression *ConstantExpression 168 Token Token 169 Token2 Token 170 Token3 Token 171 TypeName *TypeName 172 } 173 174 // String implements fmt.Stringer. 175 func (n *AlignmentSpecifier) String() string { return PrettyString(n) } 176 177 // Position reports the position of the first component of n, if available. 178 func (n *AlignmentSpecifier) Position() (r token.Position) { 179 if n == nil { 180 return r 181 } 182 183 switch n.Case { 184 case 1: 185 if p := n.Token.Position(); p.IsValid() { 186 return p 187 } 188 189 if p := n.Token2.Position(); p.IsValid() { 190 return p 191 } 192 193 if p := n.ConstantExpression.Position(); p.IsValid() { 194 return p 195 } 196 197 return n.Token3.Position() 198 case 0: 199 if p := n.Token.Position(); p.IsValid() { 200 return p 201 } 202 203 if p := n.Token2.Position(); p.IsValid() { 204 return p 205 } 206 207 if p := n.TypeName.Position(); p.IsValid() { 208 return p 209 } 210 211 return n.Token3.Position() 212 default: 213 panic("internal error") 214 } 215 } 216 217 // AndExpressionCase represents case numbers of production AndExpression 218 type AndExpressionCase int 219 220 // Values of type AndExpressionCase 221 const ( 222 AndExpressionEq AndExpressionCase = iota 223 AndExpressionAnd 224 ) 225 226 // String implements fmt.Stringer 227 func (n AndExpressionCase) String() string { 228 switch n { 229 case AndExpressionEq: 230 return "AndExpressionEq" 231 case AndExpressionAnd: 232 return "AndExpressionAnd" 233 default: 234 return fmt.Sprintf("AndExpressionCase(%v)", int(n)) 235 } 236 } 237 238 // AndExpression represents data reduced by productions: 239 // 240 // AndExpression: 241 // EqualityExpression // Case AndExpressionEq 242 // | AndExpression '&' EqualityExpression // Case AndExpressionAnd 243 type AndExpression struct { 244 Operand Operand 245 promote Type 246 IsSideEffectsFree bool 247 AndExpression *AndExpression 248 Case AndExpressionCase `PrettyPrint:"stringer,zero"` 249 EqualityExpression *EqualityExpression 250 Token Token 251 } 252 253 // String implements fmt.Stringer. 254 func (n *AndExpression) String() string { return PrettyString(n) } 255 256 // Position reports the position of the first component of n, if available. 257 func (n *AndExpression) Position() (r token.Position) { 258 if n == nil { 259 return r 260 } 261 262 switch n.Case { 263 case 1: 264 if p := n.AndExpression.Position(); p.IsValid() { 265 return p 266 } 267 268 if p := n.Token.Position(); p.IsValid() { 269 return p 270 } 271 272 return n.EqualityExpression.Position() 273 case 0: 274 return n.EqualityExpression.Position() 275 default: 276 panic("internal error") 277 } 278 } 279 280 // ArgumentExpressionList represents data reduced by productions: 281 // 282 // ArgumentExpressionList: 283 // AssignmentExpression 284 // | ArgumentExpressionList ',' AssignmentExpression 285 type ArgumentExpressionList struct { 286 ArgumentExpressionList *ArgumentExpressionList 287 AssignmentExpression *AssignmentExpression 288 Token Token 289 } 290 291 // String implements fmt.Stringer. 292 func (n *ArgumentExpressionList) String() string { return PrettyString(n) } 293 294 // Position reports the position of the first component of n, if available. 295 func (n *ArgumentExpressionList) Position() (r token.Position) { 296 if n == nil { 297 return r 298 } 299 300 return n.AssignmentExpression.Position() 301 } 302 303 // Asm represents data reduced by production: 304 // 305 // Asm: 306 // "__asm__" AsmQualifierList '(' STRINGLITERAL AsmArgList ')' 307 type Asm struct { 308 AsmArgList *AsmArgList 309 AsmQualifierList *AsmQualifierList 310 Token Token 311 Token2 Token 312 Token3 Token 313 Token4 Token 314 } 315 316 // String implements fmt.Stringer. 317 func (n *Asm) String() string { return PrettyString(n) } 318 319 // Position reports the position of the first component of n, if available. 320 func (n *Asm) Position() (r token.Position) { 321 if n == nil { 322 return r 323 } 324 325 if p := n.Token.Position(); p.IsValid() { 326 return p 327 } 328 329 if p := n.AsmQualifierList.Position(); p.IsValid() { 330 return p 331 } 332 333 if p := n.Token2.Position(); p.IsValid() { 334 return p 335 } 336 337 if p := n.Token3.Position(); p.IsValid() { 338 return p 339 } 340 341 if p := n.AsmArgList.Position(); p.IsValid() { 342 return p 343 } 344 345 return n.Token4.Position() 346 } 347 348 // AsmArgList represents data reduced by productions: 349 // 350 // AsmArgList: 351 // ':' AsmExpressionList 352 // | AsmArgList ':' AsmExpressionList 353 type AsmArgList struct { 354 AsmArgList *AsmArgList 355 AsmExpressionList *AsmExpressionList 356 Token Token 357 } 358 359 // String implements fmt.Stringer. 360 func (n *AsmArgList) String() string { return PrettyString(n) } 361 362 // Position reports the position of the first component of n, if available. 363 func (n *AsmArgList) Position() (r token.Position) { 364 if n == nil { 365 return r 366 } 367 368 if p := n.Token.Position(); p.IsValid() { 369 return p 370 } 371 372 return n.AsmExpressionList.Position() 373 } 374 375 // AsmExpressionList represents data reduced by productions: 376 // 377 // AsmExpressionList: 378 // AsmIndex AssignmentExpression 379 // | AsmExpressionList ',' AsmIndex AssignmentExpression 380 type AsmExpressionList struct { 381 AsmExpressionList *AsmExpressionList 382 AsmIndex *AsmIndex 383 AssignmentExpression *AssignmentExpression 384 Token Token 385 } 386 387 // String implements fmt.Stringer. 388 func (n *AsmExpressionList) String() string { return PrettyString(n) } 389 390 // Position reports the position of the first component of n, if available. 391 func (n *AsmExpressionList) Position() (r token.Position) { 392 if n == nil { 393 return r 394 } 395 396 if p := n.AsmIndex.Position(); p.IsValid() { 397 return p 398 } 399 400 return n.AssignmentExpression.Position() 401 } 402 403 // AsmFunctionDefinition represents data reduced by production: 404 // 405 // AsmFunctionDefinition: 406 // DeclarationSpecifiers Declarator AsmStatement 407 type AsmFunctionDefinition struct { 408 AsmStatement *AsmStatement 409 DeclarationSpecifiers *DeclarationSpecifiers 410 Declarator *Declarator 411 } 412 413 // String implements fmt.Stringer. 414 func (n *AsmFunctionDefinition) String() string { return PrettyString(n) } 415 416 // Position reports the position of the first component of n, if available. 417 func (n *AsmFunctionDefinition) Position() (r token.Position) { 418 if n == nil { 419 return r 420 } 421 422 if p := n.DeclarationSpecifiers.Position(); p.IsValid() { 423 return p 424 } 425 426 if p := n.Declarator.Position(); p.IsValid() { 427 return p 428 } 429 430 return n.AsmStatement.Position() 431 } 432 433 // AsmIndex represents data reduced by production: 434 // 435 // AsmIndex: 436 // '[' Expression ']' 437 type AsmIndex struct { 438 Expression *Expression 439 Token Token 440 Token2 Token 441 } 442 443 // String implements fmt.Stringer. 444 func (n *AsmIndex) String() string { return PrettyString(n) } 445 446 // Position reports the position of the first component of n, if available. 447 func (n *AsmIndex) Position() (r token.Position) { 448 if n == nil { 449 return r 450 } 451 452 if p := n.Token.Position(); p.IsValid() { 453 return p 454 } 455 456 if p := n.Expression.Position(); p.IsValid() { 457 return p 458 } 459 460 return n.Token2.Position() 461 } 462 463 // AsmQualifierCase represents case numbers of production AsmQualifier 464 type AsmQualifierCase int 465 466 // Values of type AsmQualifierCase 467 const ( 468 AsmQualifierVolatile AsmQualifierCase = iota 469 AsmQualifierInline 470 AsmQualifierGoto 471 ) 472 473 // String implements fmt.Stringer 474 func (n AsmQualifierCase) String() string { 475 switch n { 476 case AsmQualifierVolatile: 477 return "AsmQualifierVolatile" 478 case AsmQualifierInline: 479 return "AsmQualifierInline" 480 case AsmQualifierGoto: 481 return "AsmQualifierGoto" 482 default: 483 return fmt.Sprintf("AsmQualifierCase(%v)", int(n)) 484 } 485 } 486 487 // AsmQualifier represents data reduced by productions: 488 // 489 // AsmQualifier: 490 // "volatile" // Case AsmQualifierVolatile 491 // | "inline" // Case AsmQualifierInline 492 // | "goto" // Case AsmQualifierGoto 493 type AsmQualifier struct { 494 Case AsmQualifierCase `PrettyPrint:"stringer,zero"` 495 Token Token 496 } 497 498 // String implements fmt.Stringer. 499 func (n *AsmQualifier) String() string { return PrettyString(n) } 500 501 // Position reports the position of the first component of n, if available. 502 func (n *AsmQualifier) Position() (r token.Position) { 503 if n == nil { 504 return r 505 } 506 507 return n.Token.Position() 508 } 509 510 // AsmQualifierList represents data reduced by productions: 511 // 512 // AsmQualifierList: 513 // AsmQualifier 514 // | AsmQualifierList AsmQualifier 515 type AsmQualifierList struct { 516 AsmQualifier *AsmQualifier 517 AsmQualifierList *AsmQualifierList 518 } 519 520 // String implements fmt.Stringer. 521 func (n *AsmQualifierList) String() string { return PrettyString(n) } 522 523 // Position reports the position of the first component of n, if available. 524 func (n *AsmQualifierList) Position() (r token.Position) { 525 if n == nil { 526 return r 527 } 528 529 return n.AsmQualifier.Position() 530 } 531 532 // AsmStatement represents data reduced by production: 533 // 534 // AsmStatement: 535 // Asm AttributeSpecifierList ';' 536 type AsmStatement struct { 537 Asm *Asm 538 AttributeSpecifierList *AttributeSpecifierList 539 Token Token 540 } 541 542 // String implements fmt.Stringer. 543 func (n *AsmStatement) String() string { return PrettyString(n) } 544 545 // Position reports the position of the first component of n, if available. 546 func (n *AsmStatement) Position() (r token.Position) { 547 if n == nil { 548 return r 549 } 550 551 if p := n.Asm.Position(); p.IsValid() { 552 return p 553 } 554 555 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 556 return p 557 } 558 559 return n.Token.Position() 560 } 561 562 // AssignmentExpressionCase represents case numbers of production AssignmentExpression 563 type AssignmentExpressionCase int 564 565 // Values of type AssignmentExpressionCase 566 const ( 567 AssignmentExpressionCond AssignmentExpressionCase = iota 568 AssignmentExpressionAssign 569 AssignmentExpressionMul 570 AssignmentExpressionDiv 571 AssignmentExpressionMod 572 AssignmentExpressionAdd 573 AssignmentExpressionSub 574 AssignmentExpressionLsh 575 AssignmentExpressionRsh 576 AssignmentExpressionAnd 577 AssignmentExpressionXor 578 AssignmentExpressionOr 579 ) 580 581 // String implements fmt.Stringer 582 func (n AssignmentExpressionCase) String() string { 583 switch n { 584 case AssignmentExpressionCond: 585 return "AssignmentExpressionCond" 586 case AssignmentExpressionAssign: 587 return "AssignmentExpressionAssign" 588 case AssignmentExpressionMul: 589 return "AssignmentExpressionMul" 590 case AssignmentExpressionDiv: 591 return "AssignmentExpressionDiv" 592 case AssignmentExpressionMod: 593 return "AssignmentExpressionMod" 594 case AssignmentExpressionAdd: 595 return "AssignmentExpressionAdd" 596 case AssignmentExpressionSub: 597 return "AssignmentExpressionSub" 598 case AssignmentExpressionLsh: 599 return "AssignmentExpressionLsh" 600 case AssignmentExpressionRsh: 601 return "AssignmentExpressionRsh" 602 case AssignmentExpressionAnd: 603 return "AssignmentExpressionAnd" 604 case AssignmentExpressionXor: 605 return "AssignmentExpressionXor" 606 case AssignmentExpressionOr: 607 return "AssignmentExpressionOr" 608 default: 609 return fmt.Sprintf("AssignmentExpressionCase(%v)", int(n)) 610 } 611 } 612 613 // AssignmentExpression represents data reduced by productions: 614 // 615 // AssignmentExpression: 616 // ConditionalExpression // Case AssignmentExpressionCond 617 // | UnaryExpression '=' AssignmentExpression // Case AssignmentExpressionAssign 618 // | UnaryExpression "*=" AssignmentExpression // Case AssignmentExpressionMul 619 // | UnaryExpression "/=" AssignmentExpression // Case AssignmentExpressionDiv 620 // | UnaryExpression "%=" AssignmentExpression // Case AssignmentExpressionMod 621 // | UnaryExpression "+=" AssignmentExpression // Case AssignmentExpressionAdd 622 // | UnaryExpression "-=" AssignmentExpression // Case AssignmentExpressionSub 623 // | UnaryExpression "<<=" AssignmentExpression // Case AssignmentExpressionLsh 624 // | UnaryExpression ">>=" AssignmentExpression // Case AssignmentExpressionRsh 625 // | UnaryExpression "&=" AssignmentExpression // Case AssignmentExpressionAnd 626 // | UnaryExpression "^=" AssignmentExpression // Case AssignmentExpressionXor 627 // | UnaryExpression "|=" AssignmentExpression // Case AssignmentExpressionOr 628 type AssignmentExpression struct { 629 Operand Operand 630 InitializerOperand Operand // When the expression is used in an initializer 631 lexicalScope Scope 632 promote Type 633 IsSideEffectsFree bool 634 AssignmentExpression *AssignmentExpression 635 Case AssignmentExpressionCase `PrettyPrint:"stringer,zero"` 636 ConditionalExpression *ConditionalExpression 637 Token Token 638 UnaryExpression *UnaryExpression 639 } 640 641 // String implements fmt.Stringer. 642 func (n *AssignmentExpression) String() string { return PrettyString(n) } 643 644 // Position reports the position of the first component of n, if available. 645 func (n *AssignmentExpression) Position() (r token.Position) { 646 if n == nil { 647 return r 648 } 649 650 switch n.Case { 651 case 0: 652 return n.ConditionalExpression.Position() 653 case 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11: 654 if p := n.UnaryExpression.Position(); p.IsValid() { 655 return p 656 } 657 658 if p := n.Token.Position(); p.IsValid() { 659 return p 660 } 661 662 return n.AssignmentExpression.Position() 663 default: 664 panic("internal error") 665 } 666 } 667 668 // AtomicTypeSpecifier represents data reduced by production: 669 // 670 // AtomicTypeSpecifier: 671 // "_Atomic" '(' TypeName ')' 672 type AtomicTypeSpecifier struct { 673 list []*TypeSpecifier 674 Token Token 675 Token2 Token 676 Token3 Token 677 TypeName *TypeName 678 } 679 680 // String implements fmt.Stringer. 681 func (n *AtomicTypeSpecifier) String() string { return PrettyString(n) } 682 683 // Position reports the position of the first component of n, if available. 684 func (n *AtomicTypeSpecifier) Position() (r token.Position) { 685 if n == nil { 686 return r 687 } 688 689 if p := n.Token.Position(); p.IsValid() { 690 return p 691 } 692 693 if p := n.Token2.Position(); p.IsValid() { 694 return p 695 } 696 697 if p := n.TypeName.Position(); p.IsValid() { 698 return p 699 } 700 701 return n.Token3.Position() 702 } 703 704 // AttributeSpecifier represents data reduced by production: 705 // 706 // AttributeSpecifier: 707 // "__attribute__" '(' '(' AttributeValueList ')' ')' 708 type AttributeSpecifier struct { 709 AttributeValueList *AttributeValueList 710 Token Token 711 Token2 Token 712 Token3 Token 713 Token4 Token 714 Token5 Token 715 } 716 717 // String implements fmt.Stringer. 718 func (n *AttributeSpecifier) String() string { return PrettyString(n) } 719 720 // Position reports the position of the first component of n, if available. 721 func (n *AttributeSpecifier) Position() (r token.Position) { 722 if n == nil { 723 return r 724 } 725 726 if p := n.Token.Position(); p.IsValid() { 727 return p 728 } 729 730 if p := n.Token2.Position(); p.IsValid() { 731 return p 732 } 733 734 if p := n.Token3.Position(); p.IsValid() { 735 return p 736 } 737 738 if p := n.AttributeValueList.Position(); p.IsValid() { 739 return p 740 } 741 742 if p := n.Token4.Position(); p.IsValid() { 743 return p 744 } 745 746 return n.Token5.Position() 747 } 748 749 // AttributeSpecifierList represents data reduced by productions: 750 // 751 // AttributeSpecifierList: 752 // AttributeSpecifier 753 // | AttributeSpecifierList AttributeSpecifier 754 type AttributeSpecifierList struct { 755 AttributeSpecifier *AttributeSpecifier 756 AttributeSpecifierList *AttributeSpecifierList 757 } 758 759 // String implements fmt.Stringer. 760 func (n *AttributeSpecifierList) String() string { return PrettyString(n) } 761 762 // Position reports the position of the first component of n, if available. 763 func (n *AttributeSpecifierList) Position() (r token.Position) { 764 if n == nil { 765 return r 766 } 767 768 return n.AttributeSpecifier.Position() 769 } 770 771 // AttributeValueCase represents case numbers of production AttributeValue 772 type AttributeValueCase int 773 774 // Values of type AttributeValueCase 775 const ( 776 AttributeValueIdent AttributeValueCase = iota 777 AttributeValueExpr 778 ) 779 780 // String implements fmt.Stringer 781 func (n AttributeValueCase) String() string { 782 switch n { 783 case AttributeValueIdent: 784 return "AttributeValueIdent" 785 case AttributeValueExpr: 786 return "AttributeValueExpr" 787 default: 788 return fmt.Sprintf("AttributeValueCase(%v)", int(n)) 789 } 790 } 791 792 // AttributeValue represents data reduced by productions: 793 // 794 // AttributeValue: 795 // IDENTIFIER // Case AttributeValueIdent 796 // | IDENTIFIER '(' ExpressionList ')' // Case AttributeValueExpr 797 type AttributeValue struct { 798 lexicalScope Scope 799 Case AttributeValueCase `PrettyPrint:"stringer,zero"` 800 ExpressionList *ExpressionList 801 Token Token 802 Token2 Token 803 Token3 Token 804 } 805 806 // String implements fmt.Stringer. 807 func (n *AttributeValue) String() string { return PrettyString(n) } 808 809 // Position reports the position of the first component of n, if available. 810 func (n *AttributeValue) Position() (r token.Position) { 811 if n == nil { 812 return r 813 } 814 815 switch n.Case { 816 case 0: 817 return n.Token.Position() 818 case 1: 819 if p := n.Token.Position(); p.IsValid() { 820 return p 821 } 822 823 if p := n.Token2.Position(); p.IsValid() { 824 return p 825 } 826 827 if p := n.ExpressionList.Position(); p.IsValid() { 828 return p 829 } 830 831 return n.Token3.Position() 832 default: 833 panic("internal error") 834 } 835 } 836 837 // AttributeValueList represents data reduced by productions: 838 // 839 // AttributeValueList: 840 // AttributeValue 841 // | AttributeValueList ',' AttributeValue 842 type AttributeValueList struct { 843 AttributeValue *AttributeValue 844 AttributeValueList *AttributeValueList 845 Token Token 846 } 847 848 // String implements fmt.Stringer. 849 func (n *AttributeValueList) String() string { return PrettyString(n) } 850 851 // Position reports the position of the first component of n, if available. 852 func (n *AttributeValueList) Position() (r token.Position) { 853 if n == nil { 854 return r 855 } 856 857 return n.AttributeValue.Position() 858 } 859 860 // BlockItemCase represents case numbers of production BlockItem 861 type BlockItemCase int 862 863 // Values of type BlockItemCase 864 const ( 865 BlockItemDecl BlockItemCase = iota 866 BlockItemStmt 867 BlockItemLabel 868 BlockItemFuncDef 869 BlockItemPragma 870 ) 871 872 // String implements fmt.Stringer 873 func (n BlockItemCase) String() string { 874 switch n { 875 case BlockItemDecl: 876 return "BlockItemDecl" 877 case BlockItemStmt: 878 return "BlockItemStmt" 879 case BlockItemLabel: 880 return "BlockItemLabel" 881 case BlockItemFuncDef: 882 return "BlockItemFuncDef" 883 case BlockItemPragma: 884 return "BlockItemPragma" 885 default: 886 return fmt.Sprintf("BlockItemCase(%v)", int(n)) 887 } 888 } 889 890 // BlockItem represents data reduced by productions: 891 // 892 // BlockItem: 893 // Declaration // Case BlockItemDecl 894 // | Statement // Case BlockItemStmt 895 // | LabelDeclaration // Case BlockItemLabel 896 // | DeclarationSpecifiers Declarator CompoundStatement // Case BlockItemFuncDef 897 // | PragmaSTDC // Case BlockItemPragma 898 type BlockItem struct { 899 fn *FunctionDefinition // Case FuncDef 900 closure map[StringID]struct{} // Case FuncDef 901 Last bool 902 Case BlockItemCase `PrettyPrint:"stringer,zero"` 903 CompoundStatement *CompoundStatement 904 Declaration *Declaration 905 DeclarationSpecifiers *DeclarationSpecifiers 906 Declarator *Declarator 907 LabelDeclaration *LabelDeclaration 908 PragmaSTDC *PragmaSTDC 909 Statement *Statement 910 } 911 912 // String implements fmt.Stringer. 913 func (n *BlockItem) String() string { return PrettyString(n) } 914 915 // Position reports the position of the first component of n, if available. 916 func (n *BlockItem) Position() (r token.Position) { 917 if n == nil { 918 return r 919 } 920 921 switch n.Case { 922 case 0: 923 return n.Declaration.Position() 924 case 3: 925 if p := n.DeclarationSpecifiers.Position(); p.IsValid() { 926 return p 927 } 928 929 if p := n.Declarator.Position(); p.IsValid() { 930 return p 931 } 932 933 return n.CompoundStatement.Position() 934 case 2: 935 return n.LabelDeclaration.Position() 936 case 4: 937 return n.PragmaSTDC.Position() 938 case 1: 939 return n.Statement.Position() 940 default: 941 panic("internal error") 942 } 943 } 944 945 // BlockItemList represents data reduced by productions: 946 // 947 // BlockItemList: 948 // BlockItem 949 // | BlockItemList BlockItem 950 type BlockItemList struct { 951 BlockItem *BlockItem 952 BlockItemList *BlockItemList 953 } 954 955 // String implements fmt.Stringer. 956 func (n *BlockItemList) String() string { return PrettyString(n) } 957 958 // Position reports the position of the first component of n, if available. 959 func (n *BlockItemList) Position() (r token.Position) { 960 if n == nil { 961 return r 962 } 963 964 return n.BlockItem.Position() 965 } 966 967 // CastExpressionCase represents case numbers of production CastExpression 968 type CastExpressionCase int 969 970 // Values of type CastExpressionCase 971 const ( 972 CastExpressionUnary CastExpressionCase = iota 973 CastExpressionCast 974 ) 975 976 // String implements fmt.Stringer 977 func (n CastExpressionCase) String() string { 978 switch n { 979 case CastExpressionUnary: 980 return "CastExpressionUnary" 981 case CastExpressionCast: 982 return "CastExpressionCast" 983 default: 984 return fmt.Sprintf("CastExpressionCase(%v)", int(n)) 985 } 986 } 987 988 // CastExpression represents data reduced by productions: 989 // 990 // CastExpression: 991 // UnaryExpression // Case CastExpressionUnary 992 // | '(' TypeName ')' CastExpression // Case CastExpressionCast 993 type CastExpression struct { 994 Operand Operand 995 IsSideEffectsFree bool 996 Case CastExpressionCase `PrettyPrint:"stringer,zero"` 997 CastExpression *CastExpression 998 Token Token 999 Token2 Token 1000 TypeName *TypeName 1001 UnaryExpression *UnaryExpression 1002 } 1003 1004 // String implements fmt.Stringer. 1005 func (n *CastExpression) String() string { return PrettyString(n) } 1006 1007 // Position reports the position of the first component of n, if available. 1008 func (n *CastExpression) Position() (r token.Position) { 1009 if n == nil { 1010 return r 1011 } 1012 1013 switch n.Case { 1014 case 1: 1015 if p := n.Token.Position(); p.IsValid() { 1016 return p 1017 } 1018 1019 if p := n.TypeName.Position(); p.IsValid() { 1020 return p 1021 } 1022 1023 if p := n.Token2.Position(); p.IsValid() { 1024 return p 1025 } 1026 1027 return n.CastExpression.Position() 1028 case 0: 1029 return n.UnaryExpression.Position() 1030 default: 1031 panic("internal error") 1032 } 1033 } 1034 1035 // CompoundStatement represents data reduced by production: 1036 // 1037 // CompoundStatement: 1038 // '{' BlockItemList '}' 1039 type CompoundStatement struct { 1040 Operand Operand 1041 children []*CompoundStatement 1042 declarations []*Declaration 1043 isJumpTarget bool 1044 labeledStmts []*LabeledStatement 1045 parent *CompoundStatement 1046 scope Scope 1047 BlockItemList *BlockItemList 1048 Token Token 1049 Token2 Token 1050 } 1051 1052 // String implements fmt.Stringer. 1053 func (n *CompoundStatement) String() string { return PrettyString(n) } 1054 1055 // Position reports the position of the first component of n, if available. 1056 func (n *CompoundStatement) Position() (r token.Position) { 1057 if n == nil { 1058 return r 1059 } 1060 1061 if p := n.Token.Position(); p.IsValid() { 1062 return p 1063 } 1064 1065 if p := n.BlockItemList.Position(); p.IsValid() { 1066 return p 1067 } 1068 1069 return n.Token2.Position() 1070 } 1071 1072 // ConditionalExpressionCase represents case numbers of production ConditionalExpression 1073 type ConditionalExpressionCase int 1074 1075 // Values of type ConditionalExpressionCase 1076 const ( 1077 ConditionalExpressionLOr ConditionalExpressionCase = iota 1078 ConditionalExpressionCond 1079 ) 1080 1081 // String implements fmt.Stringer 1082 func (n ConditionalExpressionCase) String() string { 1083 switch n { 1084 case ConditionalExpressionLOr: 1085 return "ConditionalExpressionLOr" 1086 case ConditionalExpressionCond: 1087 return "ConditionalExpressionCond" 1088 default: 1089 return fmt.Sprintf("ConditionalExpressionCase(%v)", int(n)) 1090 } 1091 } 1092 1093 // ConditionalExpression represents data reduced by productions: 1094 // 1095 // ConditionalExpression: 1096 // LogicalOrExpression // Case ConditionalExpressionLOr 1097 // | LogicalOrExpression '?' Expression ':' ConditionalExpression // Case ConditionalExpressionCond 1098 type ConditionalExpression struct { 1099 Operand Operand 1100 IsSideEffectsFree bool 1101 Case ConditionalExpressionCase `PrettyPrint:"stringer,zero"` 1102 ConditionalExpression *ConditionalExpression 1103 Expression *Expression 1104 LogicalOrExpression *LogicalOrExpression 1105 Token Token 1106 Token2 Token 1107 } 1108 1109 // String implements fmt.Stringer. 1110 func (n *ConditionalExpression) String() string { return PrettyString(n) } 1111 1112 // Position reports the position of the first component of n, if available. 1113 func (n *ConditionalExpression) Position() (r token.Position) { 1114 if n == nil { 1115 return r 1116 } 1117 1118 switch n.Case { 1119 case 0: 1120 return n.LogicalOrExpression.Position() 1121 case 1: 1122 if p := n.LogicalOrExpression.Position(); p.IsValid() { 1123 return p 1124 } 1125 1126 if p := n.Token.Position(); p.IsValid() { 1127 return p 1128 } 1129 1130 if p := n.Expression.Position(); p.IsValid() { 1131 return p 1132 } 1133 1134 if p := n.Token2.Position(); p.IsValid() { 1135 return p 1136 } 1137 1138 return n.ConditionalExpression.Position() 1139 default: 1140 panic("internal error") 1141 } 1142 } 1143 1144 // ConstantExpression represents data reduced by production: 1145 // 1146 // ConstantExpression: 1147 // ConditionalExpression 1148 type ConstantExpression struct { 1149 Operand Operand 1150 ConditionalExpression *ConditionalExpression 1151 } 1152 1153 // String implements fmt.Stringer. 1154 func (n *ConstantExpression) String() string { return PrettyString(n) } 1155 1156 // Position reports the position of the first component of n, if available. 1157 func (n *ConstantExpression) Position() (r token.Position) { 1158 if n == nil { 1159 return r 1160 } 1161 1162 return n.ConditionalExpression.Position() 1163 } 1164 1165 // Declaration represents data reduced by production: 1166 // 1167 // Declaration: 1168 // DeclarationSpecifiers InitDeclaratorList ';' 1169 type Declaration struct { 1170 DeclarationSpecifiers *DeclarationSpecifiers 1171 InitDeclaratorList *InitDeclaratorList 1172 Token Token 1173 } 1174 1175 // String implements fmt.Stringer. 1176 func (n *Declaration) String() string { return PrettyString(n) } 1177 1178 // Position reports the position of the first component of n, if available. 1179 func (n *Declaration) Position() (r token.Position) { 1180 if n == nil { 1181 return r 1182 } 1183 1184 if p := n.DeclarationSpecifiers.Position(); p.IsValid() { 1185 return p 1186 } 1187 1188 if p := n.InitDeclaratorList.Position(); p.IsValid() { 1189 return p 1190 } 1191 1192 return n.Token.Position() 1193 } 1194 1195 // DeclarationList represents data reduced by productions: 1196 // 1197 // DeclarationList: 1198 // Declaration 1199 // | DeclarationList Declaration 1200 type DeclarationList struct { 1201 Declaration *Declaration 1202 DeclarationList *DeclarationList 1203 } 1204 1205 // String implements fmt.Stringer. 1206 func (n *DeclarationList) String() string { return PrettyString(n) } 1207 1208 // Position reports the position of the first component of n, if available. 1209 func (n *DeclarationList) Position() (r token.Position) { 1210 if n == nil { 1211 return r 1212 } 1213 1214 return n.Declaration.Position() 1215 } 1216 1217 // DeclarationSpecifiersCase represents case numbers of production DeclarationSpecifiers 1218 type DeclarationSpecifiersCase int 1219 1220 // Values of type DeclarationSpecifiersCase 1221 const ( 1222 DeclarationSpecifiersStorage DeclarationSpecifiersCase = iota 1223 DeclarationSpecifiersTypeSpec 1224 DeclarationSpecifiersTypeQual 1225 DeclarationSpecifiersFunc 1226 DeclarationSpecifiersAlignSpec 1227 DeclarationSpecifiersAttribute 1228 ) 1229 1230 // String implements fmt.Stringer 1231 func (n DeclarationSpecifiersCase) String() string { 1232 switch n { 1233 case DeclarationSpecifiersStorage: 1234 return "DeclarationSpecifiersStorage" 1235 case DeclarationSpecifiersTypeSpec: 1236 return "DeclarationSpecifiersTypeSpec" 1237 case DeclarationSpecifiersTypeQual: 1238 return "DeclarationSpecifiersTypeQual" 1239 case DeclarationSpecifiersFunc: 1240 return "DeclarationSpecifiersFunc" 1241 case DeclarationSpecifiersAlignSpec: 1242 return "DeclarationSpecifiersAlignSpec" 1243 case DeclarationSpecifiersAttribute: 1244 return "DeclarationSpecifiersAttribute" 1245 default: 1246 return fmt.Sprintf("DeclarationSpecifiersCase(%v)", int(n)) 1247 } 1248 } 1249 1250 // DeclarationSpecifiers represents data reduced by productions: 1251 // 1252 // DeclarationSpecifiers: 1253 // StorageClassSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersStorage 1254 // | TypeSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersTypeSpec 1255 // | TypeQualifier DeclarationSpecifiers // Case DeclarationSpecifiersTypeQual 1256 // | FunctionSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersFunc 1257 // | AlignmentSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersAlignSpec 1258 // | AttributeSpecifier DeclarationSpecifiers // Case DeclarationSpecifiersAttribute 1259 type DeclarationSpecifiers struct { 1260 class storageClass 1261 AlignmentSpecifier *AlignmentSpecifier 1262 AttributeSpecifier *AttributeSpecifier 1263 Case DeclarationSpecifiersCase `PrettyPrint:"stringer,zero"` 1264 DeclarationSpecifiers *DeclarationSpecifiers 1265 FunctionSpecifier *FunctionSpecifier 1266 StorageClassSpecifier *StorageClassSpecifier 1267 TypeQualifier *TypeQualifier 1268 TypeSpecifier *TypeSpecifier 1269 } 1270 1271 // String implements fmt.Stringer. 1272 func (n *DeclarationSpecifiers) String() string { return PrettyString(n) } 1273 1274 // Position reports the position of the first component of n, if available. 1275 func (n *DeclarationSpecifiers) Position() (r token.Position) { 1276 if n == nil { 1277 return r 1278 } 1279 1280 switch n.Case { 1281 case 4: 1282 if p := n.AlignmentSpecifier.Position(); p.IsValid() { 1283 return p 1284 } 1285 1286 return n.DeclarationSpecifiers.Position() 1287 case 5: 1288 if p := n.AttributeSpecifier.Position(); p.IsValid() { 1289 return p 1290 } 1291 1292 return n.DeclarationSpecifiers.Position() 1293 case 3: 1294 if p := n.FunctionSpecifier.Position(); p.IsValid() { 1295 return p 1296 } 1297 1298 return n.DeclarationSpecifiers.Position() 1299 case 0: 1300 if p := n.StorageClassSpecifier.Position(); p.IsValid() { 1301 return p 1302 } 1303 1304 return n.DeclarationSpecifiers.Position() 1305 case 2: 1306 if p := n.TypeQualifier.Position(); p.IsValid() { 1307 return p 1308 } 1309 1310 return n.DeclarationSpecifiers.Position() 1311 case 1: 1312 if p := n.TypeSpecifier.Position(); p.IsValid() { 1313 return p 1314 } 1315 1316 return n.DeclarationSpecifiers.Position() 1317 default: 1318 panic("internal error") 1319 } 1320 } 1321 1322 // Declarator represents data reduced by production: 1323 // 1324 // Declarator: 1325 // Pointer DirectDeclarator AttributeSpecifierList 1326 type Declarator struct { 1327 Linkage Linkage 1328 Read int 1329 StorageClass StorageClass 1330 Write int 1331 funcDefinition *FunctionDefinition 1332 lhs map[*Declarator]struct{} 1333 td typeDescriptor 1334 typ Type 1335 AddressTaken bool 1336 IsParameter bool 1337 IsTypedefName bool 1338 SubjectOfAsgnOp bool 1339 SubjectOfIncDec bool 1340 called bool 1341 fnDef bool 1342 hasInitializer bool 1343 implicit bool 1344 AttributeSpecifierList *AttributeSpecifierList 1345 DirectDeclarator *DirectDeclarator 1346 Pointer *Pointer 1347 } 1348 1349 // String implements fmt.Stringer. 1350 func (n *Declarator) String() string { return PrettyString(n) } 1351 1352 // Position reports the position of the first component of n, if available. 1353 func (n *Declarator) Position() (r token.Position) { 1354 if n == nil { 1355 return r 1356 } 1357 1358 if p := n.Pointer.Position(); p.IsValid() { 1359 return p 1360 } 1361 1362 if p := n.DirectDeclarator.Position(); p.IsValid() { 1363 return p 1364 } 1365 1366 return n.AttributeSpecifierList.Position() 1367 } 1368 1369 // Designation represents data reduced by production: 1370 // 1371 // Designation: 1372 // DesignatorList '=' 1373 type Designation struct { 1374 DesignatorList *DesignatorList 1375 Token Token 1376 } 1377 1378 // String implements fmt.Stringer. 1379 func (n *Designation) String() string { return PrettyString(n) } 1380 1381 // Position reports the position of the first component of n, if available. 1382 func (n *Designation) Position() (r token.Position) { 1383 if n == nil { 1384 return r 1385 } 1386 1387 if p := n.DesignatorList.Position(); p.IsValid() { 1388 return p 1389 } 1390 1391 return n.Token.Position() 1392 } 1393 1394 // DesignatorCase represents case numbers of production Designator 1395 type DesignatorCase int 1396 1397 // Values of type DesignatorCase 1398 const ( 1399 DesignatorIndex DesignatorCase = iota 1400 DesignatorField 1401 DesignatorField2 1402 ) 1403 1404 // String implements fmt.Stringer 1405 func (n DesignatorCase) String() string { 1406 switch n { 1407 case DesignatorIndex: 1408 return "DesignatorIndex" 1409 case DesignatorField: 1410 return "DesignatorField" 1411 case DesignatorField2: 1412 return "DesignatorField2" 1413 default: 1414 return fmt.Sprintf("DesignatorCase(%v)", int(n)) 1415 } 1416 } 1417 1418 // Designator represents data reduced by productions: 1419 // 1420 // Designator: 1421 // '[' ConstantExpression ']' // Case DesignatorIndex 1422 // | '.' IDENTIFIER // Case DesignatorField 1423 // | IDENTIFIER ':' // Case DesignatorField2 1424 type Designator struct { 1425 lexicalScope Scope 1426 Case DesignatorCase `PrettyPrint:"stringer,zero"` 1427 ConstantExpression *ConstantExpression 1428 Token Token 1429 Token2 Token 1430 } 1431 1432 // String implements fmt.Stringer. 1433 func (n *Designator) String() string { return PrettyString(n) } 1434 1435 // Position reports the position of the first component of n, if available. 1436 func (n *Designator) Position() (r token.Position) { 1437 if n == nil { 1438 return r 1439 } 1440 1441 switch n.Case { 1442 case 0: 1443 if p := n.Token.Position(); p.IsValid() { 1444 return p 1445 } 1446 1447 if p := n.ConstantExpression.Position(); p.IsValid() { 1448 return p 1449 } 1450 1451 return n.Token2.Position() 1452 case 1, 2: 1453 if p := n.Token.Position(); p.IsValid() { 1454 return p 1455 } 1456 1457 return n.Token2.Position() 1458 default: 1459 panic("internal error") 1460 } 1461 } 1462 1463 // DesignatorList represents data reduced by productions: 1464 // 1465 // DesignatorList: 1466 // Designator 1467 // | DesignatorList Designator 1468 type DesignatorList struct { 1469 Designator *Designator 1470 DesignatorList *DesignatorList 1471 } 1472 1473 // String implements fmt.Stringer. 1474 func (n *DesignatorList) String() string { return PrettyString(n) } 1475 1476 // Position reports the position of the first component of n, if available. 1477 func (n *DesignatorList) Position() (r token.Position) { 1478 if n == nil { 1479 return r 1480 } 1481 1482 return n.Designator.Position() 1483 } 1484 1485 // DirectAbstractDeclaratorCase represents case numbers of production DirectAbstractDeclarator 1486 type DirectAbstractDeclaratorCase int 1487 1488 // Values of type DirectAbstractDeclaratorCase 1489 const ( 1490 DirectAbstractDeclaratorDecl DirectAbstractDeclaratorCase = iota 1491 DirectAbstractDeclaratorArr 1492 DirectAbstractDeclaratorStaticArr 1493 DirectAbstractDeclaratorArrStatic 1494 DirectAbstractDeclaratorArrStar 1495 DirectAbstractDeclaratorFunc 1496 ) 1497 1498 // String implements fmt.Stringer 1499 func (n DirectAbstractDeclaratorCase) String() string { 1500 switch n { 1501 case DirectAbstractDeclaratorDecl: 1502 return "DirectAbstractDeclaratorDecl" 1503 case DirectAbstractDeclaratorArr: 1504 return "DirectAbstractDeclaratorArr" 1505 case DirectAbstractDeclaratorStaticArr: 1506 return "DirectAbstractDeclaratorStaticArr" 1507 case DirectAbstractDeclaratorArrStatic: 1508 return "DirectAbstractDeclaratorArrStatic" 1509 case DirectAbstractDeclaratorArrStar: 1510 return "DirectAbstractDeclaratorArrStar" 1511 case DirectAbstractDeclaratorFunc: 1512 return "DirectAbstractDeclaratorFunc" 1513 default: 1514 return fmt.Sprintf("DirectAbstractDeclaratorCase(%v)", int(n)) 1515 } 1516 } 1517 1518 // DirectAbstractDeclarator represents data reduced by productions: 1519 // 1520 // DirectAbstractDeclarator: 1521 // '(' AbstractDeclarator ')' // Case DirectAbstractDeclaratorDecl 1522 // | DirectAbstractDeclarator '[' TypeQualifiers AssignmentExpression ']' // Case DirectAbstractDeclaratorArr 1523 // | DirectAbstractDeclarator '[' "static" TypeQualifiers AssignmentExpression ']' // Case DirectAbstractDeclaratorStaticArr 1524 // | DirectAbstractDeclarator '[' TypeQualifiers "static" AssignmentExpression ']' // Case DirectAbstractDeclaratorArrStatic 1525 // | DirectAbstractDeclarator '[' '*' ']' // Case DirectAbstractDeclaratorArrStar 1526 // | DirectAbstractDeclarator '(' ParameterTypeList ')' // Case DirectAbstractDeclaratorFunc 1527 type DirectAbstractDeclarator struct { 1528 paramScope Scope 1529 typeQualifiers *typeBase 1530 AbstractDeclarator *AbstractDeclarator 1531 AssignmentExpression *AssignmentExpression 1532 Case DirectAbstractDeclaratorCase `PrettyPrint:"stringer,zero"` 1533 DirectAbstractDeclarator *DirectAbstractDeclarator 1534 ParameterTypeList *ParameterTypeList 1535 Token Token 1536 Token2 Token 1537 Token3 Token 1538 TypeQualifiers *TypeQualifiers 1539 } 1540 1541 // String implements fmt.Stringer. 1542 func (n *DirectAbstractDeclarator) String() string { return PrettyString(n) } 1543 1544 // Position reports the position of the first component of n, if available. 1545 func (n *DirectAbstractDeclarator) Position() (r token.Position) { 1546 if n == nil { 1547 return r 1548 } 1549 1550 switch n.Case { 1551 case 5: 1552 if p := n.DirectAbstractDeclarator.Position(); p.IsValid() { 1553 return p 1554 } 1555 1556 if p := n.Token.Position(); p.IsValid() { 1557 return p 1558 } 1559 1560 if p := n.ParameterTypeList.Position(); p.IsValid() { 1561 return p 1562 } 1563 1564 return n.Token2.Position() 1565 case 4: 1566 if p := n.DirectAbstractDeclarator.Position(); p.IsValid() { 1567 return p 1568 } 1569 1570 if p := n.Token.Position(); p.IsValid() { 1571 return p 1572 } 1573 1574 if p := n.Token2.Position(); p.IsValid() { 1575 return p 1576 } 1577 1578 return n.Token3.Position() 1579 case 2: 1580 if p := n.DirectAbstractDeclarator.Position(); p.IsValid() { 1581 return p 1582 } 1583 1584 if p := n.Token.Position(); p.IsValid() { 1585 return p 1586 } 1587 1588 if p := n.Token2.Position(); p.IsValid() { 1589 return p 1590 } 1591 1592 if p := n.TypeQualifiers.Position(); p.IsValid() { 1593 return p 1594 } 1595 1596 if p := n.AssignmentExpression.Position(); p.IsValid() { 1597 return p 1598 } 1599 1600 return n.Token3.Position() 1601 case 1: 1602 if p := n.DirectAbstractDeclarator.Position(); p.IsValid() { 1603 return p 1604 } 1605 1606 if p := n.Token.Position(); p.IsValid() { 1607 return p 1608 } 1609 1610 if p := n.TypeQualifiers.Position(); p.IsValid() { 1611 return p 1612 } 1613 1614 if p := n.AssignmentExpression.Position(); p.IsValid() { 1615 return p 1616 } 1617 1618 return n.Token2.Position() 1619 case 3: 1620 if p := n.DirectAbstractDeclarator.Position(); p.IsValid() { 1621 return p 1622 } 1623 1624 if p := n.Token.Position(); p.IsValid() { 1625 return p 1626 } 1627 1628 if p := n.TypeQualifiers.Position(); p.IsValid() { 1629 return p 1630 } 1631 1632 if p := n.Token2.Position(); p.IsValid() { 1633 return p 1634 } 1635 1636 if p := n.AssignmentExpression.Position(); p.IsValid() { 1637 return p 1638 } 1639 1640 return n.Token3.Position() 1641 case 0: 1642 if p := n.Token.Position(); p.IsValid() { 1643 return p 1644 } 1645 1646 if p := n.AbstractDeclarator.Position(); p.IsValid() { 1647 return p 1648 } 1649 1650 return n.Token2.Position() 1651 default: 1652 panic("internal error") 1653 } 1654 } 1655 1656 // DirectDeclaratorCase represents case numbers of production DirectDeclarator 1657 type DirectDeclaratorCase int 1658 1659 // Values of type DirectDeclaratorCase 1660 const ( 1661 DirectDeclaratorIdent DirectDeclaratorCase = iota 1662 DirectDeclaratorDecl 1663 DirectDeclaratorArr 1664 DirectDeclaratorStaticArr 1665 DirectDeclaratorArrStatic 1666 DirectDeclaratorStar 1667 DirectDeclaratorFuncParam 1668 DirectDeclaratorFuncIdent 1669 ) 1670 1671 // String implements fmt.Stringer 1672 func (n DirectDeclaratorCase) String() string { 1673 switch n { 1674 case DirectDeclaratorIdent: 1675 return "DirectDeclaratorIdent" 1676 case DirectDeclaratorDecl: 1677 return "DirectDeclaratorDecl" 1678 case DirectDeclaratorArr: 1679 return "DirectDeclaratorArr" 1680 case DirectDeclaratorStaticArr: 1681 return "DirectDeclaratorStaticArr" 1682 case DirectDeclaratorArrStatic: 1683 return "DirectDeclaratorArrStatic" 1684 case DirectDeclaratorStar: 1685 return "DirectDeclaratorStar" 1686 case DirectDeclaratorFuncParam: 1687 return "DirectDeclaratorFuncParam" 1688 case DirectDeclaratorFuncIdent: 1689 return "DirectDeclaratorFuncIdent" 1690 default: 1691 return fmt.Sprintf("DirectDeclaratorCase(%v)", int(n)) 1692 } 1693 } 1694 1695 // DirectDeclarator represents data reduced by productions: 1696 // 1697 // DirectDeclarator: 1698 // IDENTIFIER Asm // Case DirectDeclaratorIdent 1699 // | '(' AttributeSpecifierList Declarator ')' // Case DirectDeclaratorDecl 1700 // | DirectDeclarator '[' TypeQualifiers AssignmentExpression ']' // Case DirectDeclaratorArr 1701 // | DirectDeclarator '[' "static" TypeQualifiers AssignmentExpression ']' // Case DirectDeclaratorStaticArr 1702 // | DirectDeclarator '[' TypeQualifiers "static" AssignmentExpression ']' // Case DirectDeclaratorArrStatic 1703 // | DirectDeclarator '[' TypeQualifiers '*' ']' // Case DirectDeclaratorStar 1704 // | DirectDeclarator '(' ParameterTypeList ')' // Case DirectDeclaratorFuncParam 1705 // | DirectDeclarator '(' IdentifierList ')' // Case DirectDeclaratorFuncIdent 1706 type DirectDeclarator struct { 1707 lexicalScope Scope 1708 paramScope Scope 1709 typeQualifiers *typeBase 1710 idListNoDeclList bool 1711 Asm *Asm 1712 AssignmentExpression *AssignmentExpression 1713 AttributeSpecifierList *AttributeSpecifierList 1714 Case DirectDeclaratorCase `PrettyPrint:"stringer,zero"` 1715 Declarator *Declarator 1716 DirectDeclarator *DirectDeclarator 1717 IdentifierList *IdentifierList 1718 ParameterTypeList *ParameterTypeList 1719 Token Token 1720 Token2 Token 1721 Token3 Token 1722 TypeQualifiers *TypeQualifiers 1723 } 1724 1725 // String implements fmt.Stringer. 1726 func (n *DirectDeclarator) String() string { return PrettyString(n) } 1727 1728 // Position reports the position of the first component of n, if available. 1729 func (n *DirectDeclarator) Position() (r token.Position) { 1730 if n == nil { 1731 return r 1732 } 1733 1734 switch n.Case { 1735 case 7: 1736 if p := n.DirectDeclarator.Position(); p.IsValid() { 1737 return p 1738 } 1739 1740 if p := n.Token.Position(); p.IsValid() { 1741 return p 1742 } 1743 1744 if p := n.IdentifierList.Position(); p.IsValid() { 1745 return p 1746 } 1747 1748 return n.Token2.Position() 1749 case 6: 1750 if p := n.DirectDeclarator.Position(); p.IsValid() { 1751 return p 1752 } 1753 1754 if p := n.Token.Position(); p.IsValid() { 1755 return p 1756 } 1757 1758 if p := n.ParameterTypeList.Position(); p.IsValid() { 1759 return p 1760 } 1761 1762 return n.Token2.Position() 1763 case 3: 1764 if p := n.DirectDeclarator.Position(); p.IsValid() { 1765 return p 1766 } 1767 1768 if p := n.Token.Position(); p.IsValid() { 1769 return p 1770 } 1771 1772 if p := n.Token2.Position(); p.IsValid() { 1773 return p 1774 } 1775 1776 if p := n.TypeQualifiers.Position(); p.IsValid() { 1777 return p 1778 } 1779 1780 if p := n.AssignmentExpression.Position(); p.IsValid() { 1781 return p 1782 } 1783 1784 return n.Token3.Position() 1785 case 2: 1786 if p := n.DirectDeclarator.Position(); p.IsValid() { 1787 return p 1788 } 1789 1790 if p := n.Token.Position(); p.IsValid() { 1791 return p 1792 } 1793 1794 if p := n.TypeQualifiers.Position(); p.IsValid() { 1795 return p 1796 } 1797 1798 if p := n.AssignmentExpression.Position(); p.IsValid() { 1799 return p 1800 } 1801 1802 return n.Token2.Position() 1803 case 4: 1804 if p := n.DirectDeclarator.Position(); p.IsValid() { 1805 return p 1806 } 1807 1808 if p := n.Token.Position(); p.IsValid() { 1809 return p 1810 } 1811 1812 if p := n.TypeQualifiers.Position(); p.IsValid() { 1813 return p 1814 } 1815 1816 if p := n.Token2.Position(); p.IsValid() { 1817 return p 1818 } 1819 1820 if p := n.AssignmentExpression.Position(); p.IsValid() { 1821 return p 1822 } 1823 1824 return n.Token3.Position() 1825 case 5: 1826 if p := n.DirectDeclarator.Position(); p.IsValid() { 1827 return p 1828 } 1829 1830 if p := n.Token.Position(); p.IsValid() { 1831 return p 1832 } 1833 1834 if p := n.TypeQualifiers.Position(); p.IsValid() { 1835 return p 1836 } 1837 1838 if p := n.Token2.Position(); p.IsValid() { 1839 return p 1840 } 1841 1842 return n.Token3.Position() 1843 case 0: 1844 if p := n.Token.Position(); p.IsValid() { 1845 return p 1846 } 1847 1848 return n.Asm.Position() 1849 case 1: 1850 if p := n.Token.Position(); p.IsValid() { 1851 return p 1852 } 1853 1854 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 1855 return p 1856 } 1857 1858 if p := n.Declarator.Position(); p.IsValid() { 1859 return p 1860 } 1861 1862 return n.Token2.Position() 1863 default: 1864 panic("internal error") 1865 } 1866 } 1867 1868 // EnumSpecifierCase represents case numbers of production EnumSpecifier 1869 type EnumSpecifierCase int 1870 1871 // Values of type EnumSpecifierCase 1872 const ( 1873 EnumSpecifierDef EnumSpecifierCase = iota 1874 EnumSpecifierTag 1875 ) 1876 1877 // String implements fmt.Stringer 1878 func (n EnumSpecifierCase) String() string { 1879 switch n { 1880 case EnumSpecifierDef: 1881 return "EnumSpecifierDef" 1882 case EnumSpecifierTag: 1883 return "EnumSpecifierTag" 1884 default: 1885 return fmt.Sprintf("EnumSpecifierCase(%v)", int(n)) 1886 } 1887 } 1888 1889 // EnumSpecifier represents data reduced by productions: 1890 // 1891 // EnumSpecifier: 1892 // "enum" AttributeSpecifierList IDENTIFIER '{' EnumeratorList ',' '}' // Case EnumSpecifierDef 1893 // | "enum" AttributeSpecifierList IDENTIFIER // Case EnumSpecifierTag 1894 type EnumSpecifier struct { 1895 lexicalScope Scope 1896 typ Type 1897 min Value 1898 max Value 1899 AttributeSpecifierList *AttributeSpecifierList 1900 Case EnumSpecifierCase `PrettyPrint:"stringer,zero"` 1901 EnumeratorList *EnumeratorList 1902 Token Token 1903 Token2 Token 1904 Token3 Token 1905 Token4 Token 1906 Token5 Token 1907 } 1908 1909 // String implements fmt.Stringer. 1910 func (n *EnumSpecifier) String() string { return PrettyString(n) } 1911 1912 // Position reports the position of the first component of n, if available. 1913 func (n *EnumSpecifier) Position() (r token.Position) { 1914 if n == nil { 1915 return r 1916 } 1917 1918 switch n.Case { 1919 case 1: 1920 if p := n.Token.Position(); p.IsValid() { 1921 return p 1922 } 1923 1924 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 1925 return p 1926 } 1927 1928 return n.Token2.Position() 1929 case 0: 1930 if p := n.Token.Position(); p.IsValid() { 1931 return p 1932 } 1933 1934 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 1935 return p 1936 } 1937 1938 if p := n.Token2.Position(); p.IsValid() { 1939 return p 1940 } 1941 1942 if p := n.Token3.Position(); p.IsValid() { 1943 return p 1944 } 1945 1946 if p := n.EnumeratorList.Position(); p.IsValid() { 1947 return p 1948 } 1949 1950 if p := n.Token4.Position(); p.IsValid() { 1951 return p 1952 } 1953 1954 return n.Token5.Position() 1955 default: 1956 panic("internal error") 1957 } 1958 } 1959 1960 // EnumeratorCase represents case numbers of production Enumerator 1961 type EnumeratorCase int 1962 1963 // Values of type EnumeratorCase 1964 const ( 1965 EnumeratorIdent EnumeratorCase = iota 1966 EnumeratorExpr 1967 ) 1968 1969 // String implements fmt.Stringer 1970 func (n EnumeratorCase) String() string { 1971 switch n { 1972 case EnumeratorIdent: 1973 return "EnumeratorIdent" 1974 case EnumeratorExpr: 1975 return "EnumeratorExpr" 1976 default: 1977 return fmt.Sprintf("EnumeratorCase(%v)", int(n)) 1978 } 1979 } 1980 1981 // Enumerator represents data reduced by productions: 1982 // 1983 // Enumerator: 1984 // IDENTIFIER AttributeSpecifierList // Case EnumeratorIdent 1985 // | IDENTIFIER AttributeSpecifierList '=' ConstantExpression // Case EnumeratorExpr 1986 type Enumerator struct { 1987 lexicalScope Scope 1988 Operand Operand 1989 AttributeSpecifierList *AttributeSpecifierList 1990 Case EnumeratorCase `PrettyPrint:"stringer,zero"` 1991 ConstantExpression *ConstantExpression 1992 Token Token 1993 Token2 Token 1994 } 1995 1996 // String implements fmt.Stringer. 1997 func (n *Enumerator) String() string { return PrettyString(n) } 1998 1999 // Position reports the position of the first component of n, if available. 2000 func (n *Enumerator) Position() (r token.Position) { 2001 if n == nil { 2002 return r 2003 } 2004 2005 switch n.Case { 2006 case 0: 2007 if p := n.Token.Position(); p.IsValid() { 2008 return p 2009 } 2010 2011 return n.AttributeSpecifierList.Position() 2012 case 1: 2013 if p := n.Token.Position(); p.IsValid() { 2014 return p 2015 } 2016 2017 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 2018 return p 2019 } 2020 2021 if p := n.Token2.Position(); p.IsValid() { 2022 return p 2023 } 2024 2025 return n.ConstantExpression.Position() 2026 default: 2027 panic("internal error") 2028 } 2029 } 2030 2031 // EnumeratorList represents data reduced by productions: 2032 // 2033 // EnumeratorList: 2034 // Enumerator 2035 // | EnumeratorList ',' Enumerator 2036 type EnumeratorList struct { 2037 Enumerator *Enumerator 2038 EnumeratorList *EnumeratorList 2039 Token Token 2040 } 2041 2042 // String implements fmt.Stringer. 2043 func (n *EnumeratorList) String() string { return PrettyString(n) } 2044 2045 // Position reports the position of the first component of n, if available. 2046 func (n *EnumeratorList) Position() (r token.Position) { 2047 if n == nil { 2048 return r 2049 } 2050 2051 return n.Enumerator.Position() 2052 } 2053 2054 // EqualityExpressionCase represents case numbers of production EqualityExpression 2055 type EqualityExpressionCase int 2056 2057 // Values of type EqualityExpressionCase 2058 const ( 2059 EqualityExpressionRel EqualityExpressionCase = iota 2060 EqualityExpressionEq 2061 EqualityExpressionNeq 2062 ) 2063 2064 // String implements fmt.Stringer 2065 func (n EqualityExpressionCase) String() string { 2066 switch n { 2067 case EqualityExpressionRel: 2068 return "EqualityExpressionRel" 2069 case EqualityExpressionEq: 2070 return "EqualityExpressionEq" 2071 case EqualityExpressionNeq: 2072 return "EqualityExpressionNeq" 2073 default: 2074 return fmt.Sprintf("EqualityExpressionCase(%v)", int(n)) 2075 } 2076 } 2077 2078 // EqualityExpression represents data reduced by productions: 2079 // 2080 // EqualityExpression: 2081 // RelationalExpression // Case EqualityExpressionRel 2082 // | EqualityExpression "==" RelationalExpression // Case EqualityExpressionEq 2083 // | EqualityExpression "!=" RelationalExpression // Case EqualityExpressionNeq 2084 type EqualityExpression struct { 2085 Operand Operand 2086 promote Type 2087 IsSideEffectsFree bool 2088 Case EqualityExpressionCase `PrettyPrint:"stringer,zero"` 2089 EqualityExpression *EqualityExpression 2090 RelationalExpression *RelationalExpression 2091 Token Token 2092 } 2093 2094 // String implements fmt.Stringer. 2095 func (n *EqualityExpression) String() string { return PrettyString(n) } 2096 2097 // Position reports the position of the first component of n, if available. 2098 func (n *EqualityExpression) Position() (r token.Position) { 2099 if n == nil { 2100 return r 2101 } 2102 2103 switch n.Case { 2104 case 1, 2: 2105 if p := n.EqualityExpression.Position(); p.IsValid() { 2106 return p 2107 } 2108 2109 if p := n.Token.Position(); p.IsValid() { 2110 return p 2111 } 2112 2113 return n.RelationalExpression.Position() 2114 case 0: 2115 return n.RelationalExpression.Position() 2116 default: 2117 panic("internal error") 2118 } 2119 } 2120 2121 // ExclusiveOrExpressionCase represents case numbers of production ExclusiveOrExpression 2122 type ExclusiveOrExpressionCase int 2123 2124 // Values of type ExclusiveOrExpressionCase 2125 const ( 2126 ExclusiveOrExpressionAnd ExclusiveOrExpressionCase = iota 2127 ExclusiveOrExpressionXor 2128 ) 2129 2130 // String implements fmt.Stringer 2131 func (n ExclusiveOrExpressionCase) String() string { 2132 switch n { 2133 case ExclusiveOrExpressionAnd: 2134 return "ExclusiveOrExpressionAnd" 2135 case ExclusiveOrExpressionXor: 2136 return "ExclusiveOrExpressionXor" 2137 default: 2138 return fmt.Sprintf("ExclusiveOrExpressionCase(%v)", int(n)) 2139 } 2140 } 2141 2142 // ExclusiveOrExpression represents data reduced by productions: 2143 // 2144 // ExclusiveOrExpression: 2145 // AndExpression // Case ExclusiveOrExpressionAnd 2146 // | ExclusiveOrExpression '^' AndExpression // Case ExclusiveOrExpressionXor 2147 type ExclusiveOrExpression struct { 2148 Operand Operand 2149 promote Type 2150 IsSideEffectsFree bool 2151 AndExpression *AndExpression 2152 Case ExclusiveOrExpressionCase `PrettyPrint:"stringer,zero"` 2153 ExclusiveOrExpression *ExclusiveOrExpression 2154 Token Token 2155 } 2156 2157 // String implements fmt.Stringer. 2158 func (n *ExclusiveOrExpression) String() string { return PrettyString(n) } 2159 2160 // Position reports the position of the first component of n, if available. 2161 func (n *ExclusiveOrExpression) Position() (r token.Position) { 2162 if n == nil { 2163 return r 2164 } 2165 2166 switch n.Case { 2167 case 0: 2168 return n.AndExpression.Position() 2169 case 1: 2170 if p := n.ExclusiveOrExpression.Position(); p.IsValid() { 2171 return p 2172 } 2173 2174 if p := n.Token.Position(); p.IsValid() { 2175 return p 2176 } 2177 2178 return n.AndExpression.Position() 2179 default: 2180 panic("internal error") 2181 } 2182 } 2183 2184 // ExpressionCase represents case numbers of production Expression 2185 type ExpressionCase int 2186 2187 // Values of type ExpressionCase 2188 const ( 2189 ExpressionAssign ExpressionCase = iota 2190 ExpressionComma 2191 ) 2192 2193 // String implements fmt.Stringer 2194 func (n ExpressionCase) String() string { 2195 switch n { 2196 case ExpressionAssign: 2197 return "ExpressionAssign" 2198 case ExpressionComma: 2199 return "ExpressionComma" 2200 default: 2201 return fmt.Sprintf("ExpressionCase(%v)", int(n)) 2202 } 2203 } 2204 2205 // Expression represents data reduced by productions: 2206 // 2207 // Expression: 2208 // AssignmentExpression // Case ExpressionAssign 2209 // | Expression ',' AssignmentExpression // Case ExpressionComma 2210 type Expression struct { 2211 Operand Operand 2212 IsSideEffectsFree bool 2213 AssignmentExpression *AssignmentExpression 2214 Case ExpressionCase `PrettyPrint:"stringer,zero"` 2215 Expression *Expression 2216 Token Token 2217 } 2218 2219 // String implements fmt.Stringer. 2220 func (n *Expression) String() string { return PrettyString(n) } 2221 2222 // Position reports the position of the first component of n, if available. 2223 func (n *Expression) Position() (r token.Position) { 2224 if n == nil { 2225 return r 2226 } 2227 2228 switch n.Case { 2229 case 0: 2230 return n.AssignmentExpression.Position() 2231 case 1: 2232 if p := n.Expression.Position(); p.IsValid() { 2233 return p 2234 } 2235 2236 if p := n.Token.Position(); p.IsValid() { 2237 return p 2238 } 2239 2240 return n.AssignmentExpression.Position() 2241 default: 2242 panic("internal error") 2243 } 2244 } 2245 2246 // ExpressionList represents data reduced by productions: 2247 // 2248 // ExpressionList: 2249 // AssignmentExpression 2250 // | ExpressionList ',' AssignmentExpression 2251 type ExpressionList struct { 2252 AssignmentExpression *AssignmentExpression 2253 ExpressionList *ExpressionList 2254 Token Token 2255 } 2256 2257 // String implements fmt.Stringer. 2258 func (n *ExpressionList) String() string { return PrettyString(n) } 2259 2260 // Position reports the position of the first component of n, if available. 2261 func (n *ExpressionList) Position() (r token.Position) { 2262 if n == nil { 2263 return r 2264 } 2265 2266 return n.AssignmentExpression.Position() 2267 } 2268 2269 // ExpressionStatement represents data reduced by production: 2270 // 2271 // ExpressionStatement: 2272 // Expression AttributeSpecifierList ';' 2273 type ExpressionStatement struct { 2274 AttributeSpecifierList *AttributeSpecifierList 2275 Expression *Expression 2276 Token Token 2277 } 2278 2279 // String implements fmt.Stringer. 2280 func (n *ExpressionStatement) String() string { return PrettyString(n) } 2281 2282 // Position reports the position of the first component of n, if available. 2283 func (n *ExpressionStatement) Position() (r token.Position) { 2284 if n == nil { 2285 return r 2286 } 2287 2288 if p := n.Expression.Position(); p.IsValid() { 2289 return p 2290 } 2291 2292 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 2293 return p 2294 } 2295 2296 return n.Token.Position() 2297 } 2298 2299 // ExternalDeclarationCase represents case numbers of production ExternalDeclaration 2300 type ExternalDeclarationCase int 2301 2302 // Values of type ExternalDeclarationCase 2303 const ( 2304 ExternalDeclarationFuncDef ExternalDeclarationCase = iota 2305 ExternalDeclarationDecl 2306 ExternalDeclarationAsm 2307 ExternalDeclarationAsmStmt 2308 ExternalDeclarationEmpty 2309 ExternalDeclarationPragma 2310 ) 2311 2312 // String implements fmt.Stringer 2313 func (n ExternalDeclarationCase) String() string { 2314 switch n { 2315 case ExternalDeclarationFuncDef: 2316 return "ExternalDeclarationFuncDef" 2317 case ExternalDeclarationDecl: 2318 return "ExternalDeclarationDecl" 2319 case ExternalDeclarationAsm: 2320 return "ExternalDeclarationAsm" 2321 case ExternalDeclarationAsmStmt: 2322 return "ExternalDeclarationAsmStmt" 2323 case ExternalDeclarationEmpty: 2324 return "ExternalDeclarationEmpty" 2325 case ExternalDeclarationPragma: 2326 return "ExternalDeclarationPragma" 2327 default: 2328 return fmt.Sprintf("ExternalDeclarationCase(%v)", int(n)) 2329 } 2330 } 2331 2332 // ExternalDeclaration represents data reduced by productions: 2333 // 2334 // ExternalDeclaration: 2335 // FunctionDefinition // Case ExternalDeclarationFuncDef 2336 // | Declaration // Case ExternalDeclarationDecl 2337 // | AsmFunctionDefinition // Case ExternalDeclarationAsm 2338 // | AsmStatement // Case ExternalDeclarationAsmStmt 2339 // | ';' // Case ExternalDeclarationEmpty 2340 // | PragmaSTDC // Case ExternalDeclarationPragma 2341 type ExternalDeclaration struct { 2342 AsmFunctionDefinition *AsmFunctionDefinition 2343 AsmStatement *AsmStatement 2344 Case ExternalDeclarationCase `PrettyPrint:"stringer,zero"` 2345 Declaration *Declaration 2346 FunctionDefinition *FunctionDefinition 2347 PragmaSTDC *PragmaSTDC 2348 Token Token 2349 } 2350 2351 // String implements fmt.Stringer. 2352 func (n *ExternalDeclaration) String() string { return PrettyString(n) } 2353 2354 // Position reports the position of the first component of n, if available. 2355 func (n *ExternalDeclaration) Position() (r token.Position) { 2356 if n == nil { 2357 return r 2358 } 2359 2360 switch n.Case { 2361 case 2: 2362 return n.AsmFunctionDefinition.Position() 2363 case 3: 2364 return n.AsmStatement.Position() 2365 case 1: 2366 return n.Declaration.Position() 2367 case 0: 2368 return n.FunctionDefinition.Position() 2369 case 5: 2370 return n.PragmaSTDC.Position() 2371 case 4: 2372 return n.Token.Position() 2373 default: 2374 panic("internal error") 2375 } 2376 } 2377 2378 // FunctionDefinition represents data reduced by production: 2379 // 2380 // FunctionDefinition: 2381 // DeclarationSpecifiers Declarator DeclarationList CompoundStatement 2382 type FunctionDefinition struct { 2383 CallSiteComplexExpr []*AssignmentExpression 2384 CompositeLiterals []*PostfixExpression 2385 ComputedGotos map[StringID]*UnaryExpression 2386 Gotos map[StringID]*JumpStatement 2387 InitDeclarators []*InitDeclarator 2388 Labels map[StringID]*LabeledStatement 2389 ReturnComplexExpr []*Expression 2390 VLAs []*Declarator 2391 compoundStatements []*CompoundStatement 2392 checked bool 2393 CompoundStatement *CompoundStatement 2394 DeclarationList *DeclarationList 2395 DeclarationSpecifiers *DeclarationSpecifiers 2396 Declarator *Declarator 2397 } 2398 2399 // String implements fmt.Stringer. 2400 func (n *FunctionDefinition) String() string { return PrettyString(n) } 2401 2402 // Position reports the position of the first component of n, if available. 2403 func (n *FunctionDefinition) Position() (r token.Position) { 2404 if n == nil { 2405 return r 2406 } 2407 2408 if p := n.DeclarationSpecifiers.Position(); p.IsValid() { 2409 return p 2410 } 2411 2412 if p := n.Declarator.Position(); p.IsValid() { 2413 return p 2414 } 2415 2416 if p := n.DeclarationList.Position(); p.IsValid() { 2417 return p 2418 } 2419 2420 return n.CompoundStatement.Position() 2421 } 2422 2423 // FunctionSpecifierCase represents case numbers of production FunctionSpecifier 2424 type FunctionSpecifierCase int 2425 2426 // Values of type FunctionSpecifierCase 2427 const ( 2428 FunctionSpecifierInline FunctionSpecifierCase = iota 2429 FunctionSpecifierNoreturn 2430 ) 2431 2432 // String implements fmt.Stringer 2433 func (n FunctionSpecifierCase) String() string { 2434 switch n { 2435 case FunctionSpecifierInline: 2436 return "FunctionSpecifierInline" 2437 case FunctionSpecifierNoreturn: 2438 return "FunctionSpecifierNoreturn" 2439 default: 2440 return fmt.Sprintf("FunctionSpecifierCase(%v)", int(n)) 2441 } 2442 } 2443 2444 // FunctionSpecifier represents data reduced by productions: 2445 // 2446 // FunctionSpecifier: 2447 // "inline" // Case FunctionSpecifierInline 2448 // | "_Noreturn" // Case FunctionSpecifierNoreturn 2449 type FunctionSpecifier struct { 2450 Case FunctionSpecifierCase `PrettyPrint:"stringer,zero"` 2451 Token Token 2452 } 2453 2454 // String implements fmt.Stringer. 2455 func (n *FunctionSpecifier) String() string { return PrettyString(n) } 2456 2457 // Position reports the position of the first component of n, if available. 2458 func (n *FunctionSpecifier) Position() (r token.Position) { 2459 if n == nil { 2460 return r 2461 } 2462 2463 return n.Token.Position() 2464 } 2465 2466 // IdentifierList represents data reduced by productions: 2467 // 2468 // IdentifierList: 2469 // IDENTIFIER 2470 // | IdentifierList ',' IDENTIFIER 2471 type IdentifierList struct { 2472 lexicalScope Scope 2473 IdentifierList *IdentifierList 2474 Token Token 2475 Token2 Token 2476 } 2477 2478 // String implements fmt.Stringer. 2479 func (n *IdentifierList) String() string { return PrettyString(n) } 2480 2481 // Position reports the position of the first component of n, if available. 2482 func (n *IdentifierList) Position() (r token.Position) { 2483 if n == nil { 2484 return r 2485 } 2486 2487 return n.Token.Position() 2488 } 2489 2490 // InclusiveOrExpressionCase represents case numbers of production InclusiveOrExpression 2491 type InclusiveOrExpressionCase int 2492 2493 // Values of type InclusiveOrExpressionCase 2494 const ( 2495 InclusiveOrExpressionXor InclusiveOrExpressionCase = iota 2496 InclusiveOrExpressionOr 2497 ) 2498 2499 // String implements fmt.Stringer 2500 func (n InclusiveOrExpressionCase) String() string { 2501 switch n { 2502 case InclusiveOrExpressionXor: 2503 return "InclusiveOrExpressionXor" 2504 case InclusiveOrExpressionOr: 2505 return "InclusiveOrExpressionOr" 2506 default: 2507 return fmt.Sprintf("InclusiveOrExpressionCase(%v)", int(n)) 2508 } 2509 } 2510 2511 // InclusiveOrExpression represents data reduced by productions: 2512 // 2513 // InclusiveOrExpression: 2514 // ExclusiveOrExpression // Case InclusiveOrExpressionXor 2515 // | InclusiveOrExpression '|' ExclusiveOrExpression // Case InclusiveOrExpressionOr 2516 type InclusiveOrExpression struct { 2517 Operand Operand 2518 promote Type 2519 IsSideEffectsFree bool 2520 Case InclusiveOrExpressionCase `PrettyPrint:"stringer,zero"` 2521 ExclusiveOrExpression *ExclusiveOrExpression 2522 InclusiveOrExpression *InclusiveOrExpression 2523 Token Token 2524 } 2525 2526 // String implements fmt.Stringer. 2527 func (n *InclusiveOrExpression) String() string { return PrettyString(n) } 2528 2529 // Position reports the position of the first component of n, if available. 2530 func (n *InclusiveOrExpression) Position() (r token.Position) { 2531 if n == nil { 2532 return r 2533 } 2534 2535 switch n.Case { 2536 case 0: 2537 return n.ExclusiveOrExpression.Position() 2538 case 1: 2539 if p := n.InclusiveOrExpression.Position(); p.IsValid() { 2540 return p 2541 } 2542 2543 if p := n.Token.Position(); p.IsValid() { 2544 return p 2545 } 2546 2547 return n.ExclusiveOrExpression.Position() 2548 default: 2549 panic("internal error") 2550 } 2551 } 2552 2553 // InitDeclaratorCase represents case numbers of production InitDeclarator 2554 type InitDeclaratorCase int 2555 2556 // Values of type InitDeclaratorCase 2557 const ( 2558 InitDeclaratorDecl InitDeclaratorCase = iota 2559 InitDeclaratorInit 2560 ) 2561 2562 // String implements fmt.Stringer 2563 func (n InitDeclaratorCase) String() string { 2564 switch n { 2565 case InitDeclaratorDecl: 2566 return "InitDeclaratorDecl" 2567 case InitDeclaratorInit: 2568 return "InitDeclaratorInit" 2569 default: 2570 return fmt.Sprintf("InitDeclaratorCase(%v)", int(n)) 2571 } 2572 } 2573 2574 // InitDeclarator represents data reduced by productions: 2575 // 2576 // InitDeclarator: 2577 // Declarator AttributeSpecifierList // Case InitDeclaratorDecl 2578 // | Declarator AttributeSpecifierList '=' Initializer // Case InitDeclaratorInit 2579 type InitDeclarator struct { 2580 initializer *InitializerValue 2581 AttributeSpecifierList *AttributeSpecifierList 2582 Case InitDeclaratorCase `PrettyPrint:"stringer,zero"` 2583 Declarator *Declarator 2584 Initializer *Initializer 2585 Token Token 2586 } 2587 2588 // String implements fmt.Stringer. 2589 func (n *InitDeclarator) String() string { return PrettyString(n) } 2590 2591 // Position reports the position of the first component of n, if available. 2592 func (n *InitDeclarator) Position() (r token.Position) { 2593 if n == nil { 2594 return r 2595 } 2596 2597 switch n.Case { 2598 case 0: 2599 if p := n.Declarator.Position(); p.IsValid() { 2600 return p 2601 } 2602 2603 return n.AttributeSpecifierList.Position() 2604 case 1: 2605 if p := n.Declarator.Position(); p.IsValid() { 2606 return p 2607 } 2608 2609 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 2610 return p 2611 } 2612 2613 if p := n.Token.Position(); p.IsValid() { 2614 return p 2615 } 2616 2617 return n.Initializer.Position() 2618 default: 2619 panic("internal error") 2620 } 2621 } 2622 2623 // InitDeclaratorList represents data reduced by productions: 2624 // 2625 // InitDeclaratorList: 2626 // InitDeclarator 2627 // | InitDeclaratorList ',' AttributeSpecifierList InitDeclarator 2628 type InitDeclaratorList struct { 2629 AttributeSpecifierList *AttributeSpecifierList 2630 InitDeclarator *InitDeclarator 2631 InitDeclaratorList *InitDeclaratorList 2632 Token Token 2633 } 2634 2635 // String implements fmt.Stringer. 2636 func (n *InitDeclaratorList) String() string { return PrettyString(n) } 2637 2638 // Position reports the position of the first component of n, if available. 2639 func (n *InitDeclaratorList) Position() (r token.Position) { 2640 if n == nil { 2641 return r 2642 } 2643 2644 return n.InitDeclarator.Position() 2645 } 2646 2647 // InitializerCase represents case numbers of production Initializer 2648 type InitializerCase int 2649 2650 // Values of type InitializerCase 2651 const ( 2652 InitializerExpr InitializerCase = iota 2653 InitializerInitList 2654 ) 2655 2656 // String implements fmt.Stringer 2657 func (n InitializerCase) String() string { 2658 switch n { 2659 case InitializerExpr: 2660 return "InitializerExpr" 2661 case InitializerInitList: 2662 return "InitializerInitList" 2663 default: 2664 return fmt.Sprintf("InitializerCase(%v)", int(n)) 2665 } 2666 } 2667 2668 // Initializer represents data reduced by productions: 2669 // 2670 // Initializer: 2671 // AssignmentExpression // Case InitializerExpr 2672 // | '{' InitializerList ',' '}' // Case InitializerInitList 2673 type Initializer struct { 2674 Field Field // Where aplicable 2675 Offset uintptr // Case Expr 2676 field0 Field 2677 list []*Initializer 2678 parent *Initializer 2679 trailingComma *Token 2680 typ Type 2681 isConst bool 2682 isZero bool 2683 AssignmentExpression *AssignmentExpression 2684 Case InitializerCase `PrettyPrint:"stringer,zero"` 2685 InitializerList *InitializerList 2686 Token Token 2687 Token2 Token 2688 Token3 Token 2689 } 2690 2691 // String implements fmt.Stringer. 2692 func (n *Initializer) String() string { return PrettyString(n) } 2693 2694 // Position reports the position of the first component of n, if available. 2695 func (n *Initializer) Position() (r token.Position) { 2696 if n == nil { 2697 return r 2698 } 2699 2700 switch n.Case { 2701 case 0: 2702 return n.AssignmentExpression.Position() 2703 case 1: 2704 if p := n.Token.Position(); p.IsValid() { 2705 return p 2706 } 2707 2708 if p := n.InitializerList.Position(); p.IsValid() { 2709 return p 2710 } 2711 2712 if p := n.Token2.Position(); p.IsValid() { 2713 return p 2714 } 2715 2716 return n.Token3.Position() 2717 default: 2718 panic("internal error") 2719 } 2720 } 2721 2722 // InitializerList represents data reduced by productions: 2723 // 2724 // InitializerList: 2725 // Designation Initializer 2726 // | InitializerList ',' Designation Initializer 2727 type InitializerList struct { 2728 list []*Initializer 2729 isConst bool 2730 isZero bool 2731 Designation *Designation 2732 Initializer *Initializer 2733 InitializerList *InitializerList 2734 Token Token 2735 } 2736 2737 // String implements fmt.Stringer. 2738 func (n *InitializerList) String() string { return PrettyString(n) } 2739 2740 // Position reports the position of the first component of n, if available. 2741 func (n *InitializerList) Position() (r token.Position) { 2742 if n == nil { 2743 return r 2744 } 2745 2746 if p := n.Designation.Position(); p.IsValid() { 2747 return p 2748 } 2749 2750 return n.Initializer.Position() 2751 } 2752 2753 // IterationStatementCase represents case numbers of production IterationStatement 2754 type IterationStatementCase int 2755 2756 // Values of type IterationStatementCase 2757 const ( 2758 IterationStatementWhile IterationStatementCase = iota 2759 IterationStatementDo 2760 IterationStatementFor 2761 IterationStatementForDecl 2762 ) 2763 2764 // String implements fmt.Stringer 2765 func (n IterationStatementCase) String() string { 2766 switch n { 2767 case IterationStatementWhile: 2768 return "IterationStatementWhile" 2769 case IterationStatementDo: 2770 return "IterationStatementDo" 2771 case IterationStatementFor: 2772 return "IterationStatementFor" 2773 case IterationStatementForDecl: 2774 return "IterationStatementForDecl" 2775 default: 2776 return fmt.Sprintf("IterationStatementCase(%v)", int(n)) 2777 } 2778 } 2779 2780 // IterationStatement represents data reduced by productions: 2781 // 2782 // IterationStatement: 2783 // "while" '(' Expression ')' Statement // Case IterationStatementWhile 2784 // | "do" Statement "while" '(' Expression ')' ';' // Case IterationStatementDo 2785 // | "for" '(' Expression ';' Expression ';' Expression ')' Statement // Case IterationStatementFor 2786 // | "for" '(' Declaration Expression ';' Expression ')' Statement // Case IterationStatementForDecl 2787 type IterationStatement struct { 2788 Case IterationStatementCase `PrettyPrint:"stringer,zero"` 2789 Declaration *Declaration 2790 Expression *Expression 2791 Expression2 *Expression 2792 Expression3 *Expression 2793 Statement *Statement 2794 Token Token 2795 Token2 Token 2796 Token3 Token 2797 Token4 Token 2798 Token5 Token 2799 } 2800 2801 // String implements fmt.Stringer. 2802 func (n *IterationStatement) String() string { return PrettyString(n) } 2803 2804 // Position reports the position of the first component of n, if available. 2805 func (n *IterationStatement) Position() (r token.Position) { 2806 if n == nil { 2807 return r 2808 } 2809 2810 switch n.Case { 2811 case 1: 2812 if p := n.Token.Position(); p.IsValid() { 2813 return p 2814 } 2815 2816 if p := n.Statement.Position(); p.IsValid() { 2817 return p 2818 } 2819 2820 if p := n.Token2.Position(); p.IsValid() { 2821 return p 2822 } 2823 2824 if p := n.Token3.Position(); p.IsValid() { 2825 return p 2826 } 2827 2828 if p := n.Expression.Position(); p.IsValid() { 2829 return p 2830 } 2831 2832 if p := n.Token4.Position(); p.IsValid() { 2833 return p 2834 } 2835 2836 return n.Token5.Position() 2837 case 3: 2838 if p := n.Token.Position(); p.IsValid() { 2839 return p 2840 } 2841 2842 if p := n.Token2.Position(); p.IsValid() { 2843 return p 2844 } 2845 2846 if p := n.Declaration.Position(); p.IsValid() { 2847 return p 2848 } 2849 2850 if p := n.Expression.Position(); p.IsValid() { 2851 return p 2852 } 2853 2854 if p := n.Token3.Position(); p.IsValid() { 2855 return p 2856 } 2857 2858 if p := n.Expression2.Position(); p.IsValid() { 2859 return p 2860 } 2861 2862 if p := n.Token4.Position(); p.IsValid() { 2863 return p 2864 } 2865 2866 return n.Statement.Position() 2867 case 2: 2868 if p := n.Token.Position(); p.IsValid() { 2869 return p 2870 } 2871 2872 if p := n.Token2.Position(); p.IsValid() { 2873 return p 2874 } 2875 2876 if p := n.Expression.Position(); p.IsValid() { 2877 return p 2878 } 2879 2880 if p := n.Token3.Position(); p.IsValid() { 2881 return p 2882 } 2883 2884 if p := n.Expression2.Position(); p.IsValid() { 2885 return p 2886 } 2887 2888 if p := n.Token4.Position(); p.IsValid() { 2889 return p 2890 } 2891 2892 if p := n.Expression3.Position(); p.IsValid() { 2893 return p 2894 } 2895 2896 if p := n.Token5.Position(); p.IsValid() { 2897 return p 2898 } 2899 2900 return n.Statement.Position() 2901 case 0: 2902 if p := n.Token.Position(); p.IsValid() { 2903 return p 2904 } 2905 2906 if p := n.Token2.Position(); p.IsValid() { 2907 return p 2908 } 2909 2910 if p := n.Expression.Position(); p.IsValid() { 2911 return p 2912 } 2913 2914 if p := n.Token3.Position(); p.IsValid() { 2915 return p 2916 } 2917 2918 return n.Statement.Position() 2919 default: 2920 panic("internal error") 2921 } 2922 } 2923 2924 // JumpStatementCase represents case numbers of production JumpStatement 2925 type JumpStatementCase int 2926 2927 // Values of type JumpStatementCase 2928 const ( 2929 JumpStatementGoto JumpStatementCase = iota 2930 JumpStatementGotoExpr 2931 JumpStatementContinue 2932 JumpStatementBreak 2933 JumpStatementReturn 2934 ) 2935 2936 // String implements fmt.Stringer 2937 func (n JumpStatementCase) String() string { 2938 switch n { 2939 case JumpStatementGoto: 2940 return "JumpStatementGoto" 2941 case JumpStatementGotoExpr: 2942 return "JumpStatementGotoExpr" 2943 case JumpStatementContinue: 2944 return "JumpStatementContinue" 2945 case JumpStatementBreak: 2946 return "JumpStatementBreak" 2947 case JumpStatementReturn: 2948 return "JumpStatementReturn" 2949 default: 2950 return fmt.Sprintf("JumpStatementCase(%v)", int(n)) 2951 } 2952 } 2953 2954 // JumpStatement represents data reduced by productions: 2955 // 2956 // JumpStatement: 2957 // "goto" IDENTIFIER ';' // Case JumpStatementGoto 2958 // | "goto" '*' Expression ';' // Case JumpStatementGotoExpr 2959 // | "continue" ';' // Case JumpStatementContinue 2960 // | "break" ';' // Case JumpStatementBreak 2961 // | "return" Expression ';' // Case JumpStatementReturn 2962 type JumpStatement struct { 2963 context Node 2964 lexicalScope Scope 2965 Case JumpStatementCase `PrettyPrint:"stringer,zero"` 2966 Expression *Expression 2967 Token Token 2968 Token2 Token 2969 Token3 Token 2970 } 2971 2972 // String implements fmt.Stringer. 2973 func (n *JumpStatement) String() string { return PrettyString(n) } 2974 2975 // Position reports the position of the first component of n, if available. 2976 func (n *JumpStatement) Position() (r token.Position) { 2977 if n == nil { 2978 return r 2979 } 2980 2981 switch n.Case { 2982 case 4: 2983 if p := n.Token.Position(); p.IsValid() { 2984 return p 2985 } 2986 2987 if p := n.Expression.Position(); p.IsValid() { 2988 return p 2989 } 2990 2991 return n.Token2.Position() 2992 case 2, 3: 2993 if p := n.Token.Position(); p.IsValid() { 2994 return p 2995 } 2996 2997 return n.Token2.Position() 2998 case 1: 2999 if p := n.Token.Position(); p.IsValid() { 3000 return p 3001 } 3002 3003 if p := n.Token2.Position(); p.IsValid() { 3004 return p 3005 } 3006 3007 if p := n.Expression.Position(); p.IsValid() { 3008 return p 3009 } 3010 3011 return n.Token3.Position() 3012 case 0: 3013 if p := n.Token.Position(); p.IsValid() { 3014 return p 3015 } 3016 3017 if p := n.Token2.Position(); p.IsValid() { 3018 return p 3019 } 3020 3021 return n.Token3.Position() 3022 default: 3023 panic("internal error") 3024 } 3025 } 3026 3027 // LabelDeclaration represents data reduced by production: 3028 // 3029 // LabelDeclaration: 3030 // "__label__" IdentifierList ';' 3031 type LabelDeclaration struct { 3032 IdentifierList *IdentifierList 3033 Token Token 3034 Token2 Token 3035 } 3036 3037 // String implements fmt.Stringer. 3038 func (n *LabelDeclaration) String() string { return PrettyString(n) } 3039 3040 // Position reports the position of the first component of n, if available. 3041 func (n *LabelDeclaration) Position() (r token.Position) { 3042 if n == nil { 3043 return r 3044 } 3045 3046 if p := n.Token.Position(); p.IsValid() { 3047 return p 3048 } 3049 3050 if p := n.IdentifierList.Position(); p.IsValid() { 3051 return p 3052 } 3053 3054 return n.Token2.Position() 3055 } 3056 3057 // LabeledStatementCase represents case numbers of production LabeledStatement 3058 type LabeledStatementCase int 3059 3060 // Values of type LabeledStatementCase 3061 const ( 3062 LabeledStatementLabel LabeledStatementCase = iota 3063 LabeledStatementCaseLabel 3064 LabeledStatementRange 3065 LabeledStatementDefault 3066 ) 3067 3068 // String implements fmt.Stringer 3069 func (n LabeledStatementCase) String() string { 3070 switch n { 3071 case LabeledStatementLabel: 3072 return "LabeledStatementLabel" 3073 case LabeledStatementCaseLabel: 3074 return "LabeledStatementCaseLabel" 3075 case LabeledStatementRange: 3076 return "LabeledStatementRange" 3077 case LabeledStatementDefault: 3078 return "LabeledStatementDefault" 3079 default: 3080 return fmt.Sprintf("LabeledStatementCase(%v)", int(n)) 3081 } 3082 } 3083 3084 // LabeledStatement represents data reduced by productions: 3085 // 3086 // LabeledStatement: 3087 // IDENTIFIER ':' AttributeSpecifierList Statement // Case LabeledStatementLabel 3088 // | "case" ConstantExpression ':' Statement // Case LabeledStatementCaseLabel 3089 // | "case" ConstantExpression "..." ConstantExpression ':' Statement // Case LabeledStatementRange 3090 // | "default" ':' Statement // Case LabeledStatementDefault 3091 type LabeledStatement struct { 3092 block *CompoundStatement 3093 lexicalScope Scope 3094 AttributeSpecifierList *AttributeSpecifierList 3095 Case LabeledStatementCase `PrettyPrint:"stringer,zero"` 3096 ConstantExpression *ConstantExpression 3097 ConstantExpression2 *ConstantExpression 3098 Statement *Statement 3099 Token Token 3100 Token2 Token 3101 Token3 Token 3102 } 3103 3104 // String implements fmt.Stringer. 3105 func (n *LabeledStatement) String() string { return PrettyString(n) } 3106 3107 // Position reports the position of the first component of n, if available. 3108 func (n *LabeledStatement) Position() (r token.Position) { 3109 if n == nil { 3110 return r 3111 } 3112 3113 switch n.Case { 3114 case 2: 3115 if p := n.Token.Position(); p.IsValid() { 3116 return p 3117 } 3118 3119 if p := n.ConstantExpression.Position(); p.IsValid() { 3120 return p 3121 } 3122 3123 if p := n.Token2.Position(); p.IsValid() { 3124 return p 3125 } 3126 3127 if p := n.ConstantExpression2.Position(); p.IsValid() { 3128 return p 3129 } 3130 3131 if p := n.Token3.Position(); p.IsValid() { 3132 return p 3133 } 3134 3135 return n.Statement.Position() 3136 case 1: 3137 if p := n.Token.Position(); p.IsValid() { 3138 return p 3139 } 3140 3141 if p := n.ConstantExpression.Position(); p.IsValid() { 3142 return p 3143 } 3144 3145 if p := n.Token2.Position(); p.IsValid() { 3146 return p 3147 } 3148 3149 return n.Statement.Position() 3150 case 0: 3151 if p := n.Token.Position(); p.IsValid() { 3152 return p 3153 } 3154 3155 if p := n.Token2.Position(); p.IsValid() { 3156 return p 3157 } 3158 3159 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 3160 return p 3161 } 3162 3163 return n.Statement.Position() 3164 case 3: 3165 if p := n.Token.Position(); p.IsValid() { 3166 return p 3167 } 3168 3169 if p := n.Token2.Position(); p.IsValid() { 3170 return p 3171 } 3172 3173 return n.Statement.Position() 3174 default: 3175 panic("internal error") 3176 } 3177 } 3178 3179 // LogicalAndExpressionCase represents case numbers of production LogicalAndExpression 3180 type LogicalAndExpressionCase int 3181 3182 // Values of type LogicalAndExpressionCase 3183 const ( 3184 LogicalAndExpressionOr LogicalAndExpressionCase = iota 3185 LogicalAndExpressionLAnd 3186 ) 3187 3188 // String implements fmt.Stringer 3189 func (n LogicalAndExpressionCase) String() string { 3190 switch n { 3191 case LogicalAndExpressionOr: 3192 return "LogicalAndExpressionOr" 3193 case LogicalAndExpressionLAnd: 3194 return "LogicalAndExpressionLAnd" 3195 default: 3196 return fmt.Sprintf("LogicalAndExpressionCase(%v)", int(n)) 3197 } 3198 } 3199 3200 // LogicalAndExpression represents data reduced by productions: 3201 // 3202 // LogicalAndExpression: 3203 // InclusiveOrExpression // Case LogicalAndExpressionOr 3204 // | LogicalAndExpression "&&" InclusiveOrExpression // Case LogicalAndExpressionLAnd 3205 type LogicalAndExpression struct { 3206 Operand Operand 3207 IsSideEffectsFree bool 3208 Case LogicalAndExpressionCase `PrettyPrint:"stringer,zero"` 3209 InclusiveOrExpression *InclusiveOrExpression 3210 LogicalAndExpression *LogicalAndExpression 3211 Token Token 3212 } 3213 3214 // String implements fmt.Stringer. 3215 func (n *LogicalAndExpression) String() string { return PrettyString(n) } 3216 3217 // Position reports the position of the first component of n, if available. 3218 func (n *LogicalAndExpression) Position() (r token.Position) { 3219 if n == nil { 3220 return r 3221 } 3222 3223 switch n.Case { 3224 case 0: 3225 return n.InclusiveOrExpression.Position() 3226 case 1: 3227 if p := n.LogicalAndExpression.Position(); p.IsValid() { 3228 return p 3229 } 3230 3231 if p := n.Token.Position(); p.IsValid() { 3232 return p 3233 } 3234 3235 return n.InclusiveOrExpression.Position() 3236 default: 3237 panic("internal error") 3238 } 3239 } 3240 3241 // LogicalOrExpressionCase represents case numbers of production LogicalOrExpression 3242 type LogicalOrExpressionCase int 3243 3244 // Values of type LogicalOrExpressionCase 3245 const ( 3246 LogicalOrExpressionLAnd LogicalOrExpressionCase = iota 3247 LogicalOrExpressionLOr 3248 ) 3249 3250 // String implements fmt.Stringer 3251 func (n LogicalOrExpressionCase) String() string { 3252 switch n { 3253 case LogicalOrExpressionLAnd: 3254 return "LogicalOrExpressionLAnd" 3255 case LogicalOrExpressionLOr: 3256 return "LogicalOrExpressionLOr" 3257 default: 3258 return fmt.Sprintf("LogicalOrExpressionCase(%v)", int(n)) 3259 } 3260 } 3261 3262 // LogicalOrExpression represents data reduced by productions: 3263 // 3264 // LogicalOrExpression: 3265 // LogicalAndExpression // Case LogicalOrExpressionLAnd 3266 // | LogicalOrExpression "||" LogicalAndExpression // Case LogicalOrExpressionLOr 3267 type LogicalOrExpression struct { 3268 Operand Operand 3269 IsSideEffectsFree bool 3270 Case LogicalOrExpressionCase `PrettyPrint:"stringer,zero"` 3271 LogicalAndExpression *LogicalAndExpression 3272 LogicalOrExpression *LogicalOrExpression 3273 Token Token 3274 } 3275 3276 // String implements fmt.Stringer. 3277 func (n *LogicalOrExpression) String() string { return PrettyString(n) } 3278 3279 // Position reports the position of the first component of n, if available. 3280 func (n *LogicalOrExpression) Position() (r token.Position) { 3281 if n == nil { 3282 return r 3283 } 3284 3285 switch n.Case { 3286 case 0: 3287 return n.LogicalAndExpression.Position() 3288 case 1: 3289 if p := n.LogicalOrExpression.Position(); p.IsValid() { 3290 return p 3291 } 3292 3293 if p := n.Token.Position(); p.IsValid() { 3294 return p 3295 } 3296 3297 return n.LogicalAndExpression.Position() 3298 default: 3299 panic("internal error") 3300 } 3301 } 3302 3303 // MultiplicativeExpressionCase represents case numbers of production MultiplicativeExpression 3304 type MultiplicativeExpressionCase int 3305 3306 // Values of type MultiplicativeExpressionCase 3307 const ( 3308 MultiplicativeExpressionCast MultiplicativeExpressionCase = iota 3309 MultiplicativeExpressionMul 3310 MultiplicativeExpressionDiv 3311 MultiplicativeExpressionMod 3312 ) 3313 3314 // String implements fmt.Stringer 3315 func (n MultiplicativeExpressionCase) String() string { 3316 switch n { 3317 case MultiplicativeExpressionCast: 3318 return "MultiplicativeExpressionCast" 3319 case MultiplicativeExpressionMul: 3320 return "MultiplicativeExpressionMul" 3321 case MultiplicativeExpressionDiv: 3322 return "MultiplicativeExpressionDiv" 3323 case MultiplicativeExpressionMod: 3324 return "MultiplicativeExpressionMod" 3325 default: 3326 return fmt.Sprintf("MultiplicativeExpressionCase(%v)", int(n)) 3327 } 3328 } 3329 3330 // MultiplicativeExpression represents data reduced by productions: 3331 // 3332 // MultiplicativeExpression: 3333 // CastExpression // Case MultiplicativeExpressionCast 3334 // | MultiplicativeExpression '*' CastExpression // Case MultiplicativeExpressionMul 3335 // | MultiplicativeExpression '/' CastExpression // Case MultiplicativeExpressionDiv 3336 // | MultiplicativeExpression '%' CastExpression // Case MultiplicativeExpressionMod 3337 type MultiplicativeExpression struct { 3338 Operand Operand 3339 promote Type 3340 IsSideEffectsFree bool 3341 Case MultiplicativeExpressionCase `PrettyPrint:"stringer,zero"` 3342 CastExpression *CastExpression 3343 MultiplicativeExpression *MultiplicativeExpression 3344 Token Token 3345 } 3346 3347 // String implements fmt.Stringer. 3348 func (n *MultiplicativeExpression) String() string { return PrettyString(n) } 3349 3350 // Position reports the position of the first component of n, if available. 3351 func (n *MultiplicativeExpression) Position() (r token.Position) { 3352 if n == nil { 3353 return r 3354 } 3355 3356 switch n.Case { 3357 case 0: 3358 return n.CastExpression.Position() 3359 case 1, 2, 3: 3360 if p := n.MultiplicativeExpression.Position(); p.IsValid() { 3361 return p 3362 } 3363 3364 if p := n.Token.Position(); p.IsValid() { 3365 return p 3366 } 3367 3368 return n.CastExpression.Position() 3369 default: 3370 panic("internal error") 3371 } 3372 } 3373 3374 // ParameterDeclarationCase represents case numbers of production ParameterDeclaration 3375 type ParameterDeclarationCase int 3376 3377 // Values of type ParameterDeclarationCase 3378 const ( 3379 ParameterDeclarationDecl ParameterDeclarationCase = iota 3380 ParameterDeclarationAbstract 3381 ) 3382 3383 // String implements fmt.Stringer 3384 func (n ParameterDeclarationCase) String() string { 3385 switch n { 3386 case ParameterDeclarationDecl: 3387 return "ParameterDeclarationDecl" 3388 case ParameterDeclarationAbstract: 3389 return "ParameterDeclarationAbstract" 3390 default: 3391 return fmt.Sprintf("ParameterDeclarationCase(%v)", int(n)) 3392 } 3393 } 3394 3395 // ParameterDeclaration represents data reduced by productions: 3396 // 3397 // ParameterDeclaration: 3398 // DeclarationSpecifiers Declarator AttributeSpecifierList // Case ParameterDeclarationDecl 3399 // | DeclarationSpecifiers AbstractDeclarator // Case ParameterDeclarationAbstract 3400 type ParameterDeclaration struct { 3401 typ Type 3402 AbstractDeclarator *AbstractDeclarator 3403 AttributeSpecifierList *AttributeSpecifierList 3404 Case ParameterDeclarationCase `PrettyPrint:"stringer,zero"` 3405 DeclarationSpecifiers *DeclarationSpecifiers 3406 Declarator *Declarator 3407 } 3408 3409 // String implements fmt.Stringer. 3410 func (n *ParameterDeclaration) String() string { return PrettyString(n) } 3411 3412 // Position reports the position of the first component of n, if available. 3413 func (n *ParameterDeclaration) Position() (r token.Position) { 3414 if n == nil { 3415 return r 3416 } 3417 3418 switch n.Case { 3419 case 1: 3420 if p := n.DeclarationSpecifiers.Position(); p.IsValid() { 3421 return p 3422 } 3423 3424 return n.AbstractDeclarator.Position() 3425 case 0: 3426 if p := n.DeclarationSpecifiers.Position(); p.IsValid() { 3427 return p 3428 } 3429 3430 if p := n.Declarator.Position(); p.IsValid() { 3431 return p 3432 } 3433 3434 return n.AttributeSpecifierList.Position() 3435 default: 3436 panic("internal error") 3437 } 3438 } 3439 3440 // ParameterList represents data reduced by productions: 3441 // 3442 // ParameterList: 3443 // ParameterDeclaration 3444 // | ParameterList ',' ParameterDeclaration 3445 type ParameterList struct { 3446 ParameterDeclaration *ParameterDeclaration 3447 ParameterList *ParameterList 3448 Token Token 3449 } 3450 3451 // String implements fmt.Stringer. 3452 func (n *ParameterList) String() string { return PrettyString(n) } 3453 3454 // Position reports the position of the first component of n, if available. 3455 func (n *ParameterList) Position() (r token.Position) { 3456 if n == nil { 3457 return r 3458 } 3459 3460 return n.ParameterDeclaration.Position() 3461 } 3462 3463 // ParameterTypeListCase represents case numbers of production ParameterTypeList 3464 type ParameterTypeListCase int 3465 3466 // Values of type ParameterTypeListCase 3467 const ( 3468 ParameterTypeListList ParameterTypeListCase = iota 3469 ParameterTypeListVar 3470 ) 3471 3472 // String implements fmt.Stringer 3473 func (n ParameterTypeListCase) String() string { 3474 switch n { 3475 case ParameterTypeListList: 3476 return "ParameterTypeListList" 3477 case ParameterTypeListVar: 3478 return "ParameterTypeListVar" 3479 default: 3480 return fmt.Sprintf("ParameterTypeListCase(%v)", int(n)) 3481 } 3482 } 3483 3484 // ParameterTypeList represents data reduced by productions: 3485 // 3486 // ParameterTypeList: 3487 // ParameterList // Case ParameterTypeListList 3488 // | ParameterList ',' "..." // Case ParameterTypeListVar 3489 type ParameterTypeList struct { 3490 Case ParameterTypeListCase `PrettyPrint:"stringer,zero"` 3491 ParameterList *ParameterList 3492 Token Token 3493 Token2 Token 3494 } 3495 3496 // String implements fmt.Stringer. 3497 func (n *ParameterTypeList) String() string { return PrettyString(n) } 3498 3499 // Position reports the position of the first component of n, if available. 3500 func (n *ParameterTypeList) Position() (r token.Position) { 3501 if n == nil { 3502 return r 3503 } 3504 3505 switch n.Case { 3506 case 0: 3507 return n.ParameterList.Position() 3508 case 1: 3509 if p := n.ParameterList.Position(); p.IsValid() { 3510 return p 3511 } 3512 3513 if p := n.Token.Position(); p.IsValid() { 3514 return p 3515 } 3516 3517 return n.Token2.Position() 3518 default: 3519 panic("internal error") 3520 } 3521 } 3522 3523 // PointerCase represents case numbers of production Pointer 3524 type PointerCase int 3525 3526 // Values of type PointerCase 3527 const ( 3528 PointerTypeQual PointerCase = iota 3529 PointerPtr 3530 PointerBlock 3531 ) 3532 3533 // String implements fmt.Stringer 3534 func (n PointerCase) String() string { 3535 switch n { 3536 case PointerTypeQual: 3537 return "PointerTypeQual" 3538 case PointerPtr: 3539 return "PointerPtr" 3540 case PointerBlock: 3541 return "PointerBlock" 3542 default: 3543 return fmt.Sprintf("PointerCase(%v)", int(n)) 3544 } 3545 } 3546 3547 // Pointer represents data reduced by productions: 3548 // 3549 // Pointer: 3550 // '*' TypeQualifiers // Case PointerTypeQual 3551 // | '*' TypeQualifiers Pointer // Case PointerPtr 3552 // | '^' TypeQualifiers // Case PointerBlock 3553 type Pointer struct { 3554 typeQualifiers *typeBase 3555 Case PointerCase `PrettyPrint:"stringer,zero"` 3556 Pointer *Pointer 3557 Token Token 3558 TypeQualifiers *TypeQualifiers 3559 } 3560 3561 // String implements fmt.Stringer. 3562 func (n *Pointer) String() string { return PrettyString(n) } 3563 3564 // Position reports the position of the first component of n, if available. 3565 func (n *Pointer) Position() (r token.Position) { 3566 if n == nil { 3567 return r 3568 } 3569 3570 switch n.Case { 3571 case 0, 2: 3572 if p := n.Token.Position(); p.IsValid() { 3573 return p 3574 } 3575 3576 return n.TypeQualifiers.Position() 3577 case 1: 3578 if p := n.Token.Position(); p.IsValid() { 3579 return p 3580 } 3581 3582 if p := n.TypeQualifiers.Position(); p.IsValid() { 3583 return p 3584 } 3585 3586 return n.Pointer.Position() 3587 default: 3588 panic("internal error") 3589 } 3590 } 3591 3592 // PostfixExpressionCase represents case numbers of production PostfixExpression 3593 type PostfixExpressionCase int 3594 3595 // Values of type PostfixExpressionCase 3596 const ( 3597 PostfixExpressionPrimary PostfixExpressionCase = iota 3598 PostfixExpressionIndex 3599 PostfixExpressionCall 3600 PostfixExpressionSelect 3601 PostfixExpressionPSelect 3602 PostfixExpressionInc 3603 PostfixExpressionDec 3604 PostfixExpressionComplit 3605 PostfixExpressionTypeCmp 3606 PostfixExpressionChooseExpr 3607 ) 3608 3609 // String implements fmt.Stringer 3610 func (n PostfixExpressionCase) String() string { 3611 switch n { 3612 case PostfixExpressionPrimary: 3613 return "PostfixExpressionPrimary" 3614 case PostfixExpressionIndex: 3615 return "PostfixExpressionIndex" 3616 case PostfixExpressionCall: 3617 return "PostfixExpressionCall" 3618 case PostfixExpressionSelect: 3619 return "PostfixExpressionSelect" 3620 case PostfixExpressionPSelect: 3621 return "PostfixExpressionPSelect" 3622 case PostfixExpressionInc: 3623 return "PostfixExpressionInc" 3624 case PostfixExpressionDec: 3625 return "PostfixExpressionDec" 3626 case PostfixExpressionComplit: 3627 return "PostfixExpressionComplit" 3628 case PostfixExpressionTypeCmp: 3629 return "PostfixExpressionTypeCmp" 3630 case PostfixExpressionChooseExpr: 3631 return "PostfixExpressionChooseExpr" 3632 default: 3633 return fmt.Sprintf("PostfixExpressionCase(%v)", int(n)) 3634 } 3635 } 3636 3637 // PostfixExpression represents data reduced by productions: 3638 // 3639 // PostfixExpression: 3640 // PrimaryExpression // Case PostfixExpressionPrimary 3641 // | PostfixExpression '[' Expression ']' // Case PostfixExpressionIndex 3642 // | PostfixExpression '(' ArgumentExpressionList ')' // Case PostfixExpressionCall 3643 // | PostfixExpression '.' IDENTIFIER // Case PostfixExpressionSelect 3644 // | PostfixExpression "->" IDENTIFIER // Case PostfixExpressionPSelect 3645 // | PostfixExpression "++" // Case PostfixExpressionInc 3646 // | PostfixExpression "--" // Case PostfixExpressionDec 3647 // | '(' TypeName ')' '{' InitializerList ',' '}' // Case PostfixExpressionComplit 3648 // | "__builtin_types_compatible_p" '(' TypeName ',' TypeName ')' // Case PostfixExpressionTypeCmp 3649 // | "__builtin_choose_expr" '(' AssignmentExpression ',' AssignmentExpression ',' AssignmentExpression ')' // Case PostfixExpressionChooseExpr 3650 type PostfixExpression struct { 3651 Operand Operand 3652 Field Field // Case Select, PSelect 3653 IsSideEffectsFree bool 3654 ArgumentExpressionList *ArgumentExpressionList 3655 AssignmentExpression *AssignmentExpression 3656 AssignmentExpression2 *AssignmentExpression 3657 AssignmentExpression3 *AssignmentExpression 3658 Case PostfixExpressionCase `PrettyPrint:"stringer,zero"` 3659 Expression *Expression 3660 InitializerList *InitializerList 3661 PostfixExpression *PostfixExpression 3662 PrimaryExpression *PrimaryExpression 3663 Token Token 3664 Token2 Token 3665 Token3 Token 3666 Token4 Token 3667 Token5 Token 3668 TypeName *TypeName 3669 TypeName2 *TypeName 3670 } 3671 3672 // String implements fmt.Stringer. 3673 func (n *PostfixExpression) String() string { return PrettyString(n) } 3674 3675 // Position reports the position of the first component of n, if available. 3676 func (n *PostfixExpression) Position() (r token.Position) { 3677 if n == nil { 3678 return r 3679 } 3680 3681 switch n.Case { 3682 case 5, 6: 3683 if p := n.PostfixExpression.Position(); p.IsValid() { 3684 return p 3685 } 3686 3687 return n.Token.Position() 3688 case 2: 3689 if p := n.PostfixExpression.Position(); p.IsValid() { 3690 return p 3691 } 3692 3693 if p := n.Token.Position(); p.IsValid() { 3694 return p 3695 } 3696 3697 if p := n.ArgumentExpressionList.Position(); p.IsValid() { 3698 return p 3699 } 3700 3701 return n.Token2.Position() 3702 case 1: 3703 if p := n.PostfixExpression.Position(); p.IsValid() { 3704 return p 3705 } 3706 3707 if p := n.Token.Position(); p.IsValid() { 3708 return p 3709 } 3710 3711 if p := n.Expression.Position(); p.IsValid() { 3712 return p 3713 } 3714 3715 return n.Token2.Position() 3716 case 3, 4: 3717 if p := n.PostfixExpression.Position(); p.IsValid() { 3718 return p 3719 } 3720 3721 if p := n.Token.Position(); p.IsValid() { 3722 return p 3723 } 3724 3725 return n.Token2.Position() 3726 case 0: 3727 return n.PrimaryExpression.Position() 3728 case 9: 3729 if p := n.Token.Position(); p.IsValid() { 3730 return p 3731 } 3732 3733 if p := n.Token2.Position(); p.IsValid() { 3734 return p 3735 } 3736 3737 if p := n.AssignmentExpression.Position(); p.IsValid() { 3738 return p 3739 } 3740 3741 if p := n.Token3.Position(); p.IsValid() { 3742 return p 3743 } 3744 3745 if p := n.AssignmentExpression2.Position(); p.IsValid() { 3746 return p 3747 } 3748 3749 if p := n.Token4.Position(); p.IsValid() { 3750 return p 3751 } 3752 3753 if p := n.AssignmentExpression3.Position(); p.IsValid() { 3754 return p 3755 } 3756 3757 return n.Token5.Position() 3758 case 8: 3759 if p := n.Token.Position(); p.IsValid() { 3760 return p 3761 } 3762 3763 if p := n.Token2.Position(); p.IsValid() { 3764 return p 3765 } 3766 3767 if p := n.TypeName.Position(); p.IsValid() { 3768 return p 3769 } 3770 3771 if p := n.Token3.Position(); p.IsValid() { 3772 return p 3773 } 3774 3775 if p := n.TypeName2.Position(); p.IsValid() { 3776 return p 3777 } 3778 3779 return n.Token4.Position() 3780 case 7: 3781 if p := n.Token.Position(); p.IsValid() { 3782 return p 3783 } 3784 3785 if p := n.TypeName.Position(); p.IsValid() { 3786 return p 3787 } 3788 3789 if p := n.Token2.Position(); p.IsValid() { 3790 return p 3791 } 3792 3793 if p := n.Token3.Position(); p.IsValid() { 3794 return p 3795 } 3796 3797 if p := n.InitializerList.Position(); p.IsValid() { 3798 return p 3799 } 3800 3801 if p := n.Token4.Position(); p.IsValid() { 3802 return p 3803 } 3804 3805 return n.Token5.Position() 3806 default: 3807 panic("internal error") 3808 } 3809 } 3810 3811 // PragmaSTDC represents data reduced by production: 3812 // 3813 // PragmaSTDC: 3814 // "__pragma_stdc" IDENTIFIER IDENTIFIER IDENTIFIER 3815 type PragmaSTDC struct { 3816 Token Token 3817 Token2 Token 3818 Token3 Token 3819 Token4 Token 3820 } 3821 3822 // String implements fmt.Stringer. 3823 func (n *PragmaSTDC) String() string { return PrettyString(n) } 3824 3825 // Position reports the position of the first component of n, if available. 3826 func (n *PragmaSTDC) Position() (r token.Position) { 3827 if n == nil { 3828 return r 3829 } 3830 3831 if p := n.Token.Position(); p.IsValid() { 3832 return p 3833 } 3834 3835 if p := n.Token2.Position(); p.IsValid() { 3836 return p 3837 } 3838 3839 if p := n.Token3.Position(); p.IsValid() { 3840 return p 3841 } 3842 3843 return n.Token4.Position() 3844 } 3845 3846 // PrimaryExpressionCase represents case numbers of production PrimaryExpression 3847 type PrimaryExpressionCase int 3848 3849 // Values of type PrimaryExpressionCase 3850 const ( 3851 PrimaryExpressionIdent PrimaryExpressionCase = iota 3852 PrimaryExpressionInt 3853 PrimaryExpressionFloat 3854 PrimaryExpressionEnum 3855 PrimaryExpressionChar 3856 PrimaryExpressionLChar 3857 PrimaryExpressionString 3858 PrimaryExpressionLString 3859 PrimaryExpressionExpr 3860 PrimaryExpressionStmt 3861 ) 3862 3863 // String implements fmt.Stringer 3864 func (n PrimaryExpressionCase) String() string { 3865 switch n { 3866 case PrimaryExpressionIdent: 3867 return "PrimaryExpressionIdent" 3868 case PrimaryExpressionInt: 3869 return "PrimaryExpressionInt" 3870 case PrimaryExpressionFloat: 3871 return "PrimaryExpressionFloat" 3872 case PrimaryExpressionEnum: 3873 return "PrimaryExpressionEnum" 3874 case PrimaryExpressionChar: 3875 return "PrimaryExpressionChar" 3876 case PrimaryExpressionLChar: 3877 return "PrimaryExpressionLChar" 3878 case PrimaryExpressionString: 3879 return "PrimaryExpressionString" 3880 case PrimaryExpressionLString: 3881 return "PrimaryExpressionLString" 3882 case PrimaryExpressionExpr: 3883 return "PrimaryExpressionExpr" 3884 case PrimaryExpressionStmt: 3885 return "PrimaryExpressionStmt" 3886 default: 3887 return fmt.Sprintf("PrimaryExpressionCase(%v)", int(n)) 3888 } 3889 } 3890 3891 // PrimaryExpression represents data reduced by productions: 3892 // 3893 // PrimaryExpression: 3894 // IDENTIFIER // Case PrimaryExpressionIdent 3895 // | INTCONST // Case PrimaryExpressionInt 3896 // | FLOATCONST // Case PrimaryExpressionFloat 3897 // | ENUMCONST // Case PrimaryExpressionEnum 3898 // | CHARCONST // Case PrimaryExpressionChar 3899 // | LONGCHARCONST // Case PrimaryExpressionLChar 3900 // | STRINGLITERAL // Case PrimaryExpressionString 3901 // | LONGSTRINGLITERAL // Case PrimaryExpressionLString 3902 // | '(' Expression ')' // Case PrimaryExpressionExpr 3903 // | '(' CompoundStatement ')' // Case PrimaryExpressionStmt 3904 type PrimaryExpression struct { 3905 Operand Operand 3906 lexicalScope Scope 3907 resolvedIn Scope 3908 resolvedTo Node 3909 IsSideEffectsFree bool 3910 Case PrimaryExpressionCase `PrettyPrint:"stringer,zero"` 3911 CompoundStatement *CompoundStatement 3912 Expression *Expression 3913 Token Token 3914 Token2 Token 3915 } 3916 3917 // String implements fmt.Stringer. 3918 func (n *PrimaryExpression) String() string { return PrettyString(n) } 3919 3920 // Position reports the position of the first component of n, if available. 3921 func (n *PrimaryExpression) Position() (r token.Position) { 3922 if n == nil { 3923 return r 3924 } 3925 3926 switch n.Case { 3927 case 0, 1, 2, 3, 4, 5, 6, 7: 3928 return n.Token.Position() 3929 case 9: 3930 if p := n.Token.Position(); p.IsValid() { 3931 return p 3932 } 3933 3934 if p := n.CompoundStatement.Position(); p.IsValid() { 3935 return p 3936 } 3937 3938 return n.Token2.Position() 3939 case 8: 3940 if p := n.Token.Position(); p.IsValid() { 3941 return p 3942 } 3943 3944 if p := n.Expression.Position(); p.IsValid() { 3945 return p 3946 } 3947 3948 return n.Token2.Position() 3949 default: 3950 panic("internal error") 3951 } 3952 } 3953 3954 // RelationalExpressionCase represents case numbers of production RelationalExpression 3955 type RelationalExpressionCase int 3956 3957 // Values of type RelationalExpressionCase 3958 const ( 3959 RelationalExpressionShift RelationalExpressionCase = iota 3960 RelationalExpressionLt 3961 RelationalExpressionGt 3962 RelationalExpressionLeq 3963 RelationalExpressionGeq 3964 ) 3965 3966 // String implements fmt.Stringer 3967 func (n RelationalExpressionCase) String() string { 3968 switch n { 3969 case RelationalExpressionShift: 3970 return "RelationalExpressionShift" 3971 case RelationalExpressionLt: 3972 return "RelationalExpressionLt" 3973 case RelationalExpressionGt: 3974 return "RelationalExpressionGt" 3975 case RelationalExpressionLeq: 3976 return "RelationalExpressionLeq" 3977 case RelationalExpressionGeq: 3978 return "RelationalExpressionGeq" 3979 default: 3980 return fmt.Sprintf("RelationalExpressionCase(%v)", int(n)) 3981 } 3982 } 3983 3984 // RelationalExpression represents data reduced by productions: 3985 // 3986 // RelationalExpression: 3987 // ShiftExpression // Case RelationalExpressionShift 3988 // | RelationalExpression '<' ShiftExpression // Case RelationalExpressionLt 3989 // | RelationalExpression '>' ShiftExpression // Case RelationalExpressionGt 3990 // | RelationalExpression "<=" ShiftExpression // Case RelationalExpressionLeq 3991 // | RelationalExpression ">=" ShiftExpression // Case RelationalExpressionGeq 3992 type RelationalExpression struct { 3993 Operand Operand 3994 promote Type 3995 IsSideEffectsFree bool 3996 Case RelationalExpressionCase `PrettyPrint:"stringer,zero"` 3997 RelationalExpression *RelationalExpression 3998 ShiftExpression *ShiftExpression 3999 Token Token 4000 } 4001 4002 // String implements fmt.Stringer. 4003 func (n *RelationalExpression) String() string { return PrettyString(n) } 4004 4005 // Position reports the position of the first component of n, if available. 4006 func (n *RelationalExpression) Position() (r token.Position) { 4007 if n == nil { 4008 return r 4009 } 4010 4011 switch n.Case { 4012 case 1, 2, 3, 4: 4013 if p := n.RelationalExpression.Position(); p.IsValid() { 4014 return p 4015 } 4016 4017 if p := n.Token.Position(); p.IsValid() { 4018 return p 4019 } 4020 4021 return n.ShiftExpression.Position() 4022 case 0: 4023 return n.ShiftExpression.Position() 4024 default: 4025 panic("internal error") 4026 } 4027 } 4028 4029 // SelectionStatementCase represents case numbers of production SelectionStatement 4030 type SelectionStatementCase int 4031 4032 // Values of type SelectionStatementCase 4033 const ( 4034 SelectionStatementIf SelectionStatementCase = iota 4035 SelectionStatementIfElse 4036 SelectionStatementSwitch 4037 ) 4038 4039 // String implements fmt.Stringer 4040 func (n SelectionStatementCase) String() string { 4041 switch n { 4042 case SelectionStatementIf: 4043 return "SelectionStatementIf" 4044 case SelectionStatementIfElse: 4045 return "SelectionStatementIfElse" 4046 case SelectionStatementSwitch: 4047 return "SelectionStatementSwitch" 4048 default: 4049 return fmt.Sprintf("SelectionStatementCase(%v)", int(n)) 4050 } 4051 } 4052 4053 // SelectionStatement represents data reduced by productions: 4054 // 4055 // SelectionStatement: 4056 // "if" '(' Expression ')' Statement // Case SelectionStatementIf 4057 // | "if" '(' Expression ')' Statement "else" Statement // Case SelectionStatementIfElse 4058 // | "switch" '(' Expression ')' Statement // Case SelectionStatementSwitch 4059 type SelectionStatement struct { 4060 promote Type // switch expression promoted type 4061 cases []*LabeledStatement 4062 Case SelectionStatementCase `PrettyPrint:"stringer,zero"` 4063 Expression *Expression 4064 Statement *Statement 4065 Statement2 *Statement 4066 Token Token 4067 Token2 Token 4068 Token3 Token 4069 Token4 Token 4070 } 4071 4072 // String implements fmt.Stringer. 4073 func (n *SelectionStatement) String() string { return PrettyString(n) } 4074 4075 // Position reports the position of the first component of n, if available. 4076 func (n *SelectionStatement) Position() (r token.Position) { 4077 if n == nil { 4078 return r 4079 } 4080 4081 switch n.Case { 4082 case 0, 2: 4083 if p := n.Token.Position(); p.IsValid() { 4084 return p 4085 } 4086 4087 if p := n.Token2.Position(); p.IsValid() { 4088 return p 4089 } 4090 4091 if p := n.Expression.Position(); p.IsValid() { 4092 return p 4093 } 4094 4095 if p := n.Token3.Position(); p.IsValid() { 4096 return p 4097 } 4098 4099 return n.Statement.Position() 4100 case 1: 4101 if p := n.Token.Position(); p.IsValid() { 4102 return p 4103 } 4104 4105 if p := n.Token2.Position(); p.IsValid() { 4106 return p 4107 } 4108 4109 if p := n.Expression.Position(); p.IsValid() { 4110 return p 4111 } 4112 4113 if p := n.Token3.Position(); p.IsValid() { 4114 return p 4115 } 4116 4117 if p := n.Statement.Position(); p.IsValid() { 4118 return p 4119 } 4120 4121 if p := n.Token4.Position(); p.IsValid() { 4122 return p 4123 } 4124 4125 return n.Statement2.Position() 4126 default: 4127 panic("internal error") 4128 } 4129 } 4130 4131 // ShiftExpressionCase represents case numbers of production ShiftExpression 4132 type ShiftExpressionCase int 4133 4134 // Values of type ShiftExpressionCase 4135 const ( 4136 ShiftExpressionAdd ShiftExpressionCase = iota 4137 ShiftExpressionLsh 4138 ShiftExpressionRsh 4139 ) 4140 4141 // String implements fmt.Stringer 4142 func (n ShiftExpressionCase) String() string { 4143 switch n { 4144 case ShiftExpressionAdd: 4145 return "ShiftExpressionAdd" 4146 case ShiftExpressionLsh: 4147 return "ShiftExpressionLsh" 4148 case ShiftExpressionRsh: 4149 return "ShiftExpressionRsh" 4150 default: 4151 return fmt.Sprintf("ShiftExpressionCase(%v)", int(n)) 4152 } 4153 } 4154 4155 // ShiftExpression represents data reduced by productions: 4156 // 4157 // ShiftExpression: 4158 // AdditiveExpression // Case ShiftExpressionAdd 4159 // | ShiftExpression "<<" AdditiveExpression // Case ShiftExpressionLsh 4160 // | ShiftExpression ">>" AdditiveExpression // Case ShiftExpressionRsh 4161 type ShiftExpression struct { 4162 Operand Operand 4163 promote Type // shift count promoted type 4164 IsSideEffectsFree bool 4165 AdditiveExpression *AdditiveExpression 4166 Case ShiftExpressionCase `PrettyPrint:"stringer,zero"` 4167 ShiftExpression *ShiftExpression 4168 Token Token 4169 } 4170 4171 // String implements fmt.Stringer. 4172 func (n *ShiftExpression) String() string { return PrettyString(n) } 4173 4174 // Position reports the position of the first component of n, if available. 4175 func (n *ShiftExpression) Position() (r token.Position) { 4176 if n == nil { 4177 return r 4178 } 4179 4180 switch n.Case { 4181 case 0: 4182 return n.AdditiveExpression.Position() 4183 case 1, 2: 4184 if p := n.ShiftExpression.Position(); p.IsValid() { 4185 return p 4186 } 4187 4188 if p := n.Token.Position(); p.IsValid() { 4189 return p 4190 } 4191 4192 return n.AdditiveExpression.Position() 4193 default: 4194 panic("internal error") 4195 } 4196 } 4197 4198 // SpecifierQualifierListCase represents case numbers of production SpecifierQualifierList 4199 type SpecifierQualifierListCase int 4200 4201 // Values of type SpecifierQualifierListCase 4202 const ( 4203 SpecifierQualifierListTypeSpec SpecifierQualifierListCase = iota 4204 SpecifierQualifierListTypeQual 4205 SpecifierQualifierListAlignSpec 4206 SpecifierQualifierListAttribute 4207 ) 4208 4209 // String implements fmt.Stringer 4210 func (n SpecifierQualifierListCase) String() string { 4211 switch n { 4212 case SpecifierQualifierListTypeSpec: 4213 return "SpecifierQualifierListTypeSpec" 4214 case SpecifierQualifierListTypeQual: 4215 return "SpecifierQualifierListTypeQual" 4216 case SpecifierQualifierListAlignSpec: 4217 return "SpecifierQualifierListAlignSpec" 4218 case SpecifierQualifierListAttribute: 4219 return "SpecifierQualifierListAttribute" 4220 default: 4221 return fmt.Sprintf("SpecifierQualifierListCase(%v)", int(n)) 4222 } 4223 } 4224 4225 // SpecifierQualifierList represents data reduced by productions: 4226 // 4227 // SpecifierQualifierList: 4228 // TypeSpecifier SpecifierQualifierList // Case SpecifierQualifierListTypeSpec 4229 // | TypeQualifier SpecifierQualifierList // Case SpecifierQualifierListTypeQual 4230 // | AlignmentSpecifier SpecifierQualifierList // Case SpecifierQualifierListAlignSpec 4231 // | AttributeSpecifier SpecifierQualifierList // Case SpecifierQualifierListAttribute 4232 type SpecifierQualifierList struct { 4233 noStorageClass 4234 AlignmentSpecifier *AlignmentSpecifier 4235 AttributeSpecifier *AttributeSpecifier 4236 Case SpecifierQualifierListCase `PrettyPrint:"stringer,zero"` 4237 SpecifierQualifierList *SpecifierQualifierList 4238 TypeQualifier *TypeQualifier 4239 TypeSpecifier *TypeSpecifier 4240 } 4241 4242 // String implements fmt.Stringer. 4243 func (n *SpecifierQualifierList) String() string { return PrettyString(n) } 4244 4245 // Position reports the position of the first component of n, if available. 4246 func (n *SpecifierQualifierList) Position() (r token.Position) { 4247 if n == nil { 4248 return r 4249 } 4250 4251 switch n.Case { 4252 case 2: 4253 if p := n.AlignmentSpecifier.Position(); p.IsValid() { 4254 return p 4255 } 4256 4257 return n.SpecifierQualifierList.Position() 4258 case 3: 4259 if p := n.AttributeSpecifier.Position(); p.IsValid() { 4260 return p 4261 } 4262 4263 return n.SpecifierQualifierList.Position() 4264 case 1: 4265 if p := n.TypeQualifier.Position(); p.IsValid() { 4266 return p 4267 } 4268 4269 return n.SpecifierQualifierList.Position() 4270 case 0: 4271 if p := n.TypeSpecifier.Position(); p.IsValid() { 4272 return p 4273 } 4274 4275 return n.SpecifierQualifierList.Position() 4276 default: 4277 panic("internal error") 4278 } 4279 } 4280 4281 // StatementCase represents case numbers of production Statement 4282 type StatementCase int 4283 4284 // Values of type StatementCase 4285 const ( 4286 StatementLabeled StatementCase = iota 4287 StatementCompound 4288 StatementExpr 4289 StatementSelection 4290 StatementIteration 4291 StatementJump 4292 StatementAsm 4293 ) 4294 4295 // String implements fmt.Stringer 4296 func (n StatementCase) String() string { 4297 switch n { 4298 case StatementLabeled: 4299 return "StatementLabeled" 4300 case StatementCompound: 4301 return "StatementCompound" 4302 case StatementExpr: 4303 return "StatementExpr" 4304 case StatementSelection: 4305 return "StatementSelection" 4306 case StatementIteration: 4307 return "StatementIteration" 4308 case StatementJump: 4309 return "StatementJump" 4310 case StatementAsm: 4311 return "StatementAsm" 4312 default: 4313 return fmt.Sprintf("StatementCase(%v)", int(n)) 4314 } 4315 } 4316 4317 // Statement represents data reduced by productions: 4318 // 4319 // Statement: 4320 // LabeledStatement // Case StatementLabeled 4321 // | CompoundStatement // Case StatementCompound 4322 // | ExpressionStatement // Case StatementExpr 4323 // | SelectionStatement // Case StatementSelection 4324 // | IterationStatement // Case StatementIteration 4325 // | JumpStatement // Case StatementJump 4326 // | AsmStatement // Case StatementAsm 4327 type Statement struct { 4328 Operand Operand // Case CompoundStatement, ExpressionStatement 4329 AsmStatement *AsmStatement 4330 Case StatementCase `PrettyPrint:"stringer,zero"` 4331 CompoundStatement *CompoundStatement 4332 ExpressionStatement *ExpressionStatement 4333 IterationStatement *IterationStatement 4334 JumpStatement *JumpStatement 4335 LabeledStatement *LabeledStatement 4336 SelectionStatement *SelectionStatement 4337 } 4338 4339 // String implements fmt.Stringer. 4340 func (n *Statement) String() string { return PrettyString(n) } 4341 4342 // Position reports the position of the first component of n, if available. 4343 func (n *Statement) Position() (r token.Position) { 4344 if n == nil { 4345 return r 4346 } 4347 4348 switch n.Case { 4349 case 6: 4350 return n.AsmStatement.Position() 4351 case 1: 4352 return n.CompoundStatement.Position() 4353 case 2: 4354 return n.ExpressionStatement.Position() 4355 case 4: 4356 return n.IterationStatement.Position() 4357 case 5: 4358 return n.JumpStatement.Position() 4359 case 0: 4360 return n.LabeledStatement.Position() 4361 case 3: 4362 return n.SelectionStatement.Position() 4363 default: 4364 panic("internal error") 4365 } 4366 } 4367 4368 // StorageClassSpecifierCase represents case numbers of production StorageClassSpecifier 4369 type StorageClassSpecifierCase int 4370 4371 // Values of type StorageClassSpecifierCase 4372 const ( 4373 StorageClassSpecifierTypedef StorageClassSpecifierCase = iota 4374 StorageClassSpecifierExtern 4375 StorageClassSpecifierStatic 4376 StorageClassSpecifierAuto 4377 StorageClassSpecifierRegister 4378 StorageClassSpecifierThreadLocal 4379 ) 4380 4381 // String implements fmt.Stringer 4382 func (n StorageClassSpecifierCase) String() string { 4383 switch n { 4384 case StorageClassSpecifierTypedef: 4385 return "StorageClassSpecifierTypedef" 4386 case StorageClassSpecifierExtern: 4387 return "StorageClassSpecifierExtern" 4388 case StorageClassSpecifierStatic: 4389 return "StorageClassSpecifierStatic" 4390 case StorageClassSpecifierAuto: 4391 return "StorageClassSpecifierAuto" 4392 case StorageClassSpecifierRegister: 4393 return "StorageClassSpecifierRegister" 4394 case StorageClassSpecifierThreadLocal: 4395 return "StorageClassSpecifierThreadLocal" 4396 default: 4397 return fmt.Sprintf("StorageClassSpecifierCase(%v)", int(n)) 4398 } 4399 } 4400 4401 // StorageClassSpecifier represents data reduced by productions: 4402 // 4403 // StorageClassSpecifier: 4404 // "typedef" // Case StorageClassSpecifierTypedef 4405 // | "extern" // Case StorageClassSpecifierExtern 4406 // | "static" // Case StorageClassSpecifierStatic 4407 // | "auto" // Case StorageClassSpecifierAuto 4408 // | "register" // Case StorageClassSpecifierRegister 4409 // | "_Thread_local" // Case StorageClassSpecifierThreadLocal 4410 type StorageClassSpecifier struct { 4411 Case StorageClassSpecifierCase `PrettyPrint:"stringer,zero"` 4412 Token Token 4413 } 4414 4415 // String implements fmt.Stringer. 4416 func (n *StorageClassSpecifier) String() string { return PrettyString(n) } 4417 4418 // Position reports the position of the first component of n, if available. 4419 func (n *StorageClassSpecifier) Position() (r token.Position) { 4420 if n == nil { 4421 return r 4422 } 4423 4424 return n.Token.Position() 4425 } 4426 4427 // StructDeclaration represents data reduced by production: 4428 // 4429 // StructDeclaration: 4430 // SpecifierQualifierList StructDeclaratorList ';' 4431 type StructDeclaration struct { 4432 Empty bool // TCC extension 4433 SpecifierQualifierList *SpecifierQualifierList 4434 StructDeclaratorList *StructDeclaratorList 4435 Token Token 4436 } 4437 4438 // String implements fmt.Stringer. 4439 func (n *StructDeclaration) String() string { return PrettyString(n) } 4440 4441 // Position reports the position of the first component of n, if available. 4442 func (n *StructDeclaration) Position() (r token.Position) { 4443 if n == nil { 4444 return r 4445 } 4446 4447 if p := n.SpecifierQualifierList.Position(); p.IsValid() { 4448 return p 4449 } 4450 4451 if p := n.StructDeclaratorList.Position(); p.IsValid() { 4452 return p 4453 } 4454 4455 return n.Token.Position() 4456 } 4457 4458 // StructDeclarationList represents data reduced by productions: 4459 // 4460 // StructDeclarationList: 4461 // StructDeclaration 4462 // | StructDeclarationList StructDeclaration 4463 type StructDeclarationList struct { 4464 StructDeclaration *StructDeclaration 4465 StructDeclarationList *StructDeclarationList 4466 } 4467 4468 // String implements fmt.Stringer. 4469 func (n *StructDeclarationList) String() string { return PrettyString(n) } 4470 4471 // Position reports the position of the first component of n, if available. 4472 func (n *StructDeclarationList) Position() (r token.Position) { 4473 if n == nil { 4474 return r 4475 } 4476 4477 return n.StructDeclaration.Position() 4478 } 4479 4480 // StructDeclaratorCase represents case numbers of production StructDeclarator 4481 type StructDeclaratorCase int 4482 4483 // Values of type StructDeclaratorCase 4484 const ( 4485 StructDeclaratorDecl StructDeclaratorCase = iota 4486 StructDeclaratorBitField 4487 ) 4488 4489 // String implements fmt.Stringer 4490 func (n StructDeclaratorCase) String() string { 4491 switch n { 4492 case StructDeclaratorDecl: 4493 return "StructDeclaratorDecl" 4494 case StructDeclaratorBitField: 4495 return "StructDeclaratorBitField" 4496 default: 4497 return fmt.Sprintf("StructDeclaratorCase(%v)", int(n)) 4498 } 4499 } 4500 4501 // StructDeclarator represents data reduced by productions: 4502 // 4503 // StructDeclarator: 4504 // Declarator // Case StructDeclaratorDecl 4505 // | Declarator ':' ConstantExpression AttributeSpecifierList // Case StructDeclaratorBitField 4506 type StructDeclarator struct { 4507 decl *StructDeclaration 4508 AttributeSpecifierList *AttributeSpecifierList 4509 Case StructDeclaratorCase `PrettyPrint:"stringer,zero"` 4510 ConstantExpression *ConstantExpression 4511 Declarator *Declarator 4512 Token Token 4513 } 4514 4515 // String implements fmt.Stringer. 4516 func (n *StructDeclarator) String() string { return PrettyString(n) } 4517 4518 // Position reports the position of the first component of n, if available. 4519 func (n *StructDeclarator) Position() (r token.Position) { 4520 if n == nil { 4521 return r 4522 } 4523 4524 switch n.Case { 4525 case 0: 4526 return n.Declarator.Position() 4527 case 1: 4528 if p := n.Declarator.Position(); p.IsValid() { 4529 return p 4530 } 4531 4532 if p := n.Token.Position(); p.IsValid() { 4533 return p 4534 } 4535 4536 if p := n.ConstantExpression.Position(); p.IsValid() { 4537 return p 4538 } 4539 4540 return n.AttributeSpecifierList.Position() 4541 default: 4542 panic("internal error") 4543 } 4544 } 4545 4546 // StructDeclaratorList represents data reduced by productions: 4547 // 4548 // StructDeclaratorList: 4549 // StructDeclarator 4550 // | StructDeclaratorList ',' StructDeclarator 4551 type StructDeclaratorList struct { 4552 StructDeclarator *StructDeclarator 4553 StructDeclaratorList *StructDeclaratorList 4554 Token Token 4555 } 4556 4557 // String implements fmt.Stringer. 4558 func (n *StructDeclaratorList) String() string { return PrettyString(n) } 4559 4560 // Position reports the position of the first component of n, if available. 4561 func (n *StructDeclaratorList) Position() (r token.Position) { 4562 if n == nil { 4563 return r 4564 } 4565 4566 return n.StructDeclarator.Position() 4567 } 4568 4569 // StructOrUnionCase represents case numbers of production StructOrUnion 4570 type StructOrUnionCase int 4571 4572 // Values of type StructOrUnionCase 4573 const ( 4574 StructOrUnionStruct StructOrUnionCase = iota 4575 StructOrUnionUnion 4576 ) 4577 4578 // String implements fmt.Stringer 4579 func (n StructOrUnionCase) String() string { 4580 switch n { 4581 case StructOrUnionStruct: 4582 return "StructOrUnionStruct" 4583 case StructOrUnionUnion: 4584 return "StructOrUnionUnion" 4585 default: 4586 return fmt.Sprintf("StructOrUnionCase(%v)", int(n)) 4587 } 4588 } 4589 4590 // StructOrUnion represents data reduced by productions: 4591 // 4592 // StructOrUnion: 4593 // "struct" // Case StructOrUnionStruct 4594 // | "union" // Case StructOrUnionUnion 4595 type StructOrUnion struct { 4596 Case StructOrUnionCase `PrettyPrint:"stringer,zero"` 4597 Token Token 4598 } 4599 4600 // String implements fmt.Stringer. 4601 func (n *StructOrUnion) String() string { return PrettyString(n) } 4602 4603 // Position reports the position of the first component of n, if available. 4604 func (n *StructOrUnion) Position() (r token.Position) { 4605 if n == nil { 4606 return r 4607 } 4608 4609 return n.Token.Position() 4610 } 4611 4612 // StructOrUnionSpecifierCase represents case numbers of production StructOrUnionSpecifier 4613 type StructOrUnionSpecifierCase int 4614 4615 // Values of type StructOrUnionSpecifierCase 4616 const ( 4617 StructOrUnionSpecifierDef StructOrUnionSpecifierCase = iota 4618 StructOrUnionSpecifierTag 4619 ) 4620 4621 // String implements fmt.Stringer 4622 func (n StructOrUnionSpecifierCase) String() string { 4623 switch n { 4624 case StructOrUnionSpecifierDef: 4625 return "StructOrUnionSpecifierDef" 4626 case StructOrUnionSpecifierTag: 4627 return "StructOrUnionSpecifierTag" 4628 default: 4629 return fmt.Sprintf("StructOrUnionSpecifierCase(%v)", int(n)) 4630 } 4631 } 4632 4633 // StructOrUnionSpecifier represents data reduced by productions: 4634 // 4635 // StructOrUnionSpecifier: 4636 // StructOrUnion AttributeSpecifierList IDENTIFIER '{' StructDeclarationList '}' // Case StructOrUnionSpecifierDef 4637 // | StructOrUnion AttributeSpecifierList IDENTIFIER // Case StructOrUnionSpecifierTag 4638 type StructOrUnionSpecifier struct { 4639 lexicalScope Scope 4640 maxAlign int 4641 typ Type 4642 AttributeSpecifierList *AttributeSpecifierList 4643 Case StructOrUnionSpecifierCase `PrettyPrint:"stringer,zero"` 4644 StructDeclarationList *StructDeclarationList 4645 StructOrUnion *StructOrUnion 4646 Token Token 4647 Token2 Token 4648 Token3 Token 4649 } 4650 4651 // String implements fmt.Stringer. 4652 func (n *StructOrUnionSpecifier) String() string { return PrettyString(n) } 4653 4654 // Position reports the position of the first component of n, if available. 4655 func (n *StructOrUnionSpecifier) Position() (r token.Position) { 4656 if n == nil { 4657 return r 4658 } 4659 4660 switch n.Case { 4661 case 1: 4662 if p := n.StructOrUnion.Position(); p.IsValid() { 4663 return p 4664 } 4665 4666 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 4667 return p 4668 } 4669 4670 return n.Token.Position() 4671 case 0: 4672 if p := n.StructOrUnion.Position(); p.IsValid() { 4673 return p 4674 } 4675 4676 if p := n.AttributeSpecifierList.Position(); p.IsValid() { 4677 return p 4678 } 4679 4680 if p := n.Token.Position(); p.IsValid() { 4681 return p 4682 } 4683 4684 if p := n.Token2.Position(); p.IsValid() { 4685 return p 4686 } 4687 4688 if p := n.StructDeclarationList.Position(); p.IsValid() { 4689 return p 4690 } 4691 4692 return n.Token3.Position() 4693 default: 4694 panic("internal error") 4695 } 4696 } 4697 4698 // TranslationUnit represents data reduced by productions: 4699 // 4700 // TranslationUnit: 4701 // ExternalDeclaration 4702 // | TranslationUnit ExternalDeclaration 4703 type TranslationUnit struct { 4704 ExternalDeclaration *ExternalDeclaration 4705 TranslationUnit *TranslationUnit 4706 } 4707 4708 // String implements fmt.Stringer. 4709 func (n *TranslationUnit) String() string { return PrettyString(n) } 4710 4711 // Position reports the position of the first component of n, if available. 4712 func (n *TranslationUnit) Position() (r token.Position) { 4713 if n == nil { 4714 return r 4715 } 4716 4717 return n.ExternalDeclaration.Position() 4718 } 4719 4720 // TypeName represents data reduced by production: 4721 // 4722 // TypeName: 4723 // SpecifierQualifierList AbstractDeclarator 4724 type TypeName struct { 4725 typ Type 4726 AbstractDeclarator *AbstractDeclarator 4727 SpecifierQualifierList *SpecifierQualifierList 4728 } 4729 4730 // String implements fmt.Stringer. 4731 func (n *TypeName) String() string { return PrettyString(n) } 4732 4733 // Position reports the position of the first component of n, if available. 4734 func (n *TypeName) Position() (r token.Position) { 4735 if n == nil { 4736 return r 4737 } 4738 4739 if p := n.SpecifierQualifierList.Position(); p.IsValid() { 4740 return p 4741 } 4742 4743 return n.AbstractDeclarator.Position() 4744 } 4745 4746 // TypeQualifierCase represents case numbers of production TypeQualifier 4747 type TypeQualifierCase int 4748 4749 // Values of type TypeQualifierCase 4750 const ( 4751 TypeQualifierConst TypeQualifierCase = iota 4752 TypeQualifierRestrict 4753 TypeQualifierVolatile 4754 TypeQualifierAtomic 4755 ) 4756 4757 // String implements fmt.Stringer 4758 func (n TypeQualifierCase) String() string { 4759 switch n { 4760 case TypeQualifierConst: 4761 return "TypeQualifierConst" 4762 case TypeQualifierRestrict: 4763 return "TypeQualifierRestrict" 4764 case TypeQualifierVolatile: 4765 return "TypeQualifierVolatile" 4766 case TypeQualifierAtomic: 4767 return "TypeQualifierAtomic" 4768 default: 4769 return fmt.Sprintf("TypeQualifierCase(%v)", int(n)) 4770 } 4771 } 4772 4773 // TypeQualifier represents data reduced by productions: 4774 // 4775 // TypeQualifier: 4776 // "const" // Case TypeQualifierConst 4777 // | "restrict" // Case TypeQualifierRestrict 4778 // | "volatile" // Case TypeQualifierVolatile 4779 // | "_Atomic" // Case TypeQualifierAtomic 4780 type TypeQualifier struct { 4781 Case TypeQualifierCase `PrettyPrint:"stringer,zero"` 4782 Token Token 4783 } 4784 4785 // String implements fmt.Stringer. 4786 func (n *TypeQualifier) String() string { return PrettyString(n) } 4787 4788 // Position reports the position of the first component of n, if available. 4789 func (n *TypeQualifier) Position() (r token.Position) { 4790 if n == nil { 4791 return r 4792 } 4793 4794 return n.Token.Position() 4795 } 4796 4797 // TypeQualifiersCase represents case numbers of production TypeQualifiers 4798 type TypeQualifiersCase int 4799 4800 // Values of type TypeQualifiersCase 4801 const ( 4802 TypeQualifiersTypeQual TypeQualifiersCase = iota 4803 TypeQualifiersAttribute 4804 _ 4805 _ 4806 ) 4807 4808 // String implements fmt.Stringer 4809 func (n TypeQualifiersCase) String() string { 4810 switch n { 4811 case TypeQualifiersTypeQual: 4812 return "TypeQualifiersTypeQual" 4813 case TypeQualifiersAttribute: 4814 return "TypeQualifiersAttribute" 4815 default: 4816 return fmt.Sprintf("TypeQualifiersCase(%v)", int(n)) 4817 } 4818 } 4819 4820 // TypeQualifiers represents data reduced by productions: 4821 // 4822 // TypeQualifiers: 4823 // TypeQualifier // Case TypeQualifiersTypeQual 4824 // | AttributeSpecifier // Case TypeQualifiersAttribute 4825 // | TypeQualifiers TypeQualifier // Case 2 4826 // | TypeQualifiers AttributeSpecifier // Case 3 4827 type TypeQualifiers struct { 4828 noStorageClass 4829 AttributeSpecifier *AttributeSpecifier 4830 Case TypeQualifiersCase `PrettyPrint:"stringer,zero"` 4831 TypeQualifier *TypeQualifier 4832 TypeQualifiers *TypeQualifiers 4833 } 4834 4835 // String implements fmt.Stringer. 4836 func (n *TypeQualifiers) String() string { return PrettyString(n) } 4837 4838 // Position reports the position of the first component of n, if available. 4839 func (n *TypeQualifiers) Position() (r token.Position) { 4840 if n == nil { 4841 return r 4842 } 4843 4844 switch n.Case { 4845 case 1: 4846 return n.AttributeSpecifier.Position() 4847 case 0: 4848 return n.TypeQualifier.Position() 4849 case 3: 4850 if p := n.TypeQualifiers.Position(); p.IsValid() { 4851 return p 4852 } 4853 4854 return n.AttributeSpecifier.Position() 4855 case 2: 4856 if p := n.TypeQualifiers.Position(); p.IsValid() { 4857 return p 4858 } 4859 4860 return n.TypeQualifier.Position() 4861 default: 4862 panic("internal error") 4863 } 4864 } 4865 4866 // TypeSpecifierCase represents case numbers of production TypeSpecifier 4867 type TypeSpecifierCase int 4868 4869 // Values of type TypeSpecifierCase 4870 const ( 4871 TypeSpecifierVoid TypeSpecifierCase = iota 4872 TypeSpecifierChar 4873 TypeSpecifierShort 4874 TypeSpecifierInt 4875 TypeSpecifierInt8 4876 TypeSpecifierInt16 4877 TypeSpecifierInt32 4878 TypeSpecifierInt64 4879 TypeSpecifierInt128 4880 TypeSpecifierLong 4881 TypeSpecifierFloat 4882 TypeSpecifierFloat16 4883 TypeSpecifierDecimal32 4884 TypeSpecifierDecimal64 4885 TypeSpecifierDecimal128 4886 TypeSpecifierFloat128 4887 TypeSpecifierFloat80 4888 TypeSpecifierDouble 4889 TypeSpecifierSigned 4890 TypeSpecifierUnsigned 4891 TypeSpecifierBool 4892 TypeSpecifierComplex 4893 TypeSpecifierStructOrUnion 4894 TypeSpecifierEnum 4895 TypeSpecifierTypedefName 4896 TypeSpecifierTypeofExpr 4897 TypeSpecifierTypeofType 4898 TypeSpecifierAtomic 4899 TypeSpecifierFract 4900 TypeSpecifierSat 4901 TypeSpecifierAccum 4902 TypeSpecifierFloat32 4903 TypeSpecifierFloat64 4904 TypeSpecifierFloat32x 4905 TypeSpecifierFloat64x 4906 ) 4907 4908 // String implements fmt.Stringer 4909 func (n TypeSpecifierCase) String() string { 4910 switch n { 4911 case TypeSpecifierVoid: 4912 return "TypeSpecifierVoid" 4913 case TypeSpecifierChar: 4914 return "TypeSpecifierChar" 4915 case TypeSpecifierShort: 4916 return "TypeSpecifierShort" 4917 case TypeSpecifierInt: 4918 return "TypeSpecifierInt" 4919 case TypeSpecifierInt8: 4920 return "TypeSpecifierInt8" 4921 case TypeSpecifierInt16: 4922 return "TypeSpecifierInt16" 4923 case TypeSpecifierInt32: 4924 return "TypeSpecifierInt32" 4925 case TypeSpecifierInt64: 4926 return "TypeSpecifierInt64" 4927 case TypeSpecifierInt128: 4928 return "TypeSpecifierInt128" 4929 case TypeSpecifierLong: 4930 return "TypeSpecifierLong" 4931 case TypeSpecifierFloat: 4932 return "TypeSpecifierFloat" 4933 case TypeSpecifierFloat16: 4934 return "TypeSpecifierFloat16" 4935 case TypeSpecifierDecimal32: 4936 return "TypeSpecifierDecimal32" 4937 case TypeSpecifierDecimal64: 4938 return "TypeSpecifierDecimal64" 4939 case TypeSpecifierDecimal128: 4940 return "TypeSpecifierDecimal128" 4941 case TypeSpecifierFloat128: 4942 return "TypeSpecifierFloat128" 4943 case TypeSpecifierFloat80: 4944 return "TypeSpecifierFloat80" 4945 case TypeSpecifierDouble: 4946 return "TypeSpecifierDouble" 4947 case TypeSpecifierSigned: 4948 return "TypeSpecifierSigned" 4949 case TypeSpecifierUnsigned: 4950 return "TypeSpecifierUnsigned" 4951 case TypeSpecifierBool: 4952 return "TypeSpecifierBool" 4953 case TypeSpecifierComplex: 4954 return "TypeSpecifierComplex" 4955 case TypeSpecifierStructOrUnion: 4956 return "TypeSpecifierStructOrUnion" 4957 case TypeSpecifierEnum: 4958 return "TypeSpecifierEnum" 4959 case TypeSpecifierTypedefName: 4960 return "TypeSpecifierTypedefName" 4961 case TypeSpecifierTypeofExpr: 4962 return "TypeSpecifierTypeofExpr" 4963 case TypeSpecifierTypeofType: 4964 return "TypeSpecifierTypeofType" 4965 case TypeSpecifierAtomic: 4966 return "TypeSpecifierAtomic" 4967 case TypeSpecifierFract: 4968 return "TypeSpecifierFract" 4969 case TypeSpecifierSat: 4970 return "TypeSpecifierSat" 4971 case TypeSpecifierAccum: 4972 return "TypeSpecifierAccum" 4973 case TypeSpecifierFloat32: 4974 return "TypeSpecifierFloat32" 4975 case TypeSpecifierFloat64: 4976 return "TypeSpecifierFloat64" 4977 case TypeSpecifierFloat32x: 4978 return "TypeSpecifierFloat32x" 4979 case TypeSpecifierFloat64x: 4980 return "TypeSpecifierFloat64x" 4981 default: 4982 return fmt.Sprintf("TypeSpecifierCase(%v)", int(n)) 4983 } 4984 } 4985 4986 // TypeSpecifier represents data reduced by productions: 4987 // 4988 // TypeSpecifier: 4989 // "void" // Case TypeSpecifierVoid 4990 // | "char" // Case TypeSpecifierChar 4991 // | "short" // Case TypeSpecifierShort 4992 // | "int" // Case TypeSpecifierInt 4993 // | "__int8" // Case TypeSpecifierInt8 4994 // | "__int16" // Case TypeSpecifierInt16 4995 // | "__int32" // Case TypeSpecifierInt32 4996 // | "__int64" // Case TypeSpecifierInt64 4997 // | "__int128" // Case TypeSpecifierInt128 4998 // | "long" // Case TypeSpecifierLong 4999 // | "float" // Case TypeSpecifierFloat 5000 // | "__fp16" // Case TypeSpecifierFloat16 5001 // | "_Decimal32" // Case TypeSpecifierDecimal32 5002 // | "_Decimal64" // Case TypeSpecifierDecimal64 5003 // | "_Decimal128" // Case TypeSpecifierDecimal128 5004 // | "_Float128" // Case TypeSpecifierFloat128 5005 // | "__float80" // Case TypeSpecifierFloat80 5006 // | "double" // Case TypeSpecifierDouble 5007 // | "signed" // Case TypeSpecifierSigned 5008 // | "unsigned" // Case TypeSpecifierUnsigned 5009 // | "_Bool" // Case TypeSpecifierBool 5010 // | "_Complex" // Case TypeSpecifierComplex 5011 // | StructOrUnionSpecifier // Case TypeSpecifierStructOrUnion 5012 // | EnumSpecifier // Case TypeSpecifierEnum 5013 // | TYPEDEFNAME // Case TypeSpecifierTypedefName 5014 // | "typeof" '(' Expression ')' // Case TypeSpecifierTypeofExpr 5015 // | "typeof" '(' TypeName ')' // Case TypeSpecifierTypeofType 5016 // | AtomicTypeSpecifier // Case TypeSpecifierAtomic 5017 // | "_Fract" // Case TypeSpecifierFract 5018 // | "_Sat" // Case TypeSpecifierSat 5019 // | "_Accum" // Case TypeSpecifierAccum 5020 // | "_Float32" // Case TypeSpecifierFloat32 5021 // | "_Float64" // Case TypeSpecifierFloat64 5022 // | "_Float32x" // Case TypeSpecifierFloat32x 5023 // | "_Float64x" // Case TypeSpecifierFloat64x 5024 type TypeSpecifier struct { 5025 resolvedIn Scope // Case TypedefName 5026 typ Type 5027 AtomicTypeSpecifier *AtomicTypeSpecifier 5028 Case TypeSpecifierCase `PrettyPrint:"stringer,zero"` 5029 EnumSpecifier *EnumSpecifier 5030 Expression *Expression 5031 StructOrUnionSpecifier *StructOrUnionSpecifier 5032 Token Token 5033 Token2 Token 5034 Token3 Token 5035 TypeName *TypeName 5036 } 5037 5038 // String implements fmt.Stringer. 5039 func (n *TypeSpecifier) String() string { return PrettyString(n) } 5040 5041 // Position reports the position of the first component of n, if available. 5042 func (n *TypeSpecifier) Position() (r token.Position) { 5043 if n == nil { 5044 return r 5045 } 5046 5047 switch n.Case { 5048 case 27: 5049 return n.AtomicTypeSpecifier.Position() 5050 case 23: 5051 return n.EnumSpecifier.Position() 5052 case 22: 5053 return n.StructOrUnionSpecifier.Position() 5054 case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 24, 28, 29, 30, 31, 32, 33, 34: 5055 return n.Token.Position() 5056 case 25: 5057 if p := n.Token.Position(); p.IsValid() { 5058 return p 5059 } 5060 5061 if p := n.Token2.Position(); p.IsValid() { 5062 return p 5063 } 5064 5065 if p := n.Expression.Position(); p.IsValid() { 5066 return p 5067 } 5068 5069 return n.Token3.Position() 5070 case 26: 5071 if p := n.Token.Position(); p.IsValid() { 5072 return p 5073 } 5074 5075 if p := n.Token2.Position(); p.IsValid() { 5076 return p 5077 } 5078 5079 if p := n.TypeName.Position(); p.IsValid() { 5080 return p 5081 } 5082 5083 return n.Token3.Position() 5084 default: 5085 panic("internal error") 5086 } 5087 } 5088 5089 // UnaryExpressionCase represents case numbers of production UnaryExpression 5090 type UnaryExpressionCase int 5091 5092 // Values of type UnaryExpressionCase 5093 const ( 5094 UnaryExpressionPostfix UnaryExpressionCase = iota 5095 UnaryExpressionInc 5096 UnaryExpressionDec 5097 UnaryExpressionAddrof 5098 UnaryExpressionDeref 5099 UnaryExpressionPlus 5100 UnaryExpressionMinus 5101 UnaryExpressionCpl 5102 UnaryExpressionNot 5103 UnaryExpressionSizeofExpr 5104 UnaryExpressionSizeofType 5105 UnaryExpressionLabelAddr 5106 UnaryExpressionAlignofExpr 5107 UnaryExpressionAlignofType 5108 UnaryExpressionImag 5109 UnaryExpressionReal 5110 ) 5111 5112 // String implements fmt.Stringer 5113 func (n UnaryExpressionCase) String() string { 5114 switch n { 5115 case UnaryExpressionPostfix: 5116 return "UnaryExpressionPostfix" 5117 case UnaryExpressionInc: 5118 return "UnaryExpressionInc" 5119 case UnaryExpressionDec: 5120 return "UnaryExpressionDec" 5121 case UnaryExpressionAddrof: 5122 return "UnaryExpressionAddrof" 5123 case UnaryExpressionDeref: 5124 return "UnaryExpressionDeref" 5125 case UnaryExpressionPlus: 5126 return "UnaryExpressionPlus" 5127 case UnaryExpressionMinus: 5128 return "UnaryExpressionMinus" 5129 case UnaryExpressionCpl: 5130 return "UnaryExpressionCpl" 5131 case UnaryExpressionNot: 5132 return "UnaryExpressionNot" 5133 case UnaryExpressionSizeofExpr: 5134 return "UnaryExpressionSizeofExpr" 5135 case UnaryExpressionSizeofType: 5136 return "UnaryExpressionSizeofType" 5137 case UnaryExpressionLabelAddr: 5138 return "UnaryExpressionLabelAddr" 5139 case UnaryExpressionAlignofExpr: 5140 return "UnaryExpressionAlignofExpr" 5141 case UnaryExpressionAlignofType: 5142 return "UnaryExpressionAlignofType" 5143 case UnaryExpressionImag: 5144 return "UnaryExpressionImag" 5145 case UnaryExpressionReal: 5146 return "UnaryExpressionReal" 5147 default: 5148 return fmt.Sprintf("UnaryExpressionCase(%v)", int(n)) 5149 } 5150 } 5151 5152 // UnaryExpression represents data reduced by productions: 5153 // 5154 // UnaryExpression: 5155 // PostfixExpression // Case UnaryExpressionPostfix 5156 // | "++" UnaryExpression // Case UnaryExpressionInc 5157 // | "--" UnaryExpression // Case UnaryExpressionDec 5158 // | '&' CastExpression // Case UnaryExpressionAddrof 5159 // | '*' CastExpression // Case UnaryExpressionDeref 5160 // | '+' CastExpression // Case UnaryExpressionPlus 5161 // | '-' CastExpression // Case UnaryExpressionMinus 5162 // | '~' CastExpression // Case UnaryExpressionCpl 5163 // | '!' CastExpression // Case UnaryExpressionNot 5164 // | "sizeof" UnaryExpression // Case UnaryExpressionSizeofExpr 5165 // | "sizeof" '(' TypeName ')' // Case UnaryExpressionSizeofType 5166 // | "&&" IDENTIFIER // Case UnaryExpressionLabelAddr 5167 // | "_Alignof" UnaryExpression // Case UnaryExpressionAlignofExpr 5168 // | "_Alignof" '(' TypeName ')' // Case UnaryExpressionAlignofType 5169 // | "__imag__" UnaryExpression // Case UnaryExpressionImag 5170 // | "__real__" UnaryExpression // Case UnaryExpressionReal 5171 type UnaryExpression struct { 5172 Operand Operand 5173 lexicalScope Scope 5174 IsSideEffectsFree bool 5175 Case UnaryExpressionCase `PrettyPrint:"stringer,zero"` 5176 CastExpression *CastExpression 5177 PostfixExpression *PostfixExpression 5178 Token Token 5179 Token2 Token 5180 Token3 Token 5181 TypeName *TypeName 5182 UnaryExpression *UnaryExpression 5183 } 5184 5185 // String implements fmt.Stringer. 5186 func (n *UnaryExpression) String() string { return PrettyString(n) } 5187 5188 // Position reports the position of the first component of n, if available. 5189 func (n *UnaryExpression) Position() (r token.Position) { 5190 if n == nil { 5191 return r 5192 } 5193 5194 switch n.Case { 5195 case 0: 5196 return n.PostfixExpression.Position() 5197 case 3, 4, 5, 6, 7, 8: 5198 if p := n.Token.Position(); p.IsValid() { 5199 return p 5200 } 5201 5202 return n.CastExpression.Position() 5203 case 11: 5204 if p := n.Token.Position(); p.IsValid() { 5205 return p 5206 } 5207 5208 return n.Token2.Position() 5209 case 10, 13: 5210 if p := n.Token.Position(); p.IsValid() { 5211 return p 5212 } 5213 5214 if p := n.Token2.Position(); p.IsValid() { 5215 return p 5216 } 5217 5218 if p := n.TypeName.Position(); p.IsValid() { 5219 return p 5220 } 5221 5222 return n.Token3.Position() 5223 case 1, 2, 9, 12, 14, 15: 5224 if p := n.Token.Position(); p.IsValid() { 5225 return p 5226 } 5227 5228 return n.UnaryExpression.Position() 5229 default: 5230 panic("internal error") 5231 } 5232 }