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