gitee.com/quant1x/pkg@v0.2.8/goja/ast/README.markdown (about) 1 # ast 2 -- 3 4 import "github.com/dop251/goja/ast" 5 6 Package ast declares types representing a JavaScript AST. 7 8 ### Warning 9 10 The parser and AST interfaces are still works-in-progress (particularly where 11 node types are concerned) and may change in the future. 12 13 ## Usage 14 15 #### type ArrayLiteral 16 17 ```go 18 type ArrayLiteral struct { 19 LeftBracket file.Idx 20 RightBracket file.Idx 21 Value []Expression 22 } 23 ``` 24 25 #### func (*ArrayLiteral) Idx0 26 27 ```go 28 func (self *ArrayLiteral) Idx0() file.Idx 29 ``` 30 31 #### func (*ArrayLiteral) Idx1 32 33 ```go 34 func (self *ArrayLiteral) Idx1() file.Idx 35 ``` 36 37 #### type AssignExpression 38 39 ```go 40 type AssignExpression struct { 41 Operator token.Token 42 Left Expression 43 Right Expression 44 } 45 ``` 46 47 #### func (*AssignExpression) Idx0 48 49 ```go 50 func (self *AssignExpression) Idx0() file.Idx 51 ``` 52 53 #### func (*AssignExpression) Idx1 54 55 ```go 56 func (self *AssignExpression) Idx1() file.Idx 57 ``` 58 59 #### type BadExpression 60 61 ```go 62 type BadExpression struct { 63 From file.Idx 64 To file.Idx 65 } 66 ``` 67 68 #### func (*BadExpression) Idx0 69 70 ```go 71 func (self *BadExpression) Idx0() file.Idx 72 ``` 73 74 #### func (*BadExpression) Idx1 75 76 ```go 77 func (self *BadExpression) Idx1() file.Idx 78 ``` 79 80 #### type BadStatement 81 82 ```go 83 type BadStatement struct { 84 From file.Idx 85 To file.Idx 86 } 87 ``` 88 89 #### func (*BadStatement) Idx0 90 91 ```go 92 func (self *BadStatement) Idx0() file.Idx 93 ``` 94 95 #### func (*BadStatement) Idx1 96 97 ```go 98 func (self *BadStatement) Idx1() file.Idx 99 ``` 100 101 #### type BinaryExpression 102 103 ```go 104 type BinaryExpression struct { 105 Operator token.Token 106 Left Expression 107 Right Expression 108 Comparison bool 109 } 110 ``` 111 112 #### func (*BinaryExpression) Idx0 113 114 ```go 115 func (self *BinaryExpression) Idx0() file.Idx 116 ``` 117 118 #### func (*BinaryExpression) Idx1 119 120 ```go 121 func (self *BinaryExpression) Idx1() file.Idx 122 ``` 123 124 #### type BlockStatement 125 126 ```go 127 type BlockStatement struct { 128 LeftBrace file.Idx 129 List []Statement 130 RightBrace file.Idx 131 } 132 ``` 133 134 #### func (*BlockStatement) Idx0 135 136 ```go 137 func (self *BlockStatement) Idx0() file.Idx 138 ``` 139 140 #### func (*BlockStatement) Idx1 141 142 ```go 143 func (self *BlockStatement) Idx1() file.Idx 144 ``` 145 146 #### type BooleanLiteral 147 148 ```go 149 type BooleanLiteral struct { 150 Idx file.Idx 151 Literal string 152 Value bool 153 } 154 ``` 155 156 #### func (*BooleanLiteral) Idx0 157 158 ```go 159 func (self *BooleanLiteral) Idx0() file.Idx 160 ``` 161 162 #### func (*BooleanLiteral) Idx1 163 164 ```go 165 func (self *BooleanLiteral) Idx1() file.Idx 166 ``` 167 168 #### type BracketExpression 169 170 ```go 171 type BracketExpression struct { 172 Left Expression 173 Member Expression 174 LeftBracket file.Idx 175 RightBracket file.Idx 176 } 177 ``` 178 179 #### func (*BracketExpression) Idx0 180 181 ```go 182 func (self *BracketExpression) Idx0() file.Idx 183 ``` 184 185 #### func (*BracketExpression) Idx1 186 187 ```go 188 func (self *BracketExpression) Idx1() file.Idx 189 ``` 190 191 #### type BranchStatement 192 193 ```go 194 type BranchStatement struct { 195 Idx file.Idx 196 Token token.Token 197 Label *Identifier 198 } 199 ``` 200 201 #### func (*BranchStatement) Idx0 202 203 ```go 204 func (self *BranchStatement) Idx0() file.Idx 205 ``` 206 207 #### func (*BranchStatement) Idx1 208 209 ```go 210 func (self *BranchStatement) Idx1() file.Idx 211 ``` 212 213 #### type CallExpression 214 215 ```go 216 type CallExpression struct { 217 Callee Expression 218 LeftParenthesis file.Idx 219 ArgumentList []Expression 220 RightParenthesis file.Idx 221 } 222 ``` 223 224 #### func (*CallExpression) Idx0 225 226 ```go 227 func (self *CallExpression) Idx0() file.Idx 228 ``` 229 230 #### func (*CallExpression) Idx1 231 232 ```go 233 func (self *CallExpression) Idx1() file.Idx 234 ``` 235 236 #### type CaseStatement 237 238 ```go 239 type CaseStatement struct { 240 Case file.Idx 241 Test Expression 242 Consequent []Statement 243 } 244 ``` 245 246 #### func (*CaseStatement) Idx0 247 248 ```go 249 func (self *CaseStatement) Idx0() file.Idx 250 ``` 251 252 #### func (*CaseStatement) Idx1 253 254 ```go 255 func (self *CaseStatement) Idx1() file.Idx 256 ``` 257 258 #### type CatchStatement 259 260 ```go 261 type CatchStatement struct { 262 Catch file.Idx 263 Parameter *Identifier 264 Body Statement 265 } 266 ``` 267 268 #### func (*CatchStatement) Idx0 269 270 ```go 271 func (self *CatchStatement) Idx0() file.Idx 272 ``` 273 274 #### func (*CatchStatement) Idx1 275 276 ```go 277 func (self *CatchStatement) Idx1() file.Idx 278 ``` 279 280 #### type ConditionalExpression 281 282 ```go 283 type ConditionalExpression struct { 284 Test Expression 285 Consequent Expression 286 Alternate Expression 287 } 288 ``` 289 290 #### func (*ConditionalExpression) Idx0 291 292 ```go 293 func (self *ConditionalExpression) Idx0() file.Idx 294 ``` 295 296 #### func (*ConditionalExpression) Idx1 297 298 ```go 299 func (self *ConditionalExpression) Idx1() file.Idx 300 ``` 301 302 #### type DebuggerStatement 303 304 ```go 305 type DebuggerStatement struct { 306 Debugger file.Idx 307 } 308 ``` 309 310 #### func (*DebuggerStatement) Idx0 311 312 ```go 313 func (self *DebuggerStatement) Idx0() file.Idx 314 ``` 315 316 #### func (*DebuggerStatement) Idx1 317 318 ```go 319 func (self *DebuggerStatement) Idx1() file.Idx 320 ``` 321 322 #### type Declaration 323 324 ```go 325 type Declaration interface { 326 // contains filtered or unexported methods 327 } 328 ``` 329 330 All declaration nodes implement the Declaration interface. 331 332 #### type DoWhileStatement 333 334 ```go 335 type DoWhileStatement struct { 336 Do file.Idx 337 Test Expression 338 Body Statement 339 } 340 ``` 341 342 #### func (*DoWhileStatement) Idx0 343 344 ```go 345 func (self *DoWhileStatement) Idx0() file.Idx 346 ``` 347 348 #### func (*DoWhileStatement) Idx1 349 350 ```go 351 func (self *DoWhileStatement) Idx1() file.Idx 352 ``` 353 354 #### type DotExpression 355 356 ```go 357 type DotExpression struct { 358 Left Expression 359 Identifier Identifier 360 } 361 ``` 362 363 #### func (*DotExpression) Idx0 364 365 ```go 366 func (self *DotExpression) Idx0() file.Idx 367 ``` 368 369 #### func (*DotExpression) Idx1 370 371 ```go 372 func (self *DotExpression) Idx1() file.Idx 373 ``` 374 375 #### type EmptyStatement 376 377 ```go 378 type EmptyStatement struct { 379 Semicolon file.Idx 380 } 381 ``` 382 383 #### func (*EmptyStatement) Idx0 384 385 ```go 386 func (self *EmptyStatement) Idx0() file.Idx 387 ``` 388 389 #### func (*EmptyStatement) Idx1 390 391 ```go 392 func (self *EmptyStatement) Idx1() file.Idx 393 ``` 394 395 #### type Expression 396 397 ```go 398 type Expression interface { 399 Node 400 // contains filtered or unexported methods 401 } 402 ``` 403 404 All expression nodes implement the Expression interface. 405 406 #### type ExpressionStatement 407 408 ```go 409 type ExpressionStatement struct { 410 Expression Expression 411 } 412 ``` 413 414 #### func (*ExpressionStatement) Idx0 415 416 ```go 417 func (self *ExpressionStatement) Idx0() file.Idx 418 ``` 419 420 #### func (*ExpressionStatement) Idx1 421 422 ```go 423 func (self *ExpressionStatement) Idx1() file.Idx 424 ``` 425 426 #### type ForInStatement 427 428 ```go 429 type ForInStatement struct { 430 For file.Idx 431 Into Expression 432 Source Expression 433 Body Statement 434 } 435 ``` 436 437 #### func (*ForInStatement) Idx0 438 439 ```go 440 func (self *ForInStatement) Idx0() file.Idx 441 ``` 442 443 #### func (*ForInStatement) Idx1 444 445 ```go 446 func (self *ForInStatement) Idx1() file.Idx 447 ``` 448 449 #### type ForStatement 450 451 ```go 452 type ForStatement struct { 453 For file.Idx 454 Initializer Expression 455 Update Expression 456 Test Expression 457 Body Statement 458 } 459 ``` 460 461 #### func (*ForStatement) Idx0 462 463 ```go 464 func (self *ForStatement) Idx0() file.Idx 465 ``` 466 467 #### func (*ForStatement) Idx1 468 469 ```go 470 func (self *ForStatement) Idx1() file.Idx 471 ``` 472 473 #### type FunctionDeclaration 474 475 ```go 476 type FunctionDeclaration struct { 477 Function *FunctionLiteral 478 } 479 ``` 480 481 #### type FunctionLiteral 482 483 ```go 484 type FunctionLiteral struct { 485 Function file.Idx 486 Name *Identifier 487 ParameterList *ParameterList 488 Body Statement 489 Source string 490 491 DeclarationList []Declaration 492 } 493 ``` 494 495 #### func (*FunctionLiteral) Idx0 496 497 ```go 498 func (self *FunctionLiteral) Idx0() file.Idx 499 ``` 500 501 #### func (*FunctionLiteral) Idx1 502 503 ```go 504 func (self *FunctionLiteral) Idx1() file.Idx 505 ``` 506 507 #### type Identifier 508 509 ```go 510 type Identifier struct { 511 Name string 512 Idx file.Idx 513 } 514 ``` 515 516 #### func (*Identifier) Idx0 517 518 ```go 519 func (self *Identifier) Idx0() file.Idx 520 ``` 521 522 #### func (*Identifier) Idx1 523 524 ```go 525 func (self *Identifier) Idx1() file.Idx 526 ``` 527 528 #### type IfStatement 529 530 ```go 531 type IfStatement struct { 532 If file.Idx 533 Test Expression 534 Consequent Statement 535 Alternate Statement 536 } 537 ``` 538 539 #### func (*IfStatement) Idx0 540 541 ```go 542 func (self *IfStatement) Idx0() file.Idx 543 ``` 544 545 #### func (*IfStatement) Idx1 546 547 ```go 548 func (self *IfStatement) Idx1() file.Idx 549 ``` 550 551 #### type LabelledStatement 552 553 ```go 554 type LabelledStatement struct { 555 Label *Identifier 556 Colon file.Idx 557 Statement Statement 558 } 559 ``` 560 561 #### func (*LabelledStatement) Idx0 562 563 ```go 564 func (self *LabelledStatement) Idx0() file.Idx 565 ``` 566 567 #### func (*LabelledStatement) Idx1 568 569 ```go 570 func (self *LabelledStatement) Idx1() file.Idx 571 ``` 572 573 #### type NewExpression 574 575 ```go 576 type NewExpression struct { 577 New file.Idx 578 Callee Expression 579 LeftParenthesis file.Idx 580 ArgumentList []Expression 581 RightParenthesis file.Idx 582 } 583 ``` 584 585 #### func (*NewExpression) Idx0 586 587 ```go 588 func (self *NewExpression) Idx0() file.Idx 589 ``` 590 591 #### func (*NewExpression) Idx1 592 593 ```go 594 func (self *NewExpression) Idx1() file.Idx 595 ``` 596 597 #### type Node 598 599 ```go 600 type Node interface { 601 Idx0() file.Idx // The index of the first character belonging to the node 602 Idx1() file.Idx // The index of the first character immediately after the node 603 } 604 ``` 605 606 All nodes implement the Node interface. 607 608 #### type NullLiteral 609 610 ```go 611 type NullLiteral struct { 612 Idx file.Idx 613 Literal string 614 } 615 ``` 616 617 #### func (*NullLiteral) Idx0 618 619 ```go 620 func (self *NullLiteral) Idx0() file.Idx 621 ``` 622 623 #### func (*NullLiteral) Idx1 624 625 ```go 626 func (self *NullLiteral) Idx1() file.Idx 627 ``` 628 629 #### type NumberLiteral 630 631 ```go 632 type NumberLiteral struct { 633 Idx file.Idx 634 Literal string 635 Value interface{} 636 } 637 ``` 638 639 #### func (*NumberLiteral) Idx0 640 641 ```go 642 func (self *NumberLiteral) Idx0() file.Idx 643 ``` 644 645 #### func (*NumberLiteral) Idx1 646 647 ```go 648 func (self *NumberLiteral) Idx1() file.Idx 649 ``` 650 651 #### type ObjectLiteral 652 653 ```go 654 type ObjectLiteral struct { 655 LeftBrace file.Idx 656 RightBrace file.Idx 657 Value []Property 658 } 659 ``` 660 661 #### func (*ObjectLiteral) Idx0 662 663 ```go 664 func (self *ObjectLiteral) Idx0() file.Idx 665 ``` 666 667 #### func (*ObjectLiteral) Idx1 668 669 ```go 670 func (self *ObjectLiteral) Idx1() file.Idx 671 ``` 672 673 #### type ParameterList 674 675 ```go 676 type ParameterList struct { 677 Opening file.Idx 678 List []*Identifier 679 Closing file.Idx 680 } 681 ``` 682 683 #### type Program 684 685 ```go 686 type Program struct { 687 Body []Statement 688 689 DeclarationList []Declaration 690 691 File *file.File 692 } 693 ``` 694 695 #### func (*Program) Idx0 696 697 ```go 698 func (self *Program) Idx0() file.Idx 699 ``` 700 701 #### func (*Program) Idx1 702 703 ```go 704 func (self *Program) Idx1() file.Idx 705 ``` 706 707 #### type Property 708 709 ```go 710 type Property struct { 711 Key string 712 Kind string 713 Value Expression 714 } 715 ``` 716 717 #### type RegExpLiteral 718 719 ```go 720 type RegExpLiteral struct { 721 Idx file.Idx 722 Literal string 723 Pattern string 724 Flags string 725 Value string 726 } 727 ``` 728 729 #### func (*RegExpLiteral) Idx0 730 731 ```go 732 func (self *RegExpLiteral) Idx0() file.Idx 733 ``` 734 735 #### func (*RegExpLiteral) Idx1 736 737 ```go 738 func (self *RegExpLiteral) Idx1() file.Idx 739 ``` 740 741 #### type ReturnStatement 742 743 ```go 744 type ReturnStatement struct { 745 Return file.Idx 746 Argument Expression 747 } 748 ``` 749 750 #### func (*ReturnStatement) Idx0 751 752 ```go 753 func (self *ReturnStatement) Idx0() file.Idx 754 ``` 755 756 #### func (*ReturnStatement) Idx1 757 758 ```go 759 func (self *ReturnStatement) Idx1() file.Idx 760 ``` 761 762 #### type SequenceExpression 763 764 ```go 765 type SequenceExpression struct { 766 Sequence []Expression 767 } 768 ``` 769 770 #### func (*SequenceExpression) Idx0 771 772 ```go 773 func (self *SequenceExpression) Idx0() file.Idx 774 ``` 775 776 #### func (*SequenceExpression) Idx1 777 778 ```go 779 func (self *SequenceExpression) Idx1() file.Idx 780 ``` 781 782 #### type Statement 783 784 ```go 785 type Statement interface { 786 Node 787 // contains filtered or unexported methods 788 } 789 ``` 790 791 All statement nodes implement the Statement interface. 792 793 #### type StringLiteral 794 795 ```go 796 type StringLiteral struct { 797 Idx file.Idx 798 Literal string 799 Value string 800 } 801 ``` 802 803 #### func (*StringLiteral) Idx0 804 805 ```go 806 func (self *StringLiteral) Idx0() file.Idx 807 ``` 808 809 #### func (*StringLiteral) Idx1 810 811 ```go 812 func (self *StringLiteral) Idx1() file.Idx 813 ``` 814 815 #### type SwitchStatement 816 817 ```go 818 type SwitchStatement struct { 819 Switch file.Idx 820 Discriminant Expression 821 Default int 822 Body []*CaseStatement 823 } 824 ``` 825 826 #### func (*SwitchStatement) Idx0 827 828 ```go 829 func (self *SwitchStatement) Idx0() file.Idx 830 ``` 831 832 #### func (*SwitchStatement) Idx1 833 834 ```go 835 func (self *SwitchStatement) Idx1() file.Idx 836 ``` 837 838 #### type ThisExpression 839 840 ```go 841 type ThisExpression struct { 842 Idx file.Idx 843 } 844 ``` 845 846 #### func (*ThisExpression) Idx0 847 848 ```go 849 func (self *ThisExpression) Idx0() file.Idx 850 ``` 851 852 #### func (*ThisExpression) Idx1 853 854 ```go 855 func (self *ThisExpression) Idx1() file.Idx 856 ``` 857 858 #### type ThrowStatement 859 860 ```go 861 type ThrowStatement struct { 862 Throw file.Idx 863 Argument Expression 864 } 865 ``` 866 867 #### func (*ThrowStatement) Idx0 868 869 ```go 870 func (self *ThrowStatement) Idx0() file.Idx 871 ``` 872 873 #### func (*ThrowStatement) Idx1 874 875 ```go 876 func (self *ThrowStatement) Idx1() file.Idx 877 ``` 878 879 #### type TryStatement 880 881 ```go 882 type TryStatement struct { 883 Try file.Idx 884 Body Statement 885 Catch *CatchStatement 886 Finally Statement 887 } 888 ``` 889 890 #### func (*TryStatement) Idx0 891 892 ```go 893 func (self *TryStatement) Idx0() file.Idx 894 ``` 895 896 #### func (*TryStatement) Idx1 897 898 ```go 899 func (self *TryStatement) Idx1() file.Idx 900 ``` 901 902 #### type UnaryExpression 903 904 ```go 905 type UnaryExpression struct { 906 Operator token.Token 907 Idx file.Idx // If a prefix operation 908 Operand Expression 909 Postfix bool 910 } 911 ``` 912 913 #### func (*UnaryExpression) Idx0 914 915 ```go 916 func (self *UnaryExpression) Idx0() file.Idx 917 ``` 918 919 #### func (*UnaryExpression) Idx1 920 921 ```go 922 func (self *UnaryExpression) Idx1() file.Idx 923 ``` 924 925 #### type VariableDeclaration 926 927 ```go 928 type VariableDeclaration struct { 929 Var file.Idx 930 List []*VariableExpression 931 } 932 ``` 933 934 #### type VariableExpression 935 936 ```go 937 type VariableExpression struct { 938 Name string 939 Idx file.Idx 940 Initializer Expression 941 } 942 ``` 943 944 #### func (*VariableExpression) Idx0 945 946 ```go 947 func (self *VariableExpression) Idx0() file.Idx 948 ``` 949 950 #### func (*VariableExpression) Idx1 951 952 ```go 953 func (self *VariableExpression) Idx1() file.Idx 954 ``` 955 956 #### type VariableStatement 957 958 ```go 959 type VariableStatement struct { 960 Var file.Idx 961 List []Expression 962 } 963 ``` 964 965 #### func (*VariableStatement) Idx0 966 967 ```go 968 func (self *VariableStatement) Idx0() file.Idx 969 ``` 970 971 #### func (*VariableStatement) Idx1 972 973 ```go 974 func (self *VariableStatement) Idx1() file.Idx 975 ``` 976 977 #### type WhileStatement 978 979 ```go 980 type WhileStatement struct { 981 While file.Idx 982 Test Expression 983 Body Statement 984 } 985 ``` 986 987 #### func (*WhileStatement) Idx0 988 989 ```go 990 func (self *WhileStatement) Idx0() file.Idx 991 ``` 992 993 #### func (*WhileStatement) Idx1 994 995 ```go 996 func (self *WhileStatement) Idx1() file.Idx 997 ``` 998 999 #### type WithStatement 1000 1001 ```go 1002 type WithStatement struct { 1003 With file.Idx 1004 Object Expression 1005 Body Statement 1006 } 1007 ``` 1008 1009 #### func (*WithStatement) Idx0 1010 1011 ```go 1012 func (self *WithStatement) Idx0() file.Idx 1013 ``` 1014 1015 #### func (*WithStatement) Idx1 1016 1017 ```go 1018 func (self *WithStatement) Idx1() file.Idx 1019 ``` 1020 1021 -- 1022 **godocdown** http://github.com/robertkrimen/godocdown