MCPcopy
hub / github.com/jquery/esprima / constructor

Method constructor

src/parser.ts:78–170  ·  view source on GitHub ↗
(code: string, options: any = {}, delegate)

Source from the content-addressed store, hash-verified

76 lastMarker: Marker;
77
78 constructor(code: string, options: any = {}, delegate) {
79 this.config = {
80 range: (typeof options.range === 'boolean') && options.range,
81 loc: (typeof options.loc === 'boolean') && options.loc,
82 source: null,
83 tokens: (typeof options.tokens === 'boolean') && options.tokens,
84 comment: (typeof options.comment === 'boolean') && options.comment,
85 tolerant: (typeof options.tolerant === 'boolean') && options.tolerant
86 };
87 if (this.config.loc && options.source && options.source !== null) {
88 this.config.source = String(options.source);
89 }
90
91 this.delegate = delegate;
92
93 this.errorHandler = new ErrorHandler();
94 this.errorHandler.tolerant = this.config.tolerant;
95 this.scanner = new Scanner(code, this.errorHandler);
96 this.scanner.trackComment = this.config.comment;
97
98 this.operatorPrecedence = {
99 ')': 0,
100 ';': 0,
101 ',': 0,
102 '=': 0,
103 ']': 0,
104 '||': 1,
105 '&&': 2,
106 '|': 3,
107 '^': 4,
108 '&': 5,
109 '==': 6,
110 '!=': 6,
111 '===': 6,
112 '!==': 6,
113 '<': 7,
114 '>': 7,
115 '<=': 7,
116 '>=': 7,
117 '<<': 8,
118 '>>': 8,
119 '>>>': 8,
120 '+': 9,
121 '-': 9,
122 '*': 11,
123 '/': 11,
124 '%': 11
125 };
126
127 this.lookahead = {
128 type: Token.EOF,
129 value: '',
130 lineNumber: this.scanner.lineNumber,
131 lineStart: 0,
132 start: 0,
133 end: 0
134 };
135 this.hasLineTerminator = false;

Callers

nothing calls this directly

Calls 1

nextTokenMethod · 0.95

Tested by

no test coverage detected