modernc.org/cc@v1.0.1/v2/ast.go (about) 1 // Code generated by yy. DO NOT EDIT. 2 3 // Copyright 2017 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 "go/token" 12 "modernc.org/xc" 13 ) 14 15 // AbstractDeclaratorCase represents case numbers of production AbstractDeclarator 16 type AbstractDeclaratorCase int 17 18 // Values of type AbstractDeclaratorCase 19 const ( 20 AbstractDeclaratorPointer AbstractDeclaratorCase = iota 21 AbstractDeclaratorAbstract 22 ) 23 24 // String implements fmt.Stringer 25 func (n AbstractDeclaratorCase) String() string { 26 switch n { 27 case AbstractDeclaratorPointer: 28 return "AbstractDeclaratorPointer" 29 case AbstractDeclaratorAbstract: 30 return "AbstractDeclaratorAbstract" 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 AbstractDeclaratorPointer 40 // | PointerOpt DirectAbstractDeclarator // Case AbstractDeclaratorAbstract 41 type AbstractDeclarator struct { 42 DeclarationSpecifier *DeclarationSpecifier 43 Type Type 44 TypeQualifiers []*TypeQualifier // From the PointerOpt production, if any. 45 Case AbstractDeclaratorCase 46 DirectAbstractDeclarator *DirectAbstractDeclarator 47 Pointer *Pointer 48 PointerOpt *PointerOpt 49 } 50 51 func (n *AbstractDeclarator) fragment() interface{} { return n } 52 53 // String implements fmt.Stringer. 54 func (n *AbstractDeclarator) String() string { 55 return PrettyString(n) 56 } 57 58 // Pos reports the position of the first component of n or zero if it's empty. 59 func (n *AbstractDeclarator) Pos() token.Pos { 60 if n == nil { 61 return 0 62 } 63 64 switch n.Case { 65 case 0: 66 return n.Pointer.Pos() 67 case 1: 68 if p := n.PointerOpt.Pos(); p != 0 { 69 return p 70 } 71 72 return n.DirectAbstractDeclarator.Pos() 73 default: 74 panic("internal error") 75 } 76 } 77 78 // AbstractDeclaratorOpt represents data reduced by productions: 79 // 80 // AbstractDeclaratorOpt: 81 // /* empty */ // Case 0 82 // | AbstractDeclarator // Case 1 83 type AbstractDeclaratorOpt struct { 84 AbstractDeclarator *AbstractDeclarator 85 } 86 87 func (n *AbstractDeclaratorOpt) fragment() interface{} { return n } 88 89 // String implements fmt.Stringer. 90 func (n *AbstractDeclaratorOpt) String() string { 91 return PrettyString(n) 92 } 93 94 // Pos reports the position of the first component of n or zero if it's empty. 95 func (n *AbstractDeclaratorOpt) Pos() token.Pos { 96 if n == nil { 97 return 0 98 } 99 100 return n.AbstractDeclarator.Pos() 101 } 102 103 // AlignmentSpecifierCase represents case numbers of production AlignmentSpecifier 104 type AlignmentSpecifierCase int 105 106 // Values of type AlignmentSpecifierCase 107 const ( 108 AlignmentSpecifierTypeName AlignmentSpecifierCase = iota 109 AlignmentSpecifierConstExpr 110 ) 111 112 // String implements fmt.Stringer 113 func (n AlignmentSpecifierCase) String() string { 114 switch n { 115 case AlignmentSpecifierTypeName: 116 return "AlignmentSpecifierTypeName" 117 case AlignmentSpecifierConstExpr: 118 return "AlignmentSpecifierConstExpr" 119 default: 120 return fmt.Sprintf("AlignmentSpecifierCase(%v)", int(n)) 121 } 122 } 123 124 // AlignmentSpecifier represents data reduced by productions: 125 // 126 // AlignmentSpecifier: 127 // "_Alignas" '(' TypeName ')' // Case AlignmentSpecifierTypeName 128 // | "_Alignas" '(' ConstExpr ')' // Case AlignmentSpecifierConstExpr 129 type AlignmentSpecifier struct { 130 Case AlignmentSpecifierCase 131 ConstExpr *ConstExpr 132 Token xc.Token 133 Token2 xc.Token 134 Token3 xc.Token 135 TypeName *TypeName 136 } 137 138 func (n *AlignmentSpecifier) fragment() interface{} { return n } 139 140 // String implements fmt.Stringer. 141 func (n *AlignmentSpecifier) String() string { 142 return PrettyString(n) 143 } 144 145 // Pos reports the position of the first component of n or zero if it's empty. 146 func (n *AlignmentSpecifier) Pos() token.Pos { 147 if n == nil { 148 return 0 149 } 150 151 return n.Token.Pos() 152 } 153 154 // ArgumentExprList represents data reduced by productions: 155 // 156 // ArgumentExprList: 157 // Expr // Case 0 158 // | ArgumentExprList ',' Expr // Case 1 159 type ArgumentExprList struct { 160 ArgumentExprList *ArgumentExprList 161 Case int 162 Expr *Expr 163 Token xc.Token 164 } 165 166 func (n *ArgumentExprList) reverse() *ArgumentExprList { 167 if n == nil { 168 return nil 169 } 170 171 na := n 172 nb := na.ArgumentExprList 173 for nb != nil { 174 nc := nb.ArgumentExprList 175 nb.ArgumentExprList = na 176 na = nb 177 nb = nc 178 } 179 n.ArgumentExprList = nil 180 return na 181 } 182 183 func (n *ArgumentExprList) fragment() interface{} { return n.reverse() } 184 185 // String implements fmt.Stringer. 186 func (n *ArgumentExprList) String() string { 187 return PrettyString(n) 188 } 189 190 // Pos reports the position of the first component of n or zero if it's empty. 191 func (n *ArgumentExprList) Pos() token.Pos { 192 if n == nil { 193 return 0 194 } 195 196 switch n.Case { 197 case 1: 198 return n.ArgumentExprList.Pos() 199 case 0: 200 return n.Expr.Pos() 201 default: 202 panic("internal error") 203 } 204 } 205 206 // ArgumentExprListOpt represents data reduced by productions: 207 // 208 // ArgumentExprListOpt: 209 // /* empty */ // Case 0 210 // | ArgumentExprList // Case 1 211 type ArgumentExprListOpt struct { 212 ArgumentExprList *ArgumentExprList 213 } 214 215 func (n *ArgumentExprListOpt) fragment() interface{} { return n } 216 217 // String implements fmt.Stringer. 218 func (n *ArgumentExprListOpt) String() string { 219 return PrettyString(n) 220 } 221 222 // Pos reports the position of the first component of n or zero if it's empty. 223 func (n *ArgumentExprListOpt) Pos() token.Pos { 224 if n == nil { 225 return 0 226 } 227 228 return n.ArgumentExprList.Pos() 229 } 230 231 // BlockItemCase represents case numbers of production BlockItem 232 type BlockItemCase int 233 234 // Values of type BlockItemCase 235 const ( 236 BlockItemDecl BlockItemCase = iota 237 BlockItemStmt 238 ) 239 240 // String implements fmt.Stringer 241 func (n BlockItemCase) String() string { 242 switch n { 243 case BlockItemDecl: 244 return "BlockItemDecl" 245 case BlockItemStmt: 246 return "BlockItemStmt" 247 default: 248 return fmt.Sprintf("BlockItemCase(%v)", int(n)) 249 } 250 } 251 252 // BlockItem represents data reduced by productions: 253 // 254 // BlockItem: 255 // Declaration // Case BlockItemDecl 256 // | Stmt // Case BlockItemStmt 257 type BlockItem struct { 258 Case BlockItemCase 259 Declaration *Declaration 260 Stmt *Stmt 261 } 262 263 func (n *BlockItem) fragment() interface{} { return n } 264 265 // String implements fmt.Stringer. 266 func (n *BlockItem) String() string { 267 return PrettyString(n) 268 } 269 270 // Pos reports the position of the first component of n or zero if it's empty. 271 func (n *BlockItem) Pos() token.Pos { 272 if n == nil { 273 return 0 274 } 275 276 switch n.Case { 277 case 0: 278 return n.Declaration.Pos() 279 case 1: 280 return n.Stmt.Pos() 281 default: 282 panic("internal error") 283 } 284 } 285 286 // BlockItemList represents data reduced by productions: 287 // 288 // BlockItemList: 289 // BlockItem // Case 0 290 // | BlockItemList BlockItem // Case 1 291 type BlockItemList struct { 292 BlockItem *BlockItem 293 BlockItemList *BlockItemList 294 Case int 295 } 296 297 func (n *BlockItemList) reverse() *BlockItemList { 298 if n == nil { 299 return nil 300 } 301 302 na := n 303 nb := na.BlockItemList 304 for nb != nil { 305 nc := nb.BlockItemList 306 nb.BlockItemList = na 307 na = nb 308 nb = nc 309 } 310 n.BlockItemList = nil 311 return na 312 } 313 314 func (n *BlockItemList) fragment() interface{} { return n.reverse() } 315 316 // String implements fmt.Stringer. 317 func (n *BlockItemList) String() string { 318 return PrettyString(n) 319 } 320 321 // Pos reports the position of the first component of n or zero if it's empty. 322 func (n *BlockItemList) Pos() token.Pos { 323 if n == nil { 324 return 0 325 } 326 327 switch n.Case { 328 case 0: 329 return n.BlockItem.Pos() 330 case 1: 331 return n.BlockItemList.Pos() 332 default: 333 panic("internal error") 334 } 335 } 336 337 // BlockItemListOpt represents data reduced by productions: 338 // 339 // BlockItemListOpt: 340 // /* empty */ // Case 0 341 // | BlockItemList // Case 1 342 type BlockItemListOpt struct { 343 BlockItemList *BlockItemList 344 } 345 346 func (n *BlockItemListOpt) fragment() interface{} { return n } 347 348 // String implements fmt.Stringer. 349 func (n *BlockItemListOpt) String() string { 350 return PrettyString(n) 351 } 352 353 // Pos reports the position of the first component of n or zero if it's empty. 354 func (n *BlockItemListOpt) Pos() token.Pos { 355 if n == nil { 356 return 0 357 } 358 359 return n.BlockItemList.Pos() 360 } 361 362 // CommaOpt represents data reduced by productions: 363 // 364 // CommaOpt: 365 // /* empty */ // Case 0 366 // | ',' // Case 1 367 type CommaOpt struct { 368 Token xc.Token 369 } 370 371 func (n *CommaOpt) fragment() interface{} { return n } 372 373 // String implements fmt.Stringer. 374 func (n *CommaOpt) String() string { 375 return PrettyString(n) 376 } 377 378 // Pos reports the position of the first component of n or zero if it's empty. 379 func (n *CommaOpt) Pos() token.Pos { 380 if n == nil { 381 return 0 382 } 383 384 return n.Token.Pos() 385 } 386 387 // CompoundStmt represents data reduced by production: 388 // 389 // CompoundStmt: 390 // '{' BlockItemListOpt statementEnd '}' // Case 0 391 type CompoundStmt struct { 392 scope *Scope 393 UseGotos bool 394 BlockItemListOpt *BlockItemListOpt 395 Token xc.Token 396 Token2 xc.Token 397 statementEnd *statementEnd 398 } 399 400 func (n *CompoundStmt) fragment() interface{} { return n } 401 402 // String implements fmt.Stringer. 403 func (n *CompoundStmt) String() string { 404 return PrettyString(n) 405 } 406 407 // Pos reports the position of the first component of n or zero if it's empty. 408 func (n *CompoundStmt) Pos() token.Pos { 409 if n == nil { 410 return 0 411 } 412 413 return n.Token.Pos() 414 } 415 416 // ConstExpr represents data reduced by production: 417 // 418 // ConstExpr: 419 // Expr // Case 0 420 type ConstExpr struct { 421 Operand Operand 422 Expr *Expr 423 } 424 425 func (n *ConstExpr) fragment() interface{} { return n } 426 427 // String implements fmt.Stringer. 428 func (n *ConstExpr) String() string { 429 return PrettyString(n) 430 } 431 432 // Pos reports the position of the first component of n or zero if it's empty. 433 func (n *ConstExpr) Pos() token.Pos { 434 if n == nil { 435 return 0 436 } 437 438 return n.Expr.Pos() 439 } 440 441 // Declaration represents data reduced by production: 442 // 443 // Declaration: 444 // DeclarationSpecifiers InitDeclaratorListOpt ';' // Case 0 445 type Declaration struct { 446 Attributes [][]xc.Token 447 Scope *Scope 448 DeclarationSpecifiers *DeclarationSpecifiers 449 InitDeclaratorListOpt *InitDeclaratorListOpt 450 Token xc.Token 451 } 452 453 func (n *Declaration) fragment() interface{} { return n } 454 455 // String implements fmt.Stringer. 456 func (n *Declaration) String() string { 457 return PrettyString(n) 458 } 459 460 // Pos reports the position of the first component of n or zero if it's empty. 461 func (n *Declaration) Pos() token.Pos { 462 if n == nil { 463 return 0 464 } 465 466 return n.DeclarationSpecifiers.Pos() 467 } 468 469 // DeclarationList represents data reduced by productions: 470 // 471 // DeclarationList: 472 // Declaration // Case 0 473 // | DeclarationList Declaration // Case 1 474 type DeclarationList struct { 475 Case int 476 Declaration *Declaration 477 DeclarationList *DeclarationList 478 } 479 480 func (n *DeclarationList) reverse() *DeclarationList { 481 if n == nil { 482 return nil 483 } 484 485 na := n 486 nb := na.DeclarationList 487 for nb != nil { 488 nc := nb.DeclarationList 489 nb.DeclarationList = na 490 na = nb 491 nb = nc 492 } 493 n.DeclarationList = nil 494 return na 495 } 496 497 func (n *DeclarationList) fragment() interface{} { return n.reverse() } 498 499 // String implements fmt.Stringer. 500 func (n *DeclarationList) String() string { 501 return PrettyString(n) 502 } 503 504 // Pos reports the position of the first component of n or zero if it's empty. 505 func (n *DeclarationList) Pos() token.Pos { 506 if n == nil { 507 return 0 508 } 509 510 switch n.Case { 511 case 0: 512 return n.Declaration.Pos() 513 case 1: 514 return n.DeclarationList.Pos() 515 default: 516 panic("internal error") 517 } 518 } 519 520 // DeclarationListOpt represents data reduced by productions: 521 // 522 // DeclarationListOpt: 523 // /* empty */ // Case 0 524 // | DeclarationList // Case 1 525 type DeclarationListOpt struct { 526 DeclarationList *DeclarationList 527 } 528 529 func (n *DeclarationListOpt) fragment() interface{} { return n } 530 531 // String implements fmt.Stringer. 532 func (n *DeclarationListOpt) String() string { 533 return PrettyString(n) 534 } 535 536 // Pos reports the position of the first component of n or zero if it's empty. 537 func (n *DeclarationListOpt) Pos() token.Pos { 538 if n == nil { 539 return 0 540 } 541 542 return n.DeclarationList.Pos() 543 } 544 545 // DeclarationSpecifiersCase represents case numbers of production DeclarationSpecifiers 546 type DeclarationSpecifiersCase int 547 548 // Values of type DeclarationSpecifiersCase 549 const ( 550 DeclarationSpecifiersFunc DeclarationSpecifiersCase = iota 551 DeclarationSpecifiersStorage 552 DeclarationSpecifiersQualifier 553 DeclarationSpecifiersSpecifier 554 DeclarationSpecifiersAlignment 555 ) 556 557 // String implements fmt.Stringer 558 func (n DeclarationSpecifiersCase) String() string { 559 switch n { 560 case DeclarationSpecifiersFunc: 561 return "DeclarationSpecifiersFunc" 562 case DeclarationSpecifiersStorage: 563 return "DeclarationSpecifiersStorage" 564 case DeclarationSpecifiersQualifier: 565 return "DeclarationSpecifiersQualifier" 566 case DeclarationSpecifiersSpecifier: 567 return "DeclarationSpecifiersSpecifier" 568 case DeclarationSpecifiersAlignment: 569 return "DeclarationSpecifiersAlignment" 570 default: 571 return fmt.Sprintf("DeclarationSpecifiersCase(%v)", int(n)) 572 } 573 } 574 575 // DeclarationSpecifiers represents data reduced by productions: 576 // 577 // DeclarationSpecifiers: 578 // FunctionSpecifier DeclarationSpecifiersOpt // Case DeclarationSpecifiersFunc 579 // | StorageClassSpecifier DeclarationSpecifiersOpt // Case DeclarationSpecifiersStorage 580 // | TypeQualifier DeclarationSpecifiersOpt // Case DeclarationSpecifiersQualifier 581 // | TypeSpecifier DeclarationSpecifiersOpt // Case DeclarationSpecifiersSpecifier 582 // | AlignmentSpecifier DeclarationSpecifiersOpt // Case DeclarationSpecifiersAlignment 583 type DeclarationSpecifiers struct { 584 AlignmentSpecifier *AlignmentSpecifier 585 Case DeclarationSpecifiersCase 586 DeclarationSpecifiersOpt *DeclarationSpecifiersOpt 587 FunctionSpecifier *FunctionSpecifier 588 StorageClassSpecifier *StorageClassSpecifier 589 TypeQualifier *TypeQualifier 590 TypeSpecifier *TypeSpecifier 591 } 592 593 func (n *DeclarationSpecifiers) fragment() interface{} { return n } 594 595 // String implements fmt.Stringer. 596 func (n *DeclarationSpecifiers) String() string { 597 return PrettyString(n) 598 } 599 600 // Pos reports the position of the first component of n or zero if it's empty. 601 func (n *DeclarationSpecifiers) Pos() token.Pos { 602 if n == nil { 603 return 0 604 } 605 606 switch n.Case { 607 case 4: 608 return n.AlignmentSpecifier.Pos() 609 case 0: 610 return n.FunctionSpecifier.Pos() 611 case 1: 612 return n.StorageClassSpecifier.Pos() 613 case 2: 614 return n.TypeQualifier.Pos() 615 case 3: 616 return n.TypeSpecifier.Pos() 617 default: 618 panic("internal error") 619 } 620 } 621 622 // DeclarationSpecifiersOpt represents data reduced by productions: 623 // 624 // DeclarationSpecifiersOpt: 625 // /* empty */ // Case 0 626 // | DeclarationSpecifiers // Case 1 627 type DeclarationSpecifiersOpt struct { 628 DeclarationSpecifiers *DeclarationSpecifiers 629 } 630 631 func (n *DeclarationSpecifiersOpt) fragment() interface{} { return n } 632 633 // String implements fmt.Stringer. 634 func (n *DeclarationSpecifiersOpt) String() string { 635 return PrettyString(n) 636 } 637 638 // Pos reports the position of the first component of n or zero if it's empty. 639 func (n *DeclarationSpecifiersOpt) Pos() token.Pos { 640 if n == nil { 641 return 0 642 } 643 644 return n.DeclarationSpecifiers.Pos() 645 } 646 647 // Declarator represents data reduced by production: 648 // 649 // Declarator: 650 // PointerOpt DirectDeclarator // Case 0 651 type Declarator struct { 652 AssignedTo int // Declarator appears at the left side of assignment. 653 Attributes [][]xc.Token 654 Bits int // StructDeclarator: bit width when a bit field. 655 DeclarationSpecifier *DeclarationSpecifier // Nil for embedded declarators. 656 Definition *Declarator // Declaration -> definition. 657 Field int // Declaration order# if struct field declarator. 658 FunctionDefinition *FunctionDefinition // When the declarator defines a function. 659 Initializer *Initializer // Only when part of an InitDeclarator. 660 Linkage Linkage // Linkage of the declared name, [0]6.2.2. 661 Parameters []*Declarator // Of the function declarator. 662 Referenced int 663 Scope *Scope // Declaration scope. 664 ScopeNum int // Sequential scope number within function body. 665 StorageDuration StorageDuration // Storage duration of the declared name, [0]6.2.4. 666 Type Type // Declared type. 667 TypeQualifiers []*TypeQualifier // From the PointerOpt production, if any. 668 unnamed int 669 vars []*Declarator // Function declarator only. 670 AddressTaken bool 671 Alloca bool // Function declarator: Body calls __builtin_alloca 672 Embedded bool // [0]6.7.5-3: Not a full declarator. 673 IsField bool 674 IsFunctionParameter bool 675 IsBuiltin bool 676 DirectDeclarator *DirectDeclarator 677 PointerOpt *PointerOpt 678 } 679 680 func (n *Declarator) fragment() interface{} { return n } 681 682 // String implements fmt.Stringer. 683 func (n *Declarator) String() string { 684 return PrettyString(n) 685 } 686 687 // Pos reports the position of the first component of n or zero if it's empty. 688 func (n *Declarator) Pos() token.Pos { 689 if n == nil { 690 return 0 691 } 692 693 if p := n.PointerOpt.Pos(); p != 0 { 694 return p 695 } 696 697 return n.DirectDeclarator.Pos() 698 } 699 700 // DeclaratorOpt represents data reduced by productions: 701 // 702 // DeclaratorOpt: 703 // /* empty */ // Case 0 704 // | Declarator // Case 1 705 type DeclaratorOpt struct { 706 Declarator *Declarator 707 } 708 709 func (n *DeclaratorOpt) fragment() interface{} { return n } 710 711 // String implements fmt.Stringer. 712 func (n *DeclaratorOpt) String() string { 713 return PrettyString(n) 714 } 715 716 // Pos reports the position of the first component of n or zero if it's empty. 717 func (n *DeclaratorOpt) Pos() token.Pos { 718 if n == nil { 719 return 0 720 } 721 722 return n.Declarator.Pos() 723 } 724 725 // Designation represents data reduced by production: 726 // 727 // Designation: 728 // DesignatorList '=' // Case 0 729 type Designation struct { 730 List []int64 731 Type Type 732 DesignatorList *DesignatorList 733 Token xc.Token 734 } 735 736 func (n *Designation) fragment() interface{} { return n } 737 738 // String implements fmt.Stringer. 739 func (n *Designation) String() string { 740 return PrettyString(n) 741 } 742 743 // Pos reports the position of the first component of n or zero if it's empty. 744 func (n *Designation) Pos() token.Pos { 745 if n == nil { 746 return 0 747 } 748 749 return n.DesignatorList.Pos() 750 } 751 752 // DesignatorCase represents case numbers of production Designator 753 type DesignatorCase int 754 755 // Values of type DesignatorCase 756 const ( 757 DesignatorField DesignatorCase = iota 758 DesignatorIndex 759 ) 760 761 // String implements fmt.Stringer 762 func (n DesignatorCase) String() string { 763 switch n { 764 case DesignatorField: 765 return "DesignatorField" 766 case DesignatorIndex: 767 return "DesignatorIndex" 768 default: 769 return fmt.Sprintf("DesignatorCase(%v)", int(n)) 770 } 771 } 772 773 // Designator represents data reduced by productions: 774 // 775 // Designator: 776 // '.' IDENTIFIER // Case DesignatorField 777 // | '[' ConstExpr ']' // Case DesignatorIndex 778 type Designator struct { 779 Case DesignatorCase 780 ConstExpr *ConstExpr 781 Token xc.Token 782 Token2 xc.Token 783 } 784 785 func (n *Designator) fragment() interface{} { return n } 786 787 // String implements fmt.Stringer. 788 func (n *Designator) String() string { 789 return PrettyString(n) 790 } 791 792 // Pos reports the position of the first component of n or zero if it's empty. 793 func (n *Designator) Pos() token.Pos { 794 if n == nil { 795 return 0 796 } 797 798 return n.Token.Pos() 799 } 800 801 // DesignatorList represents data reduced by productions: 802 // 803 // DesignatorList: 804 // Designator // Case 0 805 // | DesignatorList Designator // Case 1 806 type DesignatorList struct { 807 Case int 808 Designator *Designator 809 DesignatorList *DesignatorList 810 } 811 812 func (n *DesignatorList) reverse() *DesignatorList { 813 if n == nil { 814 return nil 815 } 816 817 na := n 818 nb := na.DesignatorList 819 for nb != nil { 820 nc := nb.DesignatorList 821 nb.DesignatorList = na 822 na = nb 823 nb = nc 824 } 825 n.DesignatorList = nil 826 return na 827 } 828 829 func (n *DesignatorList) fragment() interface{} { return n.reverse() } 830 831 // String implements fmt.Stringer. 832 func (n *DesignatorList) String() string { 833 return PrettyString(n) 834 } 835 836 // Pos reports the position of the first component of n or zero if it's empty. 837 func (n *DesignatorList) Pos() token.Pos { 838 if n == nil { 839 return 0 840 } 841 842 switch n.Case { 843 case 0: 844 return n.Designator.Pos() 845 case 1: 846 return n.DesignatorList.Pos() 847 default: 848 panic("internal error") 849 } 850 } 851 852 // DirectAbstractDeclaratorCase represents case numbers of production DirectAbstractDeclarator 853 type DirectAbstractDeclaratorCase int 854 855 // Values of type DirectAbstractDeclaratorCase 856 const ( 857 DirectAbstractDeclaratorAbstract DirectAbstractDeclaratorCase = iota 858 DirectAbstractDeclaratorParamList 859 DirectAbstractDeclaratorDFn 860 DirectAbstractDeclaratorDArrSize 861 DirectAbstractDeclaratorDArrVL 862 DirectAbstractDeclaratorDArr 863 DirectAbstractDeclaratorDArrSize2 864 DirectAbstractDeclaratorDArr2 865 ) 866 867 // String implements fmt.Stringer 868 func (n DirectAbstractDeclaratorCase) String() string { 869 switch n { 870 case DirectAbstractDeclaratorAbstract: 871 return "DirectAbstractDeclaratorAbstract" 872 case DirectAbstractDeclaratorParamList: 873 return "DirectAbstractDeclaratorParamList" 874 case DirectAbstractDeclaratorDFn: 875 return "DirectAbstractDeclaratorDFn" 876 case DirectAbstractDeclaratorDArrSize: 877 return "DirectAbstractDeclaratorDArrSize" 878 case DirectAbstractDeclaratorDArrVL: 879 return "DirectAbstractDeclaratorDArrVL" 880 case DirectAbstractDeclaratorDArr: 881 return "DirectAbstractDeclaratorDArr" 882 case DirectAbstractDeclaratorDArrSize2: 883 return "DirectAbstractDeclaratorDArrSize2" 884 case DirectAbstractDeclaratorDArr2: 885 return "DirectAbstractDeclaratorDArr2" 886 default: 887 return fmt.Sprintf("DirectAbstractDeclaratorCase(%v)", int(n)) 888 } 889 } 890 891 // DirectAbstractDeclarator represents data reduced by productions: 892 // 893 // DirectAbstractDeclarator: 894 // '(' AbstractDeclarator ')' // Case DirectAbstractDeclaratorAbstract 895 // | '(' ParameterTypeListOpt ')' // Case DirectAbstractDeclaratorParamList 896 // | DirectAbstractDeclarator '(' ParameterTypeListOpt ')' // Case DirectAbstractDeclaratorDFn 897 // | DirectAbstractDeclaratorOpt '[' "static" TypeQualifierListOpt Expr ']' // Case DirectAbstractDeclaratorDArrSize 898 // | DirectAbstractDeclaratorOpt '[' '*' ']' // Case DirectAbstractDeclaratorDArrVL 899 // | DirectAbstractDeclaratorOpt '[' ExprOpt ']' // Case DirectAbstractDeclaratorDArr 900 // | DirectAbstractDeclaratorOpt '[' TypeQualifierList "static" Expr ']' // Case DirectAbstractDeclaratorDArrSize2 901 // | DirectAbstractDeclaratorOpt '[' TypeQualifierList ExprOpt ']' // Case DirectAbstractDeclaratorDArr2 902 type DirectAbstractDeclarator struct { 903 AbstractDeclarator *AbstractDeclarator 904 Case DirectAbstractDeclaratorCase 905 DirectAbstractDeclarator *DirectAbstractDeclarator 906 DirectAbstractDeclaratorOpt *DirectAbstractDeclaratorOpt 907 Expr *Expr 908 ExprOpt *ExprOpt 909 ParameterTypeListOpt *ParameterTypeListOpt 910 Token xc.Token 911 Token2 xc.Token 912 Token3 xc.Token 913 TypeQualifierList *TypeQualifierList 914 TypeQualifierListOpt *TypeQualifierListOpt 915 } 916 917 func (n *DirectAbstractDeclarator) fragment() interface{} { return n } 918 919 // String implements fmt.Stringer. 920 func (n *DirectAbstractDeclarator) String() string { 921 return PrettyString(n) 922 } 923 924 // Pos reports the position of the first component of n or zero if it's empty. 925 func (n *DirectAbstractDeclarator) Pos() token.Pos { 926 if n == nil { 927 return 0 928 } 929 930 switch n.Case { 931 case 2: 932 return n.DirectAbstractDeclarator.Pos() 933 case 3, 4, 5, 6, 7: 934 if p := n.DirectAbstractDeclaratorOpt.Pos(); p != 0 { 935 return p 936 } 937 938 return n.Token.Pos() 939 case 0, 1: 940 return n.Token.Pos() 941 default: 942 panic("internal error") 943 } 944 } 945 946 // DirectAbstractDeclaratorOpt represents data reduced by productions: 947 // 948 // DirectAbstractDeclaratorOpt: 949 // /* empty */ // Case 0 950 // | DirectAbstractDeclarator // Case 1 951 type DirectAbstractDeclaratorOpt struct { 952 DirectAbstractDeclarator *DirectAbstractDeclarator 953 } 954 955 func (n *DirectAbstractDeclaratorOpt) fragment() interface{} { return n } 956 957 // String implements fmt.Stringer. 958 func (n *DirectAbstractDeclaratorOpt) String() string { 959 return PrettyString(n) 960 } 961 962 // Pos reports the position of the first component of n or zero if it's empty. 963 func (n *DirectAbstractDeclaratorOpt) Pos() token.Pos { 964 if n == nil { 965 return 0 966 } 967 968 return n.DirectAbstractDeclarator.Pos() 969 } 970 971 // DirectDeclaratorCase represents case numbers of production DirectDeclarator 972 type DirectDeclaratorCase int 973 974 // Values of type DirectDeclaratorCase 975 const ( 976 DirectDeclaratorParen DirectDeclaratorCase = iota 977 DirectDeclaratorParameters 978 DirectDeclaratorArraySize 979 DirectDeclaratorArraySize2 980 DirectDeclaratorArrayVar 981 DirectDeclaratorArray 982 DirectDeclaratorIdent 983 ) 984 985 // String implements fmt.Stringer 986 func (n DirectDeclaratorCase) String() string { 987 switch n { 988 case DirectDeclaratorParen: 989 return "DirectDeclaratorParen" 990 case DirectDeclaratorParameters: 991 return "DirectDeclaratorParameters" 992 case DirectDeclaratorArraySize: 993 return "DirectDeclaratorArraySize" 994 case DirectDeclaratorArraySize2: 995 return "DirectDeclaratorArraySize2" 996 case DirectDeclaratorArrayVar: 997 return "DirectDeclaratorArrayVar" 998 case DirectDeclaratorArray: 999 return "DirectDeclaratorArray" 1000 case DirectDeclaratorIdent: 1001 return "DirectDeclaratorIdent" 1002 default: 1003 return fmt.Sprintf("DirectDeclaratorCase(%v)", int(n)) 1004 } 1005 } 1006 1007 // DirectDeclarator represents data reduced by productions: 1008 // 1009 // DirectDeclarator: 1010 // '(' Declarator ')' // Case DirectDeclaratorParen 1011 // | DirectDeclarator '(' Parameters ')' // Case DirectDeclaratorParameters 1012 // | DirectDeclarator '[' "static" TypeQualifierListOpt Expr ']' // Case DirectDeclaratorArraySize 1013 // | DirectDeclarator '[' TypeQualifierList "static" Expr ']' // Case DirectDeclaratorArraySize2 1014 // | DirectDeclarator '[' TypeQualifierListOpt '*' ']' // Case DirectDeclaratorArrayVar 1015 // | DirectDeclarator '[' TypeQualifierListOpt ExprOpt ']' // Case DirectDeclaratorArray 1016 // | IDENTIFIER // Case DirectDeclaratorIdent 1017 type DirectDeclarator struct { 1018 paramScope *Scope 1019 Case DirectDeclaratorCase 1020 Declarator *Declarator 1021 DirectDeclarator *DirectDeclarator 1022 Expr *Expr 1023 ExprOpt *ExprOpt 1024 Parameters *Parameters 1025 Token xc.Token 1026 Token2 xc.Token 1027 Token3 xc.Token 1028 TypeQualifierList *TypeQualifierList 1029 TypeQualifierListOpt *TypeQualifierListOpt 1030 } 1031 1032 func (n *DirectDeclarator) fragment() interface{} { return n } 1033 1034 // String implements fmt.Stringer. 1035 func (n *DirectDeclarator) String() string { 1036 return PrettyString(n) 1037 } 1038 1039 // Pos reports the position of the first component of n or zero if it's empty. 1040 func (n *DirectDeclarator) Pos() token.Pos { 1041 if n == nil { 1042 return 0 1043 } 1044 1045 switch n.Case { 1046 case 1, 2, 3, 4, 5: 1047 return n.DirectDeclarator.Pos() 1048 case 0, 6: 1049 return n.Token.Pos() 1050 default: 1051 panic("internal error") 1052 } 1053 } 1054 1055 // EnumSpecifierCase represents case numbers of production EnumSpecifier 1056 type EnumSpecifierCase int 1057 1058 // Values of type EnumSpecifierCase 1059 const ( 1060 EnumSpecifierTag EnumSpecifierCase = iota 1061 EnumSpecifierDefine 1062 ) 1063 1064 // String implements fmt.Stringer 1065 func (n EnumSpecifierCase) String() string { 1066 switch n { 1067 case EnumSpecifierTag: 1068 return "EnumSpecifierTag" 1069 case EnumSpecifierDefine: 1070 return "EnumSpecifierDefine" 1071 default: 1072 return fmt.Sprintf("EnumSpecifierCase(%v)", int(n)) 1073 } 1074 } 1075 1076 // EnumSpecifier represents data reduced by productions: 1077 // 1078 // EnumSpecifier: 1079 // "enum" IDENTIFIER // Case EnumSpecifierTag 1080 // | "enum" IdentifierOpt '{' EnumeratorList CommaOpt '}' // Case EnumSpecifierDefine 1081 type EnumSpecifier struct { 1082 Tag int 1083 scope *Scope // Where to declare enumeration constants. 1084 typ Type 1085 Case EnumSpecifierCase 1086 CommaOpt *CommaOpt 1087 EnumeratorList *EnumeratorList 1088 IdentifierOpt *IdentifierOpt 1089 Token xc.Token 1090 Token2 xc.Token 1091 Token3 xc.Token 1092 } 1093 1094 func (n *EnumSpecifier) fragment() interface{} { return n } 1095 1096 // String implements fmt.Stringer. 1097 func (n *EnumSpecifier) String() string { 1098 return PrettyString(n) 1099 } 1100 1101 // Pos reports the position of the first component of n or zero if it's empty. 1102 func (n *EnumSpecifier) Pos() token.Pos { 1103 if n == nil { 1104 return 0 1105 } 1106 1107 return n.Token.Pos() 1108 } 1109 1110 // EnumerationConstant represents data reduced by production: 1111 // 1112 // EnumerationConstant: 1113 // IDENTIFIER // Case 0 1114 type EnumerationConstant struct { 1115 Operand Operand 1116 Token xc.Token 1117 } 1118 1119 func (n *EnumerationConstant) fragment() interface{} { return n } 1120 1121 // String implements fmt.Stringer. 1122 func (n *EnumerationConstant) String() string { 1123 return PrettyString(n) 1124 } 1125 1126 // Pos reports the position of the first component of n or zero if it's empty. 1127 func (n *EnumerationConstant) Pos() token.Pos { 1128 if n == nil { 1129 return 0 1130 } 1131 1132 return n.Token.Pos() 1133 } 1134 1135 // EnumeratorCase represents case numbers of production Enumerator 1136 type EnumeratorCase int 1137 1138 // Values of type EnumeratorCase 1139 const ( 1140 EnumeratorBase EnumeratorCase = iota 1141 EnumeratorInit 1142 ) 1143 1144 // String implements fmt.Stringer 1145 func (n EnumeratorCase) String() string { 1146 switch n { 1147 case EnumeratorBase: 1148 return "EnumeratorBase" 1149 case EnumeratorInit: 1150 return "EnumeratorInit" 1151 default: 1152 return fmt.Sprintf("EnumeratorCase(%v)", int(n)) 1153 } 1154 } 1155 1156 // Enumerator represents data reduced by productions: 1157 // 1158 // Enumerator: 1159 // EnumerationConstant // Case EnumeratorBase 1160 // | EnumerationConstant '=' ConstExpr // Case EnumeratorInit 1161 type Enumerator struct { 1162 Case EnumeratorCase 1163 ConstExpr *ConstExpr 1164 EnumerationConstant *EnumerationConstant 1165 Token xc.Token 1166 } 1167 1168 func (n *Enumerator) fragment() interface{} { return n } 1169 1170 // String implements fmt.Stringer. 1171 func (n *Enumerator) String() string { 1172 return PrettyString(n) 1173 } 1174 1175 // Pos reports the position of the first component of n or zero if it's empty. 1176 func (n *Enumerator) Pos() token.Pos { 1177 if n == nil { 1178 return 0 1179 } 1180 1181 return n.EnumerationConstant.Pos() 1182 } 1183 1184 // EnumeratorList represents data reduced by productions: 1185 // 1186 // EnumeratorList: 1187 // Enumerator // Case 0 1188 // | EnumeratorList ',' Enumerator // Case 1 1189 type EnumeratorList struct { 1190 Case int 1191 Enumerator *Enumerator 1192 EnumeratorList *EnumeratorList 1193 Token xc.Token 1194 } 1195 1196 func (n *EnumeratorList) reverse() *EnumeratorList { 1197 if n == nil { 1198 return nil 1199 } 1200 1201 na := n 1202 nb := na.EnumeratorList 1203 for nb != nil { 1204 nc := nb.EnumeratorList 1205 nb.EnumeratorList = na 1206 na = nb 1207 nb = nc 1208 } 1209 n.EnumeratorList = nil 1210 return na 1211 } 1212 1213 func (n *EnumeratorList) fragment() interface{} { return n.reverse() } 1214 1215 // String implements fmt.Stringer. 1216 func (n *EnumeratorList) String() string { 1217 return PrettyString(n) 1218 } 1219 1220 // Pos reports the position of the first component of n or zero if it's empty. 1221 func (n *EnumeratorList) Pos() token.Pos { 1222 if n == nil { 1223 return 0 1224 } 1225 1226 switch n.Case { 1227 case 0: 1228 return n.Enumerator.Pos() 1229 case 1: 1230 return n.EnumeratorList.Pos() 1231 default: 1232 panic("internal error") 1233 } 1234 } 1235 1236 // ExprCase represents case numbers of production Expr 1237 type ExprCase int 1238 1239 // Values of type ExprCase 1240 const ( 1241 ExprPreInc ExprCase = iota 1242 ExprPreDec 1243 ExprAlignofType 1244 ExprAlignofExpr 1245 ExprSizeofType 1246 ExprSizeofExpr 1247 ExprNot 1248 ExprAddrof 1249 ExprStatement 1250 ExprPExprList 1251 ExprCompLit 1252 ExprCast 1253 ExprDeref 1254 ExprUnaryPlus 1255 ExprUnaryMinus 1256 ExprCpl 1257 ExprChar 1258 ExprNe 1259 ExprModAssign 1260 ExprLAnd 1261 ExprAndAssign 1262 ExprMulAssign 1263 ExprPostInc 1264 ExprAddAssign 1265 ExprPostDec 1266 ExprSubAssign 1267 ExprPSelect 1268 ExprDivAssign 1269 ExprLsh 1270 ExprLshAssign 1271 ExprLe 1272 ExprEq 1273 ExprGe 1274 ExprRsh 1275 ExprRshAssign 1276 ExprXorAssign 1277 ExprOrAssign 1278 ExprLOr 1279 ExprMod 1280 ExprAnd 1281 ExprCall 1282 ExprMul 1283 ExprAdd 1284 ExprSub 1285 ExprSelect 1286 ExprDiv 1287 ExprLt 1288 ExprAssign 1289 ExprGt 1290 ExprCond 1291 ExprIndex 1292 ExprXor 1293 ExprOr 1294 ExprFloat 1295 ExprIdent 1296 ExprInt 1297 ExprLChar 1298 ExprLString 1299 ExprString 1300 ) 1301 1302 // String implements fmt.Stringer 1303 func (n ExprCase) String() string { 1304 switch n { 1305 case ExprPreInc: 1306 return "ExprPreInc" 1307 case ExprPreDec: 1308 return "ExprPreDec" 1309 case ExprAlignofType: 1310 return "ExprAlignofType" 1311 case ExprAlignofExpr: 1312 return "ExprAlignofExpr" 1313 case ExprSizeofType: 1314 return "ExprSizeofType" 1315 case ExprSizeofExpr: 1316 return "ExprSizeofExpr" 1317 case ExprNot: 1318 return "ExprNot" 1319 case ExprAddrof: 1320 return "ExprAddrof" 1321 case ExprStatement: 1322 return "ExprStatement" 1323 case ExprPExprList: 1324 return "ExprPExprList" 1325 case ExprCompLit: 1326 return "ExprCompLit" 1327 case ExprCast: 1328 return "ExprCast" 1329 case ExprDeref: 1330 return "ExprDeref" 1331 case ExprUnaryPlus: 1332 return "ExprUnaryPlus" 1333 case ExprUnaryMinus: 1334 return "ExprUnaryMinus" 1335 case ExprCpl: 1336 return "ExprCpl" 1337 case ExprChar: 1338 return "ExprChar" 1339 case ExprNe: 1340 return "ExprNe" 1341 case ExprModAssign: 1342 return "ExprModAssign" 1343 case ExprLAnd: 1344 return "ExprLAnd" 1345 case ExprAndAssign: 1346 return "ExprAndAssign" 1347 case ExprMulAssign: 1348 return "ExprMulAssign" 1349 case ExprPostInc: 1350 return "ExprPostInc" 1351 case ExprAddAssign: 1352 return "ExprAddAssign" 1353 case ExprPostDec: 1354 return "ExprPostDec" 1355 case ExprSubAssign: 1356 return "ExprSubAssign" 1357 case ExprPSelect: 1358 return "ExprPSelect" 1359 case ExprDivAssign: 1360 return "ExprDivAssign" 1361 case ExprLsh: 1362 return "ExprLsh" 1363 case ExprLshAssign: 1364 return "ExprLshAssign" 1365 case ExprLe: 1366 return "ExprLe" 1367 case ExprEq: 1368 return "ExprEq" 1369 case ExprGe: 1370 return "ExprGe" 1371 case ExprRsh: 1372 return "ExprRsh" 1373 case ExprRshAssign: 1374 return "ExprRshAssign" 1375 case ExprXorAssign: 1376 return "ExprXorAssign" 1377 case ExprOrAssign: 1378 return "ExprOrAssign" 1379 case ExprLOr: 1380 return "ExprLOr" 1381 case ExprMod: 1382 return "ExprMod" 1383 case ExprAnd: 1384 return "ExprAnd" 1385 case ExprCall: 1386 return "ExprCall" 1387 case ExprMul: 1388 return "ExprMul" 1389 case ExprAdd: 1390 return "ExprAdd" 1391 case ExprSub: 1392 return "ExprSub" 1393 case ExprSelect: 1394 return "ExprSelect" 1395 case ExprDiv: 1396 return "ExprDiv" 1397 case ExprLt: 1398 return "ExprLt" 1399 case ExprAssign: 1400 return "ExprAssign" 1401 case ExprGt: 1402 return "ExprGt" 1403 case ExprCond: 1404 return "ExprCond" 1405 case ExprIndex: 1406 return "ExprIndex" 1407 case ExprXor: 1408 return "ExprXor" 1409 case ExprOr: 1410 return "ExprOr" 1411 case ExprFloat: 1412 return "ExprFloat" 1413 case ExprIdent: 1414 return "ExprIdent" 1415 case ExprInt: 1416 return "ExprInt" 1417 case ExprLChar: 1418 return "ExprLChar" 1419 case ExprLString: 1420 return "ExprLString" 1421 case ExprString: 1422 return "ExprString" 1423 default: 1424 return fmt.Sprintf("ExprCase(%v)", int(n)) 1425 } 1426 } 1427 1428 // Expr represents data reduced by productions: 1429 // 1430 // Expr: 1431 // "++" Expr // Case ExprPreInc 1432 // | "--" Expr // Case ExprPreDec 1433 // | "_Alignof" '(' TypeName ')' // Case ExprAlignofType 1434 // | "_Alignof" Expr // Case ExprAlignofExpr 1435 // | "sizeof" '(' TypeName ')' // Case ExprSizeofType 1436 // | "sizeof" Expr // Case ExprSizeofExpr 1437 // | '!' Expr // Case ExprNot 1438 // | '&' Expr // Case ExprAddrof 1439 // | '(' CompoundStmt ')' // Case ExprStatement 1440 // | '(' ExprList ')' // Case ExprPExprList 1441 // | '(' TypeName ')' '{' InitializerList CommaOpt '}' // Case ExprCompLit 1442 // | '(' TypeName ')' Expr // Case ExprCast 1443 // | '*' Expr // Case ExprDeref 1444 // | '+' Expr // Case ExprUnaryPlus 1445 // | '-' Expr // Case ExprUnaryMinus 1446 // | '~' Expr // Case ExprCpl 1447 // | CHARCONST // Case ExprChar 1448 // | Expr "!=" Expr // Case ExprNe 1449 // | Expr "%=" Expr // Case ExprModAssign 1450 // | Expr "&&" Expr // Case ExprLAnd 1451 // | Expr "&=" Expr // Case ExprAndAssign 1452 // | Expr "*=" Expr // Case ExprMulAssign 1453 // | Expr "++" // Case ExprPostInc 1454 // | Expr "+=" Expr // Case ExprAddAssign 1455 // | Expr "--" // Case ExprPostDec 1456 // | Expr "-=" Expr // Case ExprSubAssign 1457 // | Expr "->" IDENTIFIER // Case ExprPSelect 1458 // | Expr "/=" Expr // Case ExprDivAssign 1459 // | Expr "<<" Expr // Case ExprLsh 1460 // | Expr "<<=" Expr // Case ExprLshAssign 1461 // | Expr "<=" Expr // Case ExprLe 1462 // | Expr "==" Expr // Case ExprEq 1463 // | Expr ">=" Expr // Case ExprGe 1464 // | Expr ">>" Expr // Case ExprRsh 1465 // | Expr ">>=" Expr // Case ExprRshAssign 1466 // | Expr "^=" Expr // Case ExprXorAssign 1467 // | Expr "|=" Expr // Case ExprOrAssign 1468 // | Expr "||" Expr // Case ExprLOr 1469 // | Expr '%' Expr // Case ExprMod 1470 // | Expr '&' Expr // Case ExprAnd 1471 // | Expr '(' ArgumentExprListOpt ')' // Case ExprCall 1472 // | Expr '*' Expr // Case ExprMul 1473 // | Expr '+' Expr // Case ExprAdd 1474 // | Expr '-' Expr // Case ExprSub 1475 // | Expr '.' IDENTIFIER // Case ExprSelect 1476 // | Expr '/' Expr // Case ExprDiv 1477 // | Expr '<' Expr // Case ExprLt 1478 // | Expr '=' Expr // Case ExprAssign 1479 // | Expr '>' Expr // Case ExprGt 1480 // | Expr '?' ExprList ':' Expr // Case ExprCond 1481 // | Expr '[' ExprList ']' // Case ExprIndex 1482 // | Expr '^' Expr // Case ExprXor 1483 // | Expr '|' Expr // Case ExprOr 1484 // | FLOATCONST // Case ExprFloat 1485 // | IDENTIFIER // Case ExprIdent 1486 // | INTCONST // Case ExprInt 1487 // | LONGCHARCONST // Case ExprLChar 1488 // | LONGSTRINGLITERAL // Case ExprLString 1489 // | STRINGLITERAL // Case ExprString 1490 type Expr struct { 1491 CallArgs []Operand // Promoted arguments of Call. 1492 Declarator *Declarator // Case Ident. 1493 Operand Operand 1494 Scope *Scope // Case Ident, CompLit. 1495 enum *EnumType 1496 AssignedTo bool // Expression appears at the left side of assignment. 1497 UseGotos bool 1498 ArgumentExprListOpt *ArgumentExprListOpt 1499 Case ExprCase 1500 CommaOpt *CommaOpt 1501 CompoundStmt *CompoundStmt 1502 Expr *Expr 1503 Expr2 *Expr 1504 ExprList *ExprList 1505 InitializerList *InitializerList 1506 Token xc.Token 1507 Token2 xc.Token 1508 Token3 xc.Token 1509 Token4 xc.Token 1510 TypeName *TypeName 1511 } 1512 1513 func (n *Expr) fragment() interface{} { return n } 1514 1515 // String implements fmt.Stringer. 1516 func (n *Expr) String() string { 1517 return PrettyString(n) 1518 } 1519 1520 // Pos reports the position of the first component of n or zero if it's empty. 1521 func (n *Expr) Pos() token.Pos { 1522 if n == nil { 1523 return 0 1524 } 1525 1526 switch n.Case { 1527 case 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52: 1528 return n.Expr.Pos() 1529 case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 53, 54, 55, 56, 57, 58: 1530 return n.Token.Pos() 1531 default: 1532 panic("internal error") 1533 } 1534 } 1535 1536 // ExprList represents data reduced by productions: 1537 // 1538 // ExprList: 1539 // Expr // Case 0 1540 // | ExprList ',' Expr // Case 1 1541 type ExprList struct { 1542 Operand Operand 1543 Case int 1544 Expr *Expr 1545 ExprList *ExprList 1546 Token xc.Token 1547 } 1548 1549 func (n *ExprList) reverse() *ExprList { 1550 if n == nil { 1551 return nil 1552 } 1553 1554 na := n 1555 nb := na.ExprList 1556 for nb != nil { 1557 nc := nb.ExprList 1558 nb.ExprList = na 1559 na = nb 1560 nb = nc 1561 } 1562 n.ExprList = nil 1563 return na 1564 } 1565 1566 func (n *ExprList) fragment() interface{} { return n.reverse() } 1567 1568 // String implements fmt.Stringer. 1569 func (n *ExprList) String() string { 1570 return PrettyString(n) 1571 } 1572 1573 // Pos reports the position of the first component of n or zero if it's empty. 1574 func (n *ExprList) Pos() token.Pos { 1575 if n == nil { 1576 return 0 1577 } 1578 1579 switch n.Case { 1580 case 0: 1581 return n.Expr.Pos() 1582 case 1: 1583 return n.ExprList.Pos() 1584 default: 1585 panic("internal error") 1586 } 1587 } 1588 1589 // ExprListOpt represents data reduced by productions: 1590 // 1591 // ExprListOpt: 1592 // /* empty */ // Case 0 1593 // | ExprList // Case 1 1594 type ExprListOpt struct { 1595 ExprList *ExprList 1596 } 1597 1598 func (n *ExprListOpt) fragment() interface{} { return n } 1599 1600 // String implements fmt.Stringer. 1601 func (n *ExprListOpt) String() string { 1602 return PrettyString(n) 1603 } 1604 1605 // Pos reports the position of the first component of n or zero if it's empty. 1606 func (n *ExprListOpt) Pos() token.Pos { 1607 if n == nil { 1608 return 0 1609 } 1610 1611 return n.ExprList.Pos() 1612 } 1613 1614 // ExprOpt represents data reduced by productions: 1615 // 1616 // ExprOpt: 1617 // /* empty */ // Case 0 1618 // | Expr // Case 1 1619 type ExprOpt struct { 1620 Expr *Expr 1621 } 1622 1623 func (n *ExprOpt) fragment() interface{} { return n } 1624 1625 // String implements fmt.Stringer. 1626 func (n *ExprOpt) String() string { 1627 return PrettyString(n) 1628 } 1629 1630 // Pos reports the position of the first component of n or zero if it's empty. 1631 func (n *ExprOpt) Pos() token.Pos { 1632 if n == nil { 1633 return 0 1634 } 1635 1636 return n.Expr.Pos() 1637 } 1638 1639 // ExprStmt represents data reduced by production: 1640 // 1641 // ExprStmt: 1642 // ExprListOpt statementEnd ';' // Case 0 1643 type ExprStmt struct { 1644 UseGotos bool 1645 ExprListOpt *ExprListOpt 1646 Token xc.Token 1647 statementEnd *statementEnd 1648 } 1649 1650 func (n *ExprStmt) fragment() interface{} { return n } 1651 1652 // String implements fmt.Stringer. 1653 func (n *ExprStmt) String() string { 1654 return PrettyString(n) 1655 } 1656 1657 // Pos reports the position of the first component of n or zero if it's empty. 1658 func (n *ExprStmt) Pos() token.Pos { 1659 if n == nil { 1660 return 0 1661 } 1662 1663 if p := n.ExprListOpt.Pos(); p != 0 { 1664 return p 1665 } 1666 1667 if p := n.statementEnd.Pos(); p != 0 { 1668 return p 1669 } 1670 1671 return n.Token.Pos() 1672 } 1673 1674 // ExternalDeclarationCase represents case numbers of production ExternalDeclaration 1675 type ExternalDeclarationCase int 1676 1677 // Values of type ExternalDeclarationCase 1678 const ( 1679 ExternalDeclarationDecl ExternalDeclarationCase = iota 1680 ExternalDeclarationFunc 1681 ) 1682 1683 // String implements fmt.Stringer 1684 func (n ExternalDeclarationCase) String() string { 1685 switch n { 1686 case ExternalDeclarationDecl: 1687 return "ExternalDeclarationDecl" 1688 case ExternalDeclarationFunc: 1689 return "ExternalDeclarationFunc" 1690 default: 1691 return fmt.Sprintf("ExternalDeclarationCase(%v)", int(n)) 1692 } 1693 } 1694 1695 // ExternalDeclaration represents data reduced by productions: 1696 // 1697 // ExternalDeclaration: 1698 // Declaration // Case ExternalDeclarationDecl 1699 // | FunctionDefinition // Case ExternalDeclarationFunc 1700 type ExternalDeclaration struct { 1701 Case ExternalDeclarationCase 1702 Declaration *Declaration 1703 FunctionDefinition *FunctionDefinition 1704 } 1705 1706 func (n *ExternalDeclaration) fragment() interface{} { return n } 1707 1708 // String implements fmt.Stringer. 1709 func (n *ExternalDeclaration) String() string { 1710 return PrettyString(n) 1711 } 1712 1713 // Pos reports the position of the first component of n or zero if it's empty. 1714 func (n *ExternalDeclaration) Pos() token.Pos { 1715 if n == nil { 1716 return 0 1717 } 1718 1719 switch n.Case { 1720 case 0: 1721 return n.Declaration.Pos() 1722 case 1: 1723 return n.FunctionDefinition.Pos() 1724 default: 1725 panic("internal error") 1726 } 1727 } 1728 1729 // ExternalDeclarationList represents data reduced by productions: 1730 // 1731 // ExternalDeclarationList: 1732 // ExternalDeclaration // Case 0 1733 // | ExternalDeclarationList ExternalDeclaration // Case 1 1734 type ExternalDeclarationList struct { 1735 Case int 1736 ExternalDeclaration *ExternalDeclaration 1737 ExternalDeclarationList *ExternalDeclarationList 1738 } 1739 1740 func (n *ExternalDeclarationList) reverse() *ExternalDeclarationList { 1741 if n == nil { 1742 return nil 1743 } 1744 1745 na := n 1746 nb := na.ExternalDeclarationList 1747 for nb != nil { 1748 nc := nb.ExternalDeclarationList 1749 nb.ExternalDeclarationList = na 1750 na = nb 1751 nb = nc 1752 } 1753 n.ExternalDeclarationList = nil 1754 return na 1755 } 1756 1757 func (n *ExternalDeclarationList) fragment() interface{} { return n.reverse() } 1758 1759 // String implements fmt.Stringer. 1760 func (n *ExternalDeclarationList) String() string { 1761 return PrettyString(n) 1762 } 1763 1764 // Pos reports the position of the first component of n or zero if it's empty. 1765 func (n *ExternalDeclarationList) Pos() token.Pos { 1766 if n == nil { 1767 return 0 1768 } 1769 1770 switch n.Case { 1771 case 0: 1772 return n.ExternalDeclaration.Pos() 1773 case 1: 1774 return n.ExternalDeclarationList.Pos() 1775 default: 1776 panic("internal error") 1777 } 1778 } 1779 1780 // FunctionBody represents data reduced by production: 1781 // 1782 // FunctionBody: 1783 // CompoundStmt // Case 0 1784 type FunctionBody struct { 1785 CompoundStmt *CompoundStmt 1786 } 1787 1788 func (n *FunctionBody) fragment() interface{} { return n } 1789 1790 // String implements fmt.Stringer. 1791 func (n *FunctionBody) String() string { 1792 return PrettyString(n) 1793 } 1794 1795 // Pos reports the position of the first component of n or zero if it's empty. 1796 func (n *FunctionBody) Pos() token.Pos { 1797 if n == nil { 1798 return 0 1799 } 1800 1801 return n.CompoundStmt.Pos() 1802 } 1803 1804 // FunctionDefinitionCase represents case numbers of production FunctionDefinition 1805 type FunctionDefinitionCase int 1806 1807 // Values of type FunctionDefinitionCase 1808 const ( 1809 FunctionDefinitionSpec FunctionDefinitionCase = iota 1810 FunctionDefinitionInt 1811 ) 1812 1813 // String implements fmt.Stringer 1814 func (n FunctionDefinitionCase) String() string { 1815 switch n { 1816 case FunctionDefinitionSpec: 1817 return "FunctionDefinitionSpec" 1818 case FunctionDefinitionInt: 1819 return "FunctionDefinitionInt" 1820 default: 1821 return fmt.Sprintf("FunctionDefinitionCase(%v)", int(n)) 1822 } 1823 } 1824 1825 // FunctionDefinition represents data reduced by productions: 1826 // 1827 // FunctionDefinition: 1828 // DeclarationSpecifiers Declarator DeclarationListOpt FunctionBody // Case FunctionDefinitionSpec 1829 // | Declarator DeclarationListOpt FunctionBody // Case FunctionDefinitionInt 1830 type FunctionDefinition struct { 1831 Case FunctionDefinitionCase 1832 DeclarationListOpt *DeclarationListOpt 1833 DeclarationSpecifiers *DeclarationSpecifiers 1834 Declarator *Declarator 1835 FunctionBody *FunctionBody 1836 } 1837 1838 func (n *FunctionDefinition) fragment() interface{} { return n } 1839 1840 // String implements fmt.Stringer. 1841 func (n *FunctionDefinition) String() string { 1842 return PrettyString(n) 1843 } 1844 1845 // Pos reports the position of the first component of n or zero if it's empty. 1846 func (n *FunctionDefinition) Pos() token.Pos { 1847 if n == nil { 1848 return 0 1849 } 1850 1851 switch n.Case { 1852 case 0: 1853 return n.DeclarationSpecifiers.Pos() 1854 case 1: 1855 return n.Declarator.Pos() 1856 default: 1857 panic("internal error") 1858 } 1859 } 1860 1861 // FunctionSpecifierCase represents case numbers of production FunctionSpecifier 1862 type FunctionSpecifierCase int 1863 1864 // Values of type FunctionSpecifierCase 1865 const ( 1866 FunctionSpecifierInline FunctionSpecifierCase = iota 1867 FunctionSpecifierNoreturn 1868 ) 1869 1870 // String implements fmt.Stringer 1871 func (n FunctionSpecifierCase) String() string { 1872 switch n { 1873 case FunctionSpecifierInline: 1874 return "FunctionSpecifierInline" 1875 case FunctionSpecifierNoreturn: 1876 return "FunctionSpecifierNoreturn" 1877 default: 1878 return fmt.Sprintf("FunctionSpecifierCase(%v)", int(n)) 1879 } 1880 } 1881 1882 // FunctionSpecifier represents data reduced by productions: 1883 // 1884 // FunctionSpecifier: 1885 // "inline" // Case FunctionSpecifierInline 1886 // | "_Noreturn" // Case FunctionSpecifierNoreturn 1887 type FunctionSpecifier struct { 1888 Case FunctionSpecifierCase 1889 Token xc.Token 1890 } 1891 1892 func (n *FunctionSpecifier) fragment() interface{} { return n } 1893 1894 // String implements fmt.Stringer. 1895 func (n *FunctionSpecifier) String() string { 1896 return PrettyString(n) 1897 } 1898 1899 // Pos reports the position of the first component of n or zero if it's empty. 1900 func (n *FunctionSpecifier) Pos() token.Pos { 1901 if n == nil { 1902 return 0 1903 } 1904 1905 return n.Token.Pos() 1906 } 1907 1908 // IdentifierList represents data reduced by productions: 1909 // 1910 // IdentifierList: 1911 // IDENTIFIER // Case 0 1912 // | IdentifierList ',' IDENTIFIER // Case 1 1913 type IdentifierList struct { 1914 Case int 1915 IdentifierList *IdentifierList 1916 Token xc.Token 1917 Token2 xc.Token 1918 } 1919 1920 func (n *IdentifierList) reverse() *IdentifierList { 1921 if n == nil { 1922 return nil 1923 } 1924 1925 na := n 1926 nb := na.IdentifierList 1927 for nb != nil { 1928 nc := nb.IdentifierList 1929 nb.IdentifierList = na 1930 na = nb 1931 nb = nc 1932 } 1933 n.IdentifierList = nil 1934 return na 1935 } 1936 1937 func (n *IdentifierList) fragment() interface{} { return n.reverse() } 1938 1939 // String implements fmt.Stringer. 1940 func (n *IdentifierList) String() string { 1941 return PrettyString(n) 1942 } 1943 1944 // Pos reports the position of the first component of n or zero if it's empty. 1945 func (n *IdentifierList) Pos() token.Pos { 1946 if n == nil { 1947 return 0 1948 } 1949 1950 switch n.Case { 1951 case 1: 1952 return n.IdentifierList.Pos() 1953 case 0: 1954 return n.Token.Pos() 1955 default: 1956 panic("internal error") 1957 } 1958 } 1959 1960 // IdentifierListOpt represents data reduced by productions: 1961 // 1962 // IdentifierListOpt: 1963 // /* empty */ // Case 0 1964 // | IdentifierList // Case 1 1965 type IdentifierListOpt struct { 1966 IdentifierList *IdentifierList 1967 } 1968 1969 func (n *IdentifierListOpt) fragment() interface{} { return n } 1970 1971 // String implements fmt.Stringer. 1972 func (n *IdentifierListOpt) String() string { 1973 return PrettyString(n) 1974 } 1975 1976 // Pos reports the position of the first component of n or zero if it's empty. 1977 func (n *IdentifierListOpt) Pos() token.Pos { 1978 if n == nil { 1979 return 0 1980 } 1981 1982 return n.IdentifierList.Pos() 1983 } 1984 1985 // IdentifierOpt represents data reduced by productions: 1986 // 1987 // IdentifierOpt: 1988 // /* empty */ // Case 0 1989 // | IDENTIFIER // Case 1 1990 type IdentifierOpt struct { 1991 Token xc.Token 1992 } 1993 1994 func (n *IdentifierOpt) fragment() interface{} { return n } 1995 1996 // String implements fmt.Stringer. 1997 func (n *IdentifierOpt) String() string { 1998 return PrettyString(n) 1999 } 2000 2001 // Pos reports the position of the first component of n or zero if it's empty. 2002 func (n *IdentifierOpt) Pos() token.Pos { 2003 if n == nil { 2004 return 0 2005 } 2006 2007 return n.Token.Pos() 2008 } 2009 2010 // InitDeclaratorCase represents case numbers of production InitDeclarator 2011 type InitDeclaratorCase int 2012 2013 // Values of type InitDeclaratorCase 2014 const ( 2015 InitDeclaratorBase InitDeclaratorCase = iota 2016 InitDeclaratorInit 2017 ) 2018 2019 // String implements fmt.Stringer 2020 func (n InitDeclaratorCase) String() string { 2021 switch n { 2022 case InitDeclaratorBase: 2023 return "InitDeclaratorBase" 2024 case InitDeclaratorInit: 2025 return "InitDeclaratorInit" 2026 default: 2027 return fmt.Sprintf("InitDeclaratorCase(%v)", int(n)) 2028 } 2029 } 2030 2031 // InitDeclarator represents data reduced by productions: 2032 // 2033 // InitDeclarator: 2034 // Declarator // Case InitDeclaratorBase 2035 // | Declarator '=' Initializer // Case InitDeclaratorInit 2036 type InitDeclarator struct { 2037 Case InitDeclaratorCase 2038 Declarator *Declarator 2039 Initializer *Initializer 2040 Token xc.Token 2041 } 2042 2043 func (n *InitDeclarator) fragment() interface{} { return n } 2044 2045 // String implements fmt.Stringer. 2046 func (n *InitDeclarator) String() string { 2047 return PrettyString(n) 2048 } 2049 2050 // Pos reports the position of the first component of n or zero if it's empty. 2051 func (n *InitDeclarator) Pos() token.Pos { 2052 if n == nil { 2053 return 0 2054 } 2055 2056 return n.Declarator.Pos() 2057 } 2058 2059 // InitDeclaratorList represents data reduced by productions: 2060 // 2061 // InitDeclaratorList: 2062 // InitDeclarator // Case 0 2063 // | InitDeclaratorList ',' InitDeclarator // Case 1 2064 type InitDeclaratorList struct { 2065 Case int 2066 InitDeclarator *InitDeclarator 2067 InitDeclaratorList *InitDeclaratorList 2068 Token xc.Token 2069 } 2070 2071 func (n *InitDeclaratorList) reverse() *InitDeclaratorList { 2072 if n == nil { 2073 return nil 2074 } 2075 2076 na := n 2077 nb := na.InitDeclaratorList 2078 for nb != nil { 2079 nc := nb.InitDeclaratorList 2080 nb.InitDeclaratorList = na 2081 na = nb 2082 nb = nc 2083 } 2084 n.InitDeclaratorList = nil 2085 return na 2086 } 2087 2088 func (n *InitDeclaratorList) fragment() interface{} { return n.reverse() } 2089 2090 // String implements fmt.Stringer. 2091 func (n *InitDeclaratorList) String() string { 2092 return PrettyString(n) 2093 } 2094 2095 // Pos reports the position of the first component of n or zero if it's empty. 2096 func (n *InitDeclaratorList) Pos() token.Pos { 2097 if n == nil { 2098 return 0 2099 } 2100 2101 switch n.Case { 2102 case 0: 2103 return n.InitDeclarator.Pos() 2104 case 1: 2105 return n.InitDeclaratorList.Pos() 2106 default: 2107 panic("internal error") 2108 } 2109 } 2110 2111 // InitDeclaratorListOpt represents data reduced by productions: 2112 // 2113 // InitDeclaratorListOpt: 2114 // /* empty */ // Case 0 2115 // | InitDeclaratorList // Case 1 2116 type InitDeclaratorListOpt struct { 2117 InitDeclaratorList *InitDeclaratorList 2118 } 2119 2120 func (n *InitDeclaratorListOpt) fragment() interface{} { return n } 2121 2122 // String implements fmt.Stringer. 2123 func (n *InitDeclaratorListOpt) String() string { 2124 return PrettyString(n) 2125 } 2126 2127 // Pos reports the position of the first component of n or zero if it's empty. 2128 func (n *InitDeclaratorListOpt) Pos() token.Pos { 2129 if n == nil { 2130 return 0 2131 } 2132 2133 return n.InitDeclaratorList.Pos() 2134 } 2135 2136 // InitializerCase represents case numbers of production Initializer 2137 type InitializerCase int 2138 2139 // Values of type InitializerCase 2140 const ( 2141 InitializerCompLit InitializerCase = iota 2142 InitializerExpr 2143 ) 2144 2145 // String implements fmt.Stringer 2146 func (n InitializerCase) String() string { 2147 switch n { 2148 case InitializerCompLit: 2149 return "InitializerCompLit" 2150 case InitializerExpr: 2151 return "InitializerExpr" 2152 default: 2153 return fmt.Sprintf("InitializerCase(%v)", int(n)) 2154 } 2155 } 2156 2157 // Initializer represents data reduced by productions: 2158 // 2159 // Initializer: 2160 // '{' InitializerList CommaOpt '}' // Case InitializerCompLit 2161 // | Expr // Case InitializerExpr 2162 type Initializer struct { 2163 Case InitializerCase 2164 CommaOpt *CommaOpt 2165 Expr *Expr 2166 InitializerList *InitializerList 2167 Token xc.Token 2168 Token2 xc.Token 2169 } 2170 2171 func (n *Initializer) fragment() interface{} { return n } 2172 2173 // String implements fmt.Stringer. 2174 func (n *Initializer) String() string { 2175 return PrettyString(n) 2176 } 2177 2178 // Pos reports the position of the first component of n or zero if it's empty. 2179 func (n *Initializer) Pos() token.Pos { 2180 if n == nil { 2181 return 0 2182 } 2183 2184 switch n.Case { 2185 case 1: 2186 return n.Expr.Pos() 2187 case 0: 2188 return n.Token.Pos() 2189 default: 2190 panic("internal error") 2191 } 2192 } 2193 2194 // InitializerList represents data reduced by productions: 2195 // 2196 // InitializerList: 2197 // /* empty */ // Case 0 2198 // | Initializer // Case 1 2199 // | Designation Initializer // Case 2 2200 // | InitializerList ',' Initializer // Case 3 2201 // | InitializerList ',' Designation Initializer // Case 4 2202 type InitializerList struct { 2203 Operand Operand //TODO- 2204 Len int 2205 Case int 2206 Designation *Designation 2207 Initializer *Initializer 2208 InitializerList *InitializerList 2209 Token xc.Token 2210 } 2211 2212 func (n *InitializerList) reverse() *InitializerList { 2213 if n == nil { 2214 return nil 2215 } 2216 2217 na := n 2218 nb := na.InitializerList 2219 for nb != nil { 2220 nc := nb.InitializerList 2221 nb.InitializerList = na 2222 na = nb 2223 nb = nc 2224 } 2225 n.InitializerList = nil 2226 return na 2227 } 2228 2229 func (n *InitializerList) fragment() interface{} { return n.reverse() } 2230 2231 // String implements fmt.Stringer. 2232 func (n *InitializerList) String() string { 2233 return PrettyString(n) 2234 } 2235 2236 // Pos reports the position of the first component of n or zero if it's empty. 2237 func (n *InitializerList) Pos() token.Pos { 2238 if n == nil { 2239 return 0 2240 } 2241 2242 switch n.Case { 2243 case 0: 2244 return 0 2245 case 2: 2246 return n.Designation.Pos() 2247 case 1: 2248 return n.Initializer.Pos() 2249 case 3, 4: 2250 if p := n.InitializerList.Pos(); p != 0 { 2251 return p 2252 } 2253 2254 return n.Token.Pos() 2255 default: 2256 panic("internal error") 2257 } 2258 } 2259 2260 // IterationStmtCase represents case numbers of production IterationStmt 2261 type IterationStmtCase int 2262 2263 // Values of type IterationStmtCase 2264 const ( 2265 IterationStmtDo IterationStmtCase = iota 2266 IterationStmtForDecl 2267 IterationStmtFor 2268 IterationStmtWhile 2269 ) 2270 2271 // String implements fmt.Stringer 2272 func (n IterationStmtCase) String() string { 2273 switch n { 2274 case IterationStmtDo: 2275 return "IterationStmtDo" 2276 case IterationStmtForDecl: 2277 return "IterationStmtForDecl" 2278 case IterationStmtFor: 2279 return "IterationStmtFor" 2280 case IterationStmtWhile: 2281 return "IterationStmtWhile" 2282 default: 2283 return fmt.Sprintf("IterationStmtCase(%v)", int(n)) 2284 } 2285 } 2286 2287 // IterationStmt represents data reduced by productions: 2288 // 2289 // IterationStmt: 2290 // "do" Stmt "while" '(' ExprList ')' statementEnd ';' // Case IterationStmtDo 2291 // | "for" '(' Declaration ExprListOpt ';' ExprListOpt ')' Stmt // Case IterationStmtForDecl 2292 // | "for" '(' ExprListOpt ';' ExprListOpt ';' ExprListOpt ')' Stmt // Case IterationStmtFor 2293 // | "while" '(' ExprList ')' Stmt // Case IterationStmtWhile 2294 type IterationStmt struct { 2295 UseGotos bool 2296 Case IterationStmtCase 2297 Declaration *Declaration 2298 ExprList *ExprList 2299 ExprListOpt *ExprListOpt 2300 ExprListOpt2 *ExprListOpt 2301 ExprListOpt3 *ExprListOpt 2302 Stmt *Stmt 2303 Token xc.Token 2304 Token2 xc.Token 2305 Token3 xc.Token 2306 Token4 xc.Token 2307 Token5 xc.Token 2308 statementEnd *statementEnd 2309 } 2310 2311 func (n *IterationStmt) fragment() interface{} { return n } 2312 2313 // String implements fmt.Stringer. 2314 func (n *IterationStmt) String() string { 2315 return PrettyString(n) 2316 } 2317 2318 // Pos reports the position of the first component of n or zero if it's empty. 2319 func (n *IterationStmt) Pos() token.Pos { 2320 if n == nil { 2321 return 0 2322 } 2323 2324 return n.Token.Pos() 2325 } 2326 2327 // JumpStmtCase represents case numbers of production JumpStmt 2328 type JumpStmtCase int 2329 2330 // Values of type JumpStmtCase 2331 const ( 2332 JumpStmtBreak JumpStmtCase = iota 2333 JumpStmtContinue 2334 JumpStmtGoto 2335 JumpStmtReturn 2336 ) 2337 2338 // String implements fmt.Stringer 2339 func (n JumpStmtCase) String() string { 2340 switch n { 2341 case JumpStmtBreak: 2342 return "JumpStmtBreak" 2343 case JumpStmtContinue: 2344 return "JumpStmtContinue" 2345 case JumpStmtGoto: 2346 return "JumpStmtGoto" 2347 case JumpStmtReturn: 2348 return "JumpStmtReturn" 2349 default: 2350 return fmt.Sprintf("JumpStmtCase(%v)", int(n)) 2351 } 2352 } 2353 2354 // JumpStmt represents data reduced by productions: 2355 // 2356 // JumpStmt: 2357 // "break" statementEnd ';' // Case JumpStmtBreak 2358 // | "continue" statementEnd ';' // Case JumpStmtContinue 2359 // | "goto" IDENTIFIER statementEnd ';' // Case JumpStmtGoto 2360 // | "return" ExprListOpt statementEnd ';' // Case JumpStmtReturn 2361 type JumpStmt struct { 2362 ReturnOperand Operand 2363 scope *Scope 2364 UseGotos bool 2365 Case JumpStmtCase 2366 ExprListOpt *ExprListOpt 2367 Token xc.Token 2368 Token2 xc.Token 2369 Token3 xc.Token 2370 statementEnd *statementEnd 2371 } 2372 2373 func (n *JumpStmt) fragment() interface{} { return n } 2374 2375 // String implements fmt.Stringer. 2376 func (n *JumpStmt) String() string { 2377 return PrettyString(n) 2378 } 2379 2380 // Pos reports the position of the first component of n or zero if it's empty. 2381 func (n *JumpStmt) Pos() token.Pos { 2382 if n == nil { 2383 return 0 2384 } 2385 2386 return n.Token.Pos() 2387 } 2388 2389 // LabeledStmtCase represents case numbers of production LabeledStmt 2390 type LabeledStmtCase int 2391 2392 // Values of type LabeledStmtCase 2393 const ( 2394 LabeledStmtSwitchCase LabeledStmtCase = iota 2395 LabeledStmtDefault 2396 LabeledStmtLabel 2397 LabeledStmtLabel2 2398 ) 2399 2400 // String implements fmt.Stringer 2401 func (n LabeledStmtCase) String() string { 2402 switch n { 2403 case LabeledStmtSwitchCase: 2404 return "LabeledStmtSwitchCase" 2405 case LabeledStmtDefault: 2406 return "LabeledStmtDefault" 2407 case LabeledStmtLabel: 2408 return "LabeledStmtLabel" 2409 case LabeledStmtLabel2: 2410 return "LabeledStmtLabel2" 2411 default: 2412 return fmt.Sprintf("LabeledStmtCase(%v)", int(n)) 2413 } 2414 } 2415 2416 // LabeledStmt represents data reduced by productions: 2417 // 2418 // LabeledStmt: 2419 // "case" ConstExpr ':' Stmt // Case LabeledStmtSwitchCase 2420 // | "default" ':' Stmt // Case LabeledStmtDefault 2421 // | IDENTIFIER ':' Stmt // Case LabeledStmtLabel 2422 // | TYPEDEF_NAME ':' Stmt // Case LabeledStmtLabel2 2423 type LabeledStmt struct { 2424 UseGotos bool 2425 Case LabeledStmtCase 2426 ConstExpr *ConstExpr 2427 Stmt *Stmt 2428 Token xc.Token 2429 Token2 xc.Token 2430 } 2431 2432 func (n *LabeledStmt) fragment() interface{} { return n } 2433 2434 // String implements fmt.Stringer. 2435 func (n *LabeledStmt) String() string { 2436 return PrettyString(n) 2437 } 2438 2439 // Pos reports the position of the first component of n or zero if it's empty. 2440 func (n *LabeledStmt) Pos() token.Pos { 2441 if n == nil { 2442 return 0 2443 } 2444 2445 return n.Token.Pos() 2446 } 2447 2448 // ParameterDeclarationCase represents case numbers of production ParameterDeclaration 2449 type ParameterDeclarationCase int 2450 2451 // Values of type ParameterDeclarationCase 2452 const ( 2453 ParameterDeclarationAbstract ParameterDeclarationCase = iota 2454 ParameterDeclarationDeclarator 2455 ) 2456 2457 // String implements fmt.Stringer 2458 func (n ParameterDeclarationCase) String() string { 2459 switch n { 2460 case ParameterDeclarationAbstract: 2461 return "ParameterDeclarationAbstract" 2462 case ParameterDeclarationDeclarator: 2463 return "ParameterDeclarationDeclarator" 2464 default: 2465 return fmt.Sprintf("ParameterDeclarationCase(%v)", int(n)) 2466 } 2467 } 2468 2469 // ParameterDeclaration represents data reduced by productions: 2470 // 2471 // ParameterDeclaration: 2472 // DeclarationSpecifiers AbstractDeclaratorOpt // Case ParameterDeclarationAbstract 2473 // | DeclarationSpecifiers Declarator // Case ParameterDeclarationDeclarator 2474 type ParameterDeclaration struct { 2475 AbstractDeclaratorOpt *AbstractDeclaratorOpt 2476 Case ParameterDeclarationCase 2477 DeclarationSpecifiers *DeclarationSpecifiers 2478 Declarator *Declarator 2479 } 2480 2481 func (n *ParameterDeclaration) fragment() interface{} { return n } 2482 2483 // String implements fmt.Stringer. 2484 func (n *ParameterDeclaration) String() string { 2485 return PrettyString(n) 2486 } 2487 2488 // Pos reports the position of the first component of n or zero if it's empty. 2489 func (n *ParameterDeclaration) Pos() token.Pos { 2490 if n == nil { 2491 return 0 2492 } 2493 2494 return n.DeclarationSpecifiers.Pos() 2495 } 2496 2497 // ParameterList represents data reduced by productions: 2498 // 2499 // ParameterList: 2500 // ParameterDeclaration // Case 0 2501 // | ParameterList ',' ParameterDeclaration // Case 1 2502 type ParameterList struct { 2503 Case int 2504 ParameterDeclaration *ParameterDeclaration 2505 ParameterList *ParameterList 2506 Token xc.Token 2507 } 2508 2509 func (n *ParameterList) reverse() *ParameterList { 2510 if n == nil { 2511 return nil 2512 } 2513 2514 na := n 2515 nb := na.ParameterList 2516 for nb != nil { 2517 nc := nb.ParameterList 2518 nb.ParameterList = na 2519 na = nb 2520 nb = nc 2521 } 2522 n.ParameterList = nil 2523 return na 2524 } 2525 2526 func (n *ParameterList) fragment() interface{} { return n.reverse() } 2527 2528 // String implements fmt.Stringer. 2529 func (n *ParameterList) String() string { 2530 return PrettyString(n) 2531 } 2532 2533 // Pos reports the position of the first component of n or zero if it's empty. 2534 func (n *ParameterList) Pos() token.Pos { 2535 if n == nil { 2536 return 0 2537 } 2538 2539 switch n.Case { 2540 case 0: 2541 return n.ParameterDeclaration.Pos() 2542 case 1: 2543 return n.ParameterList.Pos() 2544 default: 2545 panic("internal error") 2546 } 2547 } 2548 2549 // ParameterTypeListCase represents case numbers of production ParameterTypeList 2550 type ParameterTypeListCase int 2551 2552 // Values of type ParameterTypeListCase 2553 const ( 2554 ParameterTypeListBase ParameterTypeListCase = iota 2555 ParameterTypeListDots 2556 ) 2557 2558 // String implements fmt.Stringer 2559 func (n ParameterTypeListCase) String() string { 2560 switch n { 2561 case ParameterTypeListBase: 2562 return "ParameterTypeListBase" 2563 case ParameterTypeListDots: 2564 return "ParameterTypeListDots" 2565 default: 2566 return fmt.Sprintf("ParameterTypeListCase(%v)", int(n)) 2567 } 2568 } 2569 2570 // ParameterTypeList represents data reduced by productions: 2571 // 2572 // ParameterTypeList: 2573 // ParameterList // Case ParameterTypeListBase 2574 // | ParameterList ',' "..." // Case ParameterTypeListDots 2575 type ParameterTypeList struct { 2576 Case ParameterTypeListCase 2577 ParameterList *ParameterList 2578 Token xc.Token 2579 Token2 xc.Token 2580 } 2581 2582 func (n *ParameterTypeList) fragment() interface{} { return n } 2583 2584 // String implements fmt.Stringer. 2585 func (n *ParameterTypeList) String() string { 2586 return PrettyString(n) 2587 } 2588 2589 // Pos reports the position of the first component of n or zero if it's empty. 2590 func (n *ParameterTypeList) Pos() token.Pos { 2591 if n == nil { 2592 return 0 2593 } 2594 2595 return n.ParameterList.Pos() 2596 } 2597 2598 // ParameterTypeListOpt represents data reduced by productions: 2599 // 2600 // ParameterTypeListOpt: 2601 // /* empty */ // Case 0 2602 // | ParameterTypeList // Case 1 2603 type ParameterTypeListOpt struct { 2604 ParameterTypeList *ParameterTypeList 2605 } 2606 2607 func (n *ParameterTypeListOpt) fragment() interface{} { return n } 2608 2609 // String implements fmt.Stringer. 2610 func (n *ParameterTypeListOpt) String() string { 2611 return PrettyString(n) 2612 } 2613 2614 // Pos reports the position of the first component of n or zero if it's empty. 2615 func (n *ParameterTypeListOpt) Pos() token.Pos { 2616 if n == nil { 2617 return 0 2618 } 2619 2620 return n.ParameterTypeList.Pos() 2621 } 2622 2623 // ParametersCase represents case numbers of production Parameters 2624 type ParametersCase int 2625 2626 // Values of type ParametersCase 2627 const ( 2628 ParametersIdentList ParametersCase = iota 2629 ParametersParamTypes 2630 ) 2631 2632 // String implements fmt.Stringer 2633 func (n ParametersCase) String() string { 2634 switch n { 2635 case ParametersIdentList: 2636 return "ParametersIdentList" 2637 case ParametersParamTypes: 2638 return "ParametersParamTypes" 2639 default: 2640 return fmt.Sprintf("ParametersCase(%v)", int(n)) 2641 } 2642 } 2643 2644 // Parameters represents data reduced by productions: 2645 // 2646 // Parameters: 2647 // IdentifierListOpt // Case ParametersIdentList 2648 // | ParameterTypeList // Case ParametersParamTypes 2649 type Parameters struct { 2650 Case ParametersCase 2651 IdentifierListOpt *IdentifierListOpt 2652 ParameterTypeList *ParameterTypeList 2653 } 2654 2655 func (n *Parameters) fragment() interface{} { return n } 2656 2657 // String implements fmt.Stringer. 2658 func (n *Parameters) String() string { 2659 return PrettyString(n) 2660 } 2661 2662 // Pos reports the position of the first component of n or zero if it's empty. 2663 func (n *Parameters) Pos() token.Pos { 2664 if n == nil { 2665 return 0 2666 } 2667 2668 switch n.Case { 2669 case 0: 2670 return n.IdentifierListOpt.Pos() 2671 case 1: 2672 return n.ParameterTypeList.Pos() 2673 default: 2674 panic("internal error") 2675 } 2676 } 2677 2678 // PointerCase represents case numbers of production Pointer 2679 type PointerCase int 2680 2681 // Values of type PointerCase 2682 const ( 2683 PointerBase PointerCase = iota 2684 PointerPtr 2685 ) 2686 2687 // String implements fmt.Stringer 2688 func (n PointerCase) String() string { 2689 switch n { 2690 case PointerBase: 2691 return "PointerBase" 2692 case PointerPtr: 2693 return "PointerPtr" 2694 default: 2695 return fmt.Sprintf("PointerCase(%v)", int(n)) 2696 } 2697 } 2698 2699 // Pointer represents data reduced by productions: 2700 // 2701 // Pointer: 2702 // '*' TypeQualifierListOpt // Case PointerBase 2703 // | '*' TypeQualifierListOpt Pointer // Case PointerPtr 2704 type Pointer struct { 2705 Case PointerCase 2706 Pointer *Pointer 2707 Token xc.Token 2708 TypeQualifierListOpt *TypeQualifierListOpt 2709 } 2710 2711 func (n *Pointer) fragment() interface{} { return n } 2712 2713 // String implements fmt.Stringer. 2714 func (n *Pointer) String() string { 2715 return PrettyString(n) 2716 } 2717 2718 // Pos reports the position of the first component of n or zero if it's empty. 2719 func (n *Pointer) Pos() token.Pos { 2720 if n == nil { 2721 return 0 2722 } 2723 2724 return n.Token.Pos() 2725 } 2726 2727 // PointerOpt represents data reduced by productions: 2728 // 2729 // PointerOpt: 2730 // /* empty */ // Case 0 2731 // | Pointer // Case 1 2732 type PointerOpt struct { 2733 Pointer *Pointer 2734 } 2735 2736 func (n *PointerOpt) fragment() interface{} { return n } 2737 2738 // String implements fmt.Stringer. 2739 func (n *PointerOpt) String() string { 2740 return PrettyString(n) 2741 } 2742 2743 // Pos reports the position of the first component of n or zero if it's empty. 2744 func (n *PointerOpt) Pos() token.Pos { 2745 if n == nil { 2746 return 0 2747 } 2748 2749 return n.Pointer.Pos() 2750 } 2751 2752 // SelectionStmtCase represents case numbers of production SelectionStmt 2753 type SelectionStmtCase int 2754 2755 // Values of type SelectionStmtCase 2756 const ( 2757 SelectionStmtIfElse SelectionStmtCase = iota 2758 SelectionStmtIf 2759 SelectionStmtSwitch 2760 ) 2761 2762 // String implements fmt.Stringer 2763 func (n SelectionStmtCase) String() string { 2764 switch n { 2765 case SelectionStmtIfElse: 2766 return "SelectionStmtIfElse" 2767 case SelectionStmtIf: 2768 return "SelectionStmtIf" 2769 case SelectionStmtSwitch: 2770 return "SelectionStmtSwitch" 2771 default: 2772 return fmt.Sprintf("SelectionStmtCase(%v)", int(n)) 2773 } 2774 } 2775 2776 // SelectionStmt represents data reduced by productions: 2777 // 2778 // SelectionStmt: 2779 // "if" '(' ExprList ')' Stmt "else" Stmt // Case SelectionStmtIfElse 2780 // | "if" '(' ExprList ')' Stmt // Case SelectionStmtIf 2781 // | "switch" '(' ExprList ')' Stmt // Case SelectionStmtSwitch 2782 type SelectionStmt struct { 2783 Cases []*LabeledStmt 2784 SwitchOp Operand // Promoted switch operand 2785 UseGotos bool 2786 Case SelectionStmtCase 2787 ExprList *ExprList 2788 Stmt *Stmt 2789 Stmt2 *Stmt 2790 Token xc.Token 2791 Token2 xc.Token 2792 Token3 xc.Token 2793 Token4 xc.Token 2794 } 2795 2796 func (n *SelectionStmt) fragment() interface{} { return n } 2797 2798 // String implements fmt.Stringer. 2799 func (n *SelectionStmt) String() string { 2800 return PrettyString(n) 2801 } 2802 2803 // Pos reports the position of the first component of n or zero if it's empty. 2804 func (n *SelectionStmt) Pos() token.Pos { 2805 if n == nil { 2806 return 0 2807 } 2808 2809 return n.Token.Pos() 2810 } 2811 2812 // SpecifierQualifierListCase represents case numbers of production SpecifierQualifierList 2813 type SpecifierQualifierListCase int 2814 2815 // Values of type SpecifierQualifierListCase 2816 const ( 2817 SpecifierQualifierListQualifier SpecifierQualifierListCase = iota 2818 SpecifierQualifierListSpecifier 2819 ) 2820 2821 // String implements fmt.Stringer 2822 func (n SpecifierQualifierListCase) String() string { 2823 switch n { 2824 case SpecifierQualifierListQualifier: 2825 return "SpecifierQualifierListQualifier" 2826 case SpecifierQualifierListSpecifier: 2827 return "SpecifierQualifierListSpecifier" 2828 default: 2829 return fmt.Sprintf("SpecifierQualifierListCase(%v)", int(n)) 2830 } 2831 } 2832 2833 // SpecifierQualifierList represents data reduced by productions: 2834 // 2835 // SpecifierQualifierList: 2836 // TypeQualifier SpecifierQualifierListOpt // Case SpecifierQualifierListQualifier 2837 // | TypeSpecifier SpecifierQualifierListOpt // Case SpecifierQualifierListSpecifier 2838 type SpecifierQualifierList struct { 2839 Case SpecifierQualifierListCase 2840 SpecifierQualifierListOpt *SpecifierQualifierListOpt 2841 TypeQualifier *TypeQualifier 2842 TypeSpecifier *TypeSpecifier 2843 } 2844 2845 func (n *SpecifierQualifierList) fragment() interface{} { return n } 2846 2847 // String implements fmt.Stringer. 2848 func (n *SpecifierQualifierList) String() string { 2849 return PrettyString(n) 2850 } 2851 2852 // Pos reports the position of the first component of n or zero if it's empty. 2853 func (n *SpecifierQualifierList) Pos() token.Pos { 2854 if n == nil { 2855 return 0 2856 } 2857 2858 switch n.Case { 2859 case 0: 2860 return n.TypeQualifier.Pos() 2861 case 1: 2862 return n.TypeSpecifier.Pos() 2863 default: 2864 panic("internal error") 2865 } 2866 } 2867 2868 // SpecifierQualifierListOpt represents data reduced by productions: 2869 // 2870 // SpecifierQualifierListOpt: 2871 // /* empty */ // Case 0 2872 // | SpecifierQualifierList // Case 1 2873 type SpecifierQualifierListOpt struct { 2874 SpecifierQualifierList *SpecifierQualifierList 2875 } 2876 2877 func (n *SpecifierQualifierListOpt) fragment() interface{} { return n } 2878 2879 // String implements fmt.Stringer. 2880 func (n *SpecifierQualifierListOpt) String() string { 2881 return PrettyString(n) 2882 } 2883 2884 // Pos reports the position of the first component of n or zero if it's empty. 2885 func (n *SpecifierQualifierListOpt) Pos() token.Pos { 2886 if n == nil { 2887 return 0 2888 } 2889 2890 return n.SpecifierQualifierList.Pos() 2891 } 2892 2893 // StmtCase represents case numbers of production Stmt 2894 type StmtCase int 2895 2896 // Values of type StmtCase 2897 const ( 2898 StmtBlock StmtCase = iota 2899 StmtExpr 2900 StmtIter 2901 StmtJump 2902 StmtLabeled 2903 StmtSelect 2904 ) 2905 2906 // String implements fmt.Stringer 2907 func (n StmtCase) String() string { 2908 switch n { 2909 case StmtBlock: 2910 return "StmtBlock" 2911 case StmtExpr: 2912 return "StmtExpr" 2913 case StmtIter: 2914 return "StmtIter" 2915 case StmtJump: 2916 return "StmtJump" 2917 case StmtLabeled: 2918 return "StmtLabeled" 2919 case StmtSelect: 2920 return "StmtSelect" 2921 default: 2922 return fmt.Sprintf("StmtCase(%v)", int(n)) 2923 } 2924 } 2925 2926 // Stmt represents data reduced by productions: 2927 // 2928 // Stmt: 2929 // CompoundStmt // Case StmtBlock 2930 // | ExprStmt // Case StmtExpr 2931 // | IterationStmt // Case StmtIter 2932 // | JumpStmt // Case StmtJump 2933 // | LabeledStmt // Case StmtLabeled 2934 // | SelectionStmt // Case StmtSelect 2935 type Stmt struct { 2936 UseGotos bool 2937 Case StmtCase 2938 CompoundStmt *CompoundStmt 2939 ExprStmt *ExprStmt 2940 IterationStmt *IterationStmt 2941 JumpStmt *JumpStmt 2942 LabeledStmt *LabeledStmt 2943 SelectionStmt *SelectionStmt 2944 } 2945 2946 func (n *Stmt) fragment() interface{} { return n } 2947 2948 // String implements fmt.Stringer. 2949 func (n *Stmt) String() string { 2950 return PrettyString(n) 2951 } 2952 2953 // Pos reports the position of the first component of n or zero if it's empty. 2954 func (n *Stmt) Pos() token.Pos { 2955 if n == nil { 2956 return 0 2957 } 2958 2959 switch n.Case { 2960 case 0: 2961 return n.CompoundStmt.Pos() 2962 case 1: 2963 return n.ExprStmt.Pos() 2964 case 2: 2965 return n.IterationStmt.Pos() 2966 case 3: 2967 return n.JumpStmt.Pos() 2968 case 4: 2969 return n.LabeledStmt.Pos() 2970 case 5: 2971 return n.SelectionStmt.Pos() 2972 default: 2973 panic("internal error") 2974 } 2975 } 2976 2977 // StorageClassSpecifierCase represents case numbers of production StorageClassSpecifier 2978 type StorageClassSpecifierCase int 2979 2980 // Values of type StorageClassSpecifierCase 2981 const ( 2982 StorageClassSpecifierAuto StorageClassSpecifierCase = iota 2983 StorageClassSpecifierExtern 2984 StorageClassSpecifierRegister 2985 StorageClassSpecifierStatic 2986 StorageClassSpecifierTypedef 2987 ) 2988 2989 // String implements fmt.Stringer 2990 func (n StorageClassSpecifierCase) String() string { 2991 switch n { 2992 case StorageClassSpecifierAuto: 2993 return "StorageClassSpecifierAuto" 2994 case StorageClassSpecifierExtern: 2995 return "StorageClassSpecifierExtern" 2996 case StorageClassSpecifierRegister: 2997 return "StorageClassSpecifierRegister" 2998 case StorageClassSpecifierStatic: 2999 return "StorageClassSpecifierStatic" 3000 case StorageClassSpecifierTypedef: 3001 return "StorageClassSpecifierTypedef" 3002 default: 3003 return fmt.Sprintf("StorageClassSpecifierCase(%v)", int(n)) 3004 } 3005 } 3006 3007 // StorageClassSpecifier represents data reduced by productions: 3008 // 3009 // StorageClassSpecifier: 3010 // "auto" // Case StorageClassSpecifierAuto 3011 // | "extern" // Case StorageClassSpecifierExtern 3012 // | "register" // Case StorageClassSpecifierRegister 3013 // | "static" // Case StorageClassSpecifierStatic 3014 // | "typedef" // Case StorageClassSpecifierTypedef 3015 type StorageClassSpecifier struct { 3016 Case StorageClassSpecifierCase 3017 Token xc.Token 3018 } 3019 3020 func (n *StorageClassSpecifier) fragment() interface{} { return n } 3021 3022 // String implements fmt.Stringer. 3023 func (n *StorageClassSpecifier) String() string { 3024 return PrettyString(n) 3025 } 3026 3027 // Pos reports the position of the first component of n or zero if it's empty. 3028 func (n *StorageClassSpecifier) Pos() token.Pos { 3029 if n == nil { 3030 return 0 3031 } 3032 3033 return n.Token.Pos() 3034 } 3035 3036 // StructDeclarationCase represents case numbers of production StructDeclaration 3037 type StructDeclarationCase int 3038 3039 // Values of type StructDeclarationCase 3040 const ( 3041 StructDeclarationBase StructDeclarationCase = iota 3042 StructDeclarationAnon 3043 ) 3044 3045 // String implements fmt.Stringer 3046 func (n StructDeclarationCase) String() string { 3047 switch n { 3048 case StructDeclarationBase: 3049 return "StructDeclarationBase" 3050 case StructDeclarationAnon: 3051 return "StructDeclarationAnon" 3052 default: 3053 return fmt.Sprintf("StructDeclarationCase(%v)", int(n)) 3054 } 3055 } 3056 3057 // StructDeclaration represents data reduced by productions: 3058 // 3059 // StructDeclaration: 3060 // SpecifierQualifierList StructDeclaratorList ';' // Case StructDeclarationBase 3061 // | SpecifierQualifierList ';' // Case StructDeclarationAnon 3062 type StructDeclaration struct { 3063 Case StructDeclarationCase 3064 SpecifierQualifierList *SpecifierQualifierList 3065 StructDeclaratorList *StructDeclaratorList 3066 Token xc.Token 3067 } 3068 3069 func (n *StructDeclaration) fragment() interface{} { return n } 3070 3071 // String implements fmt.Stringer. 3072 func (n *StructDeclaration) String() string { 3073 return PrettyString(n) 3074 } 3075 3076 // Pos reports the position of the first component of n or zero if it's empty. 3077 func (n *StructDeclaration) Pos() token.Pos { 3078 if n == nil { 3079 return 0 3080 } 3081 3082 return n.SpecifierQualifierList.Pos() 3083 } 3084 3085 // StructDeclarationList represents data reduced by productions: 3086 // 3087 // StructDeclarationList: 3088 // StructDeclaration // Case 0 3089 // | StructDeclarationList StructDeclaration // Case 1 3090 type StructDeclarationList struct { 3091 Case int 3092 StructDeclaration *StructDeclaration 3093 StructDeclarationList *StructDeclarationList 3094 } 3095 3096 func (n *StructDeclarationList) reverse() *StructDeclarationList { 3097 if n == nil { 3098 return nil 3099 } 3100 3101 na := n 3102 nb := na.StructDeclarationList 3103 for nb != nil { 3104 nc := nb.StructDeclarationList 3105 nb.StructDeclarationList = na 3106 na = nb 3107 nb = nc 3108 } 3109 n.StructDeclarationList = nil 3110 return na 3111 } 3112 3113 func (n *StructDeclarationList) fragment() interface{} { return n.reverse() } 3114 3115 // String implements fmt.Stringer. 3116 func (n *StructDeclarationList) String() string { 3117 return PrettyString(n) 3118 } 3119 3120 // Pos reports the position of the first component of n or zero if it's empty. 3121 func (n *StructDeclarationList) Pos() token.Pos { 3122 if n == nil { 3123 return 0 3124 } 3125 3126 switch n.Case { 3127 case 0: 3128 return n.StructDeclaration.Pos() 3129 case 1: 3130 return n.StructDeclarationList.Pos() 3131 default: 3132 panic("internal error") 3133 } 3134 } 3135 3136 // StructDeclaratorCase represents case numbers of production StructDeclarator 3137 type StructDeclaratorCase int 3138 3139 // Values of type StructDeclaratorCase 3140 const ( 3141 StructDeclaratorBase StructDeclaratorCase = iota 3142 StructDeclaratorBits 3143 ) 3144 3145 // String implements fmt.Stringer 3146 func (n StructDeclaratorCase) String() string { 3147 switch n { 3148 case StructDeclaratorBase: 3149 return "StructDeclaratorBase" 3150 case StructDeclaratorBits: 3151 return "StructDeclaratorBits" 3152 default: 3153 return fmt.Sprintf("StructDeclaratorCase(%v)", int(n)) 3154 } 3155 } 3156 3157 // StructDeclarator represents data reduced by productions: 3158 // 3159 // StructDeclarator: 3160 // Declarator // Case StructDeclaratorBase 3161 // | DeclaratorOpt ':' ConstExpr // Case StructDeclaratorBits 3162 type StructDeclarator struct { 3163 Bits int 3164 Case StructDeclaratorCase 3165 ConstExpr *ConstExpr 3166 Declarator *Declarator 3167 DeclaratorOpt *DeclaratorOpt 3168 Token xc.Token 3169 } 3170 3171 func (n *StructDeclarator) fragment() interface{} { return n } 3172 3173 // String implements fmt.Stringer. 3174 func (n *StructDeclarator) String() string { 3175 return PrettyString(n) 3176 } 3177 3178 // Pos reports the position of the first component of n or zero if it's empty. 3179 func (n *StructDeclarator) Pos() token.Pos { 3180 if n == nil { 3181 return 0 3182 } 3183 3184 switch n.Case { 3185 case 0: 3186 return n.Declarator.Pos() 3187 case 1: 3188 if p := n.DeclaratorOpt.Pos(); p != 0 { 3189 return p 3190 } 3191 3192 return n.Token.Pos() 3193 default: 3194 panic("internal error") 3195 } 3196 } 3197 3198 // StructDeclaratorList represents data reduced by productions: 3199 // 3200 // StructDeclaratorList: 3201 // StructDeclarator // Case 0 3202 // | StructDeclaratorList ',' StructDeclarator // Case 1 3203 type StructDeclaratorList struct { 3204 Case int 3205 StructDeclarator *StructDeclarator 3206 StructDeclaratorList *StructDeclaratorList 3207 Token xc.Token 3208 } 3209 3210 func (n *StructDeclaratorList) reverse() *StructDeclaratorList { 3211 if n == nil { 3212 return nil 3213 } 3214 3215 na := n 3216 nb := na.StructDeclaratorList 3217 for nb != nil { 3218 nc := nb.StructDeclaratorList 3219 nb.StructDeclaratorList = na 3220 na = nb 3221 nb = nc 3222 } 3223 n.StructDeclaratorList = nil 3224 return na 3225 } 3226 3227 func (n *StructDeclaratorList) fragment() interface{} { return n.reverse() } 3228 3229 // String implements fmt.Stringer. 3230 func (n *StructDeclaratorList) String() string { 3231 return PrettyString(n) 3232 } 3233 3234 // Pos reports the position of the first component of n or zero if it's empty. 3235 func (n *StructDeclaratorList) Pos() token.Pos { 3236 if n == nil { 3237 return 0 3238 } 3239 3240 switch n.Case { 3241 case 0: 3242 return n.StructDeclarator.Pos() 3243 case 1: 3244 return n.StructDeclaratorList.Pos() 3245 default: 3246 panic("internal error") 3247 } 3248 } 3249 3250 // StructOrUnionCase represents case numbers of production StructOrUnion 3251 type StructOrUnionCase int 3252 3253 // Values of type StructOrUnionCase 3254 const ( 3255 StructOrUnionStruct StructOrUnionCase = iota 3256 StructOrUnionUnion 3257 ) 3258 3259 // String implements fmt.Stringer 3260 func (n StructOrUnionCase) String() string { 3261 switch n { 3262 case StructOrUnionStruct: 3263 return "StructOrUnionStruct" 3264 case StructOrUnionUnion: 3265 return "StructOrUnionUnion" 3266 default: 3267 return fmt.Sprintf("StructOrUnionCase(%v)", int(n)) 3268 } 3269 } 3270 3271 // StructOrUnion represents data reduced by productions: 3272 // 3273 // StructOrUnion: 3274 // "struct" // Case StructOrUnionStruct 3275 // | "union" // Case StructOrUnionUnion 3276 type StructOrUnion struct { 3277 Case StructOrUnionCase 3278 Token xc.Token 3279 } 3280 3281 func (n *StructOrUnion) fragment() interface{} { return n } 3282 3283 // String implements fmt.Stringer. 3284 func (n *StructOrUnion) String() string { 3285 return PrettyString(n) 3286 } 3287 3288 // Pos reports the position of the first component of n or zero if it's empty. 3289 func (n *StructOrUnion) Pos() token.Pos { 3290 if n == nil { 3291 return 0 3292 } 3293 3294 return n.Token.Pos() 3295 } 3296 3297 // StructOrUnionSpecifierCase represents case numbers of production StructOrUnionSpecifier 3298 type StructOrUnionSpecifierCase int 3299 3300 // Values of type StructOrUnionSpecifierCase 3301 const ( 3302 StructOrUnionSpecifierTag StructOrUnionSpecifierCase = iota 3303 StructOrUnionSpecifierEmpty 3304 StructOrUnionSpecifierDefine 3305 ) 3306 3307 // String implements fmt.Stringer 3308 func (n StructOrUnionSpecifierCase) String() string { 3309 switch n { 3310 case StructOrUnionSpecifierTag: 3311 return "StructOrUnionSpecifierTag" 3312 case StructOrUnionSpecifierEmpty: 3313 return "StructOrUnionSpecifierEmpty" 3314 case StructOrUnionSpecifierDefine: 3315 return "StructOrUnionSpecifierDefine" 3316 default: 3317 return fmt.Sprintf("StructOrUnionSpecifierCase(%v)", int(n)) 3318 } 3319 } 3320 3321 // StructOrUnionSpecifier represents data reduced by productions: 3322 // 3323 // StructOrUnionSpecifier: 3324 // StructOrUnion IDENTIFIER // Case StructOrUnionSpecifierTag 3325 // | StructOrUnion IdentifierOpt '{' '}' // Case StructOrUnionSpecifierEmpty 3326 // | StructOrUnion IdentifierOpt '{' StructDeclarationList '}' // Case StructOrUnionSpecifierDefine 3327 type StructOrUnionSpecifier struct { 3328 scope *Scope // Declare the struct tag in scope.parent. 3329 typ Type 3330 Case StructOrUnionSpecifierCase 3331 IdentifierOpt *IdentifierOpt 3332 StructDeclarationList *StructDeclarationList 3333 StructOrUnion *StructOrUnion 3334 Token xc.Token 3335 Token2 xc.Token 3336 } 3337 3338 func (n *StructOrUnionSpecifier) fragment() interface{} { return n } 3339 3340 // String implements fmt.Stringer. 3341 func (n *StructOrUnionSpecifier) String() string { 3342 return PrettyString(n) 3343 } 3344 3345 // Pos reports the position of the first component of n or zero if it's empty. 3346 func (n *StructOrUnionSpecifier) Pos() token.Pos { 3347 if n == nil { 3348 return 0 3349 } 3350 3351 return n.StructOrUnion.Pos() 3352 } 3353 3354 // TypeName represents data reduced by production: 3355 // 3356 // TypeName: 3357 // SpecifierQualifierList AbstractDeclaratorOpt // Case 0 3358 type TypeName struct { 3359 Type Type 3360 AbstractDeclaratorOpt *AbstractDeclaratorOpt 3361 SpecifierQualifierList *SpecifierQualifierList 3362 } 3363 3364 func (n *TypeName) fragment() interface{} { return n } 3365 3366 // String implements fmt.Stringer. 3367 func (n *TypeName) String() string { 3368 return PrettyString(n) 3369 } 3370 3371 // Pos reports the position of the first component of n or zero if it's empty. 3372 func (n *TypeName) Pos() token.Pos { 3373 if n == nil { 3374 return 0 3375 } 3376 3377 return n.SpecifierQualifierList.Pos() 3378 } 3379 3380 // TypeQualifierCase represents case numbers of production TypeQualifier 3381 type TypeQualifierCase int 3382 3383 // Values of type TypeQualifierCase 3384 const ( 3385 TypeQualifierConst TypeQualifierCase = iota 3386 TypeQualifierRestrict 3387 TypeQualifierVolatile 3388 TypeQualifierAtomic 3389 ) 3390 3391 // String implements fmt.Stringer 3392 func (n TypeQualifierCase) String() string { 3393 switch n { 3394 case TypeQualifierConst: 3395 return "TypeQualifierConst" 3396 case TypeQualifierRestrict: 3397 return "TypeQualifierRestrict" 3398 case TypeQualifierVolatile: 3399 return "TypeQualifierVolatile" 3400 case TypeQualifierAtomic: 3401 return "TypeQualifierAtomic" 3402 default: 3403 return fmt.Sprintf("TypeQualifierCase(%v)", int(n)) 3404 } 3405 } 3406 3407 // TypeQualifier represents data reduced by productions: 3408 // 3409 // TypeQualifier: 3410 // "const" // Case TypeQualifierConst 3411 // | "restrict" // Case TypeQualifierRestrict 3412 // | "volatile" // Case TypeQualifierVolatile 3413 // | "_Atomic" // Case TypeQualifierAtomic 3414 type TypeQualifier struct { 3415 Case TypeQualifierCase 3416 Token xc.Token 3417 } 3418 3419 func (n *TypeQualifier) fragment() interface{} { return n } 3420 3421 // String implements fmt.Stringer. 3422 func (n *TypeQualifier) String() string { 3423 return PrettyString(n) 3424 } 3425 3426 // Pos reports the position of the first component of n or zero if it's empty. 3427 func (n *TypeQualifier) Pos() token.Pos { 3428 if n == nil { 3429 return 0 3430 } 3431 3432 return n.Token.Pos() 3433 } 3434 3435 // TypeQualifierList represents data reduced by productions: 3436 // 3437 // TypeQualifierList: 3438 // TypeQualifier // Case 0 3439 // | TypeQualifierList TypeQualifier // Case 1 3440 type TypeQualifierList struct { 3441 Case int 3442 TypeQualifier *TypeQualifier 3443 TypeQualifierList *TypeQualifierList 3444 } 3445 3446 func (n *TypeQualifierList) reverse() *TypeQualifierList { 3447 if n == nil { 3448 return nil 3449 } 3450 3451 na := n 3452 nb := na.TypeQualifierList 3453 for nb != nil { 3454 nc := nb.TypeQualifierList 3455 nb.TypeQualifierList = na 3456 na = nb 3457 nb = nc 3458 } 3459 n.TypeQualifierList = nil 3460 return na 3461 } 3462 3463 func (n *TypeQualifierList) fragment() interface{} { return n.reverse() } 3464 3465 // String implements fmt.Stringer. 3466 func (n *TypeQualifierList) String() string { 3467 return PrettyString(n) 3468 } 3469 3470 // Pos reports the position of the first component of n or zero if it's empty. 3471 func (n *TypeQualifierList) Pos() token.Pos { 3472 if n == nil { 3473 return 0 3474 } 3475 3476 switch n.Case { 3477 case 0: 3478 return n.TypeQualifier.Pos() 3479 case 1: 3480 return n.TypeQualifierList.Pos() 3481 default: 3482 panic("internal error") 3483 } 3484 } 3485 3486 // TypeQualifierListOpt represents data reduced by productions: 3487 // 3488 // TypeQualifierListOpt: 3489 // /* empty */ // Case 0 3490 // | TypeQualifierList // Case 1 3491 type TypeQualifierListOpt struct { 3492 TypeQualifierList *TypeQualifierList 3493 } 3494 3495 func (n *TypeQualifierListOpt) fragment() interface{} { return n } 3496 3497 // String implements fmt.Stringer. 3498 func (n *TypeQualifierListOpt) String() string { 3499 return PrettyString(n) 3500 } 3501 3502 // Pos reports the position of the first component of n or zero if it's empty. 3503 func (n *TypeQualifierListOpt) Pos() token.Pos { 3504 if n == nil { 3505 return 0 3506 } 3507 3508 return n.TypeQualifierList.Pos() 3509 } 3510 3511 // TypeSpecifierCase represents case numbers of production TypeSpecifier 3512 type TypeSpecifierCase int 3513 3514 // Values of type TypeSpecifierCase 3515 const ( 3516 TypeSpecifierBool TypeSpecifierCase = iota 3517 TypeSpecifierComplex 3518 TypeSpecifierImaginary 3519 TypeSpecifierChar 3520 TypeSpecifierDouble 3521 TypeSpecifierFloat 3522 TypeSpecifierInt 3523 TypeSpecifierLong 3524 TypeSpecifierShort 3525 TypeSpecifierSigned 3526 TypeSpecifierUnsigned 3527 TypeSpecifierVoid 3528 TypeSpecifierEnum 3529 TypeSpecifierStruct 3530 TypeSpecifierName 3531 TypeSpecifierTypeofExpr 3532 TypeSpecifierTypeof 3533 TypeSpecifierAtomic 3534 ) 3535 3536 // String implements fmt.Stringer 3537 func (n TypeSpecifierCase) String() string { 3538 switch n { 3539 case TypeSpecifierBool: 3540 return "TypeSpecifierBool" 3541 case TypeSpecifierComplex: 3542 return "TypeSpecifierComplex" 3543 case TypeSpecifierImaginary: 3544 return "TypeSpecifierImaginary" 3545 case TypeSpecifierChar: 3546 return "TypeSpecifierChar" 3547 case TypeSpecifierDouble: 3548 return "TypeSpecifierDouble" 3549 case TypeSpecifierFloat: 3550 return "TypeSpecifierFloat" 3551 case TypeSpecifierInt: 3552 return "TypeSpecifierInt" 3553 case TypeSpecifierLong: 3554 return "TypeSpecifierLong" 3555 case TypeSpecifierShort: 3556 return "TypeSpecifierShort" 3557 case TypeSpecifierSigned: 3558 return "TypeSpecifierSigned" 3559 case TypeSpecifierUnsigned: 3560 return "TypeSpecifierUnsigned" 3561 case TypeSpecifierVoid: 3562 return "TypeSpecifierVoid" 3563 case TypeSpecifierEnum: 3564 return "TypeSpecifierEnum" 3565 case TypeSpecifierStruct: 3566 return "TypeSpecifierStruct" 3567 case TypeSpecifierName: 3568 return "TypeSpecifierName" 3569 case TypeSpecifierTypeofExpr: 3570 return "TypeSpecifierTypeofExpr" 3571 case TypeSpecifierTypeof: 3572 return "TypeSpecifierTypeof" 3573 case TypeSpecifierAtomic: 3574 return "TypeSpecifierAtomic" 3575 default: 3576 return fmt.Sprintf("TypeSpecifierCase(%v)", int(n)) 3577 } 3578 } 3579 3580 // TypeSpecifier represents data reduced by productions: 3581 // 3582 // TypeSpecifier: 3583 // "_Bool" // Case TypeSpecifierBool 3584 // | "_Complex" // Case TypeSpecifierComplex 3585 // | "_Imaginary" // Case TypeSpecifierImaginary 3586 // | "char" // Case TypeSpecifierChar 3587 // | "double" // Case TypeSpecifierDouble 3588 // | "float" // Case TypeSpecifierFloat 3589 // | "int" // Case TypeSpecifierInt 3590 // | "long" // Case TypeSpecifierLong 3591 // | "short" // Case TypeSpecifierShort 3592 // | "signed" // Case TypeSpecifierSigned 3593 // | "unsigned" // Case TypeSpecifierUnsigned 3594 // | "void" // Case TypeSpecifierVoid 3595 // | EnumSpecifier // Case TypeSpecifierEnum 3596 // | StructOrUnionSpecifier // Case TypeSpecifierStruct 3597 // | TYPEDEF_NAME // Case TypeSpecifierName 3598 // | "typeof" '(' Expr ')' // Case TypeSpecifierTypeofExpr 3599 // | "typeof" '(' TypeName ')' // Case TypeSpecifierTypeof 3600 // | "_Atomic" ATOMIC_LPAREN TypeName ')' // Case TypeSpecifierAtomic 3601 type TypeSpecifier struct { 3602 scope *Scope 3603 typ Type // typeof 3604 Case TypeSpecifierCase 3605 EnumSpecifier *EnumSpecifier 3606 Expr *Expr 3607 StructOrUnionSpecifier *StructOrUnionSpecifier 3608 Token xc.Token 3609 Token2 xc.Token 3610 Token3 xc.Token 3611 TypeName *TypeName 3612 } 3613 3614 func (n *TypeSpecifier) fragment() interface{} { return n } 3615 3616 // String implements fmt.Stringer. 3617 func (n *TypeSpecifier) String() string { 3618 return PrettyString(n) 3619 } 3620 3621 // Pos reports the position of the first component of n or zero if it's empty. 3622 func (n *TypeSpecifier) Pos() token.Pos { 3623 if n == nil { 3624 return 0 3625 } 3626 3627 switch n.Case { 3628 case 12: 3629 return n.EnumSpecifier.Pos() 3630 case 13: 3631 return n.StructOrUnionSpecifier.Pos() 3632 case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16, 17: 3633 return n.Token.Pos() 3634 default: 3635 panic("internal error") 3636 } 3637 } 3638 3639 // VolatileOpt represents data reduced by productions: 3640 // 3641 // VolatileOpt: 3642 // /* empty */ // Case 0 3643 // | "volatile" // Case 1 3644 type VolatileOpt struct { 3645 Token xc.Token 3646 } 3647 3648 func (n *VolatileOpt) fragment() interface{} { return n } 3649 3650 // String implements fmt.Stringer. 3651 func (n *VolatileOpt) String() string { 3652 return PrettyString(n) 3653 } 3654 3655 // Pos reports the position of the first component of n or zero if it's empty. 3656 func (n *VolatileOpt) Pos() token.Pos { 3657 if n == nil { 3658 return 0 3659 } 3660 3661 return n.Token.Pos() 3662 } 3663 3664 // statementEnd represents data reduced by production: 3665 // 3666 // statementEnd: 3667 // /* empty */ // Case 0 3668 type statementEnd struct { 3669 } 3670 3671 func (n *statementEnd) fragment() interface{} { return n } 3672 3673 // String implements fmt.Stringer. 3674 func (n *statementEnd) String() string { 3675 return PrettyString(n) 3676 } 3677 3678 // Pos reports the position of the first component of n or zero if it's empty. 3679 func (n *statementEnd) Pos() token.Pos { 3680 if n == nil { 3681 return 0 3682 } 3683 3684 return 0 3685 }