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