Lines Matching full:this

8 // simply exist as properties on the parser object. This is only
13 this.type = p.type
14 this.value = p.value
15 this.start = p.start
16 this.end = p.end
18 this.loc = new SourceLocation(p, p.startLoc, p.endLoc)
20 this.range = [p.start, p.end]
34 if (this.options.onToken)
35 this.options.onToken(new Token(this))
37 this.lastTokEnd = this.end
38 this.lastTokStart = this.start
39 this.lastTokEndLoc = this.endLoc
40 this.lastTokStartLoc = this.startLoc
41 this.nextToken()
45 this.next()
46 return new Token(this)
52 let self = this
66 return this.context[this.context.length - 1]
73 let curContext = this.curContext()
74 if (!curContext || !curContext.preserveSpace) this.skipSpace()
76 this.start = this.pos
77 if (this.options.locations) this.startLoc = this.curPosition()
78 if (this.pos >= this.input.length) return this.finishToken(tt.eof)
80 if (curContext.override) return curContext.override(this)
81 else this.readToken(this.fullCharCodeAtPos())
87 if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
88 return this.readWord()
90 return this.getTokenFromCode(code)
94 let code = this.input.charCodeAt(this.pos)
96 let next = this.input.charCodeAt(this.pos + 1)
101 let startLoc = this.options.onComment && this.curPosition()
102 let start = this.pos, end = this.input.indexOf("*/", this.pos += 2)
103 if (end === -1) this.raise(this.pos - 2, "Unterminated comment")
104 this.pos = end + 2
105 if (this.options.locations) {
108 while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
109 ++this.curLine
110 this.lineStart = match.index + match[0].length
113 if (this.options.onComment)
114 this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
115 startLoc, this.curPosition())
119 let start = this.pos
120 let startLoc = this.options.onComment && this.curPosition()
121 let ch = this.input.charCodeAt(this.pos+=startSkip)
122 while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
123 ++this.pos
124 ch = this.input.charCodeAt(this.pos)
126 if (this.options.onComment)
127 this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
128 startLoc, this.curPosition())
135 loop: while (this.pos < this.input.length) {
136 let ch = this.input.charCodeAt(this.pos)
139 ++this.pos
142 if (this.input.charCodeAt(this.pos + 1) === 10) {
143 ++this.pos
146 ++this.pos
147 if (this.options.locations) {
148 ++this.curLine
149 this.lineStart = this.pos
153 switch (this.input.charCodeAt(this.pos + 1)) {
155 this.skipBlockComment()
158 this.skipLineComment(2)
166 ++this.pos
180 this.end = this.pos
181 if (this.options.locations) this.endLoc = this.curPosition()
182 let prevType = this.type
183 this.type = type
184 this.value = val
186 this.updateContext(prevType)
191 // This is the function that is called to fetch the next token. It
199 let next = this.input.charCodeAt(this.pos + 1)
200 if (next >= 48 && next <= 57) return this.readNumber(true)
201 let next2 = this.input.charCodeAt(this.pos + 2)
202 if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
203 this.pos += 3
204 return this.finishToken(tt.ellipsis)
206 ++this.pos
207 return this.finishToken(tt.dot)
212 let next = this.input.charCodeAt(this.pos + 1)
213 if (this.exprAllowed) {++this.pos; return this.readRegexp()}
214 if (next === 61) return this.finishOp(tt.assign, 2)
215 return this.finishOp(tt.slash, 1)
219 let next = this.input.charCodeAt(this.pos + 1)
224 if (this.options.ecmaVersion >= 7 && next === 42) {
227 next = this.input.charCodeAt(this.pos + 2)
230 if (next === 61) return this.finishOp(tt.assign, size + 1)
231 return this.finishOp(tokentype, size)
235 let next = this.input.charCodeAt(this.pos + 1)
236 if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2)
237 if (next === 61) return this.finishOp(tt.assign, 2)
238 return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1)
242 let next = this.input.charCodeAt(this.pos + 1)
243 if (next === 61) return this.finishOp(tt.assign, 2)
244 return this.finishOp(tt.bitwiseXOR, 1)
248 let next = this.input.charCodeAt(this.pos + 1)
250 if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 &&
251 lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) {
253 this.skipLineComment(3)
254 this.skipSpace()
255 return this.nextToken()
257 return this.finishOp(tt.incDec, 2)
259 if (next === 61) return this.finishOp(tt.assign, 2)
260 return this.finishOp(tt.plusMin, 1)
264 let next = this.input.charCodeAt(this.pos + 1)
267 size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2
268 if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)
269 return this.finishOp(tt.bitShift, size)
271 if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&
272 this.input.charCodeAt(this.pos + 3) == 45) {
273 if (this.inModule) this.unexpected()
275 this.skipLineComment(4)
276 this.skipSpace()
277 return this.nextToken()
280 return this.finishOp(tt.relational, size)
284 let next = this.input.charCodeAt(this.pos + 1)
285 …if (next === 61) return this.finishOp(tt.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 …
286 if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) { // '=>'
287 this.pos += 2
288 return this.finishToken(tt.arrow)
290 return this.finishOp(code === 61 ? tt.eq : tt.prefix, 1)
298 return this.readToken_dot()
301 case 40: ++this.pos; return this.finishToken(tt.parenL)
302 case 41: ++this.pos; return this.finishToken(tt.parenR)
303 case 59: ++this.pos; return this.finishToken(tt.semi)
304 case 44: ++this.pos; return this.finishToken(tt.comma)
305 case 91: ++this.pos; return this.finishToken(tt.bracketL)
306 case 93: ++this.pos; return this.finishToken(tt.bracketR)
307 case 123: ++this.pos; return this.finishToken(tt.braceL)
308 case 125: ++this.pos; return this.finishToken(tt.braceR)
309 case 58: ++this.pos; return this.finishToken(tt.colon)
310 case 63: ++this.pos; return this.finishToken(tt.question)
313 if (this.options.ecmaVersion < 6) break
314 ++this.pos
315 return this.finishToken(tt.backQuote)
318 let next = this.input.charCodeAt(this.pos + 1)
319 if (next === 120 || next === 88) return this.readRadixNumber(16) // '0x', '0X' - hex number
320 if (this.options.ecmaVersion >= 6) {
321 if (next === 111 || next === 79) return this.readRadixNumber(8) // '0o', '0O' - octal number
322 if (next === 98 || next === 66) return this.readRadixNumber(2) // '0b', '0B' - binary number
327 return this.readNumber(false)
331 return this.readString(code)
339 return this.readToken_slash()
342 return this.readToken_mult_modulo_exp(code)
345 return this.readToken_pipe_amp(code)
348 return this.readToken_caret()
351 return this.readToken_plus_min(code)
354 return this.readToken_lt_gt(code)
357 return this.readToken_eq_excl(code)
360 return this.finishOp(tt.prefix, 1)
363 this.raise(this.pos, "Unexpected character '" + codePointToString(code) + "'")
367 let str = this.input.slice(this.pos, this.pos + size)
368 this.pos += size
369 return this.finishToken(type, str)
389 let escaped, inClass, start = this.pos
391 if (this.pos >= this.input.length) this.raise(start, "Unterminated regular expression")
392 let ch = this.input.charAt(this.pos)
393 if (lineBreak.test(ch)) this.raise(start, "Unterminated regular expression")
400 ++this.pos
402 let content = this.input.slice(start, this.pos)
403 ++this.pos
406 let mods = this.readWord1()
410 if (this.options.ecmaVersion >= 6) validFlags = /^[gimuy]*$/
411 if (!validFlags.test(mods)) this.raise(start, "Invalid regular expression flag")
426 if (code > 0x10FFFF) this.raise(start + offset + 3, "Code point out of bounds")
439 tryCreateRegexp(tmp, tmpFlags, start, this)
440 // Get a regular expression object for this pattern-flag pair, or `null` in
444 return this.finishToken(tt.regexp, {pattern: content, flags: mods, value: value})
448 // were read, the integer value otherwise. When `len` is given, this
452 let start = this.pos, total = 0
454 let code = this.input.charCodeAt(this.pos), val
460 ++this.pos
463 if (this.pos === start || len != null && this.pos - start !== len) return null
469 this.pos += 2 // 0x
470 let val = this.readInt(radix)
471 if (val == null) this.raise(this.start + 2, "Expected number in radix " + radix)
472 …if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after n…
473 return this.finishToken(tt.num, val)
479 let start = this.pos, isFloat = false, octal = this.input.charCodeAt(this.pos) === 48
480 if (!startsWithDot && this.readInt(10) === null) this.raise(start, "Invalid number")
481 if (octal && this.pos == start + 1) octal = false
482 let next = this.input.charCodeAt(this.pos)
484 ++this.pos
485 this.readInt(10)
487 next = this.input.charCodeAt(this.pos)
490 next = this.input.charCodeAt(++this.pos)
491 if (next === 43 || next === 45) ++this.pos // '+-'
492 if (this.readInt(10) === null) this.raise(start, "Invalid number")
495 …if (isIdentifierStart(this.fullCharCodeAtPos())) this.raise(this.pos, "Identifier directly after n…
497 let str = this.input.slice(start, this.pos), val
500 else if (/[89]/.test(str) || this.strict) this.raise(start, "Invalid number")
502 return this.finishToken(tt.num, val)
508 let ch = this.input.charCodeAt(this.pos), code
511 if (this.options.ecmaVersion < 6) this.unexpected()
512 let codePos = ++this.pos
513 code = this.readHexChar(this.input.indexOf('}', this.pos) - this.pos)
514 ++this.pos
515 if (code > 0x10FFFF) this.raise(codePos, "Code point out of bounds")
517 code = this.readHexChar(4)
530 let out = "", chunkStart = ++this.pos
532 if (this.pos >= this.input.length) this.raise(this.start, "Unterminated string constant")
533 let ch = this.input.charCodeAt(this.pos)
536 out += this.input.slice(chunkStart, this.pos)
537 out += this.readEscapedChar(false)
538 chunkStart = this.pos
540 if (isNewLine(ch)) this.raise(this.start, "Unterminated string constant")
541 ++this.pos
544 out += this.input.slice(chunkStart, this.pos++)
545 return this.finishToken(tt.string, out)
551 let out = "", chunkStart = this.pos
553 if (this.pos >= this.input.length) this.raise(this.start, "Unterminated template")
554 let ch = this.input.charCodeAt(this.pos)
555 if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) { // '`', '${'
556 if (this.pos === this.start && this.type === tt.template) {
558 this.pos += 2
559 return this.finishToken(tt.dollarBraceL)
561 ++this.pos
562 return this.finishToken(tt.backQuote)
565 out += this.input.slice(chunkStart, this.pos)
566 return this.finishToken(tt.template, out)
569 out += this.input.slice(chunkStart, this.pos)
570 out += this.readEscapedChar(true)
571 chunkStart = this.pos
573 out += this.input.slice(chunkStart, this.pos)
574 ++this.pos
577 if (this.input.charCodeAt(this.pos) === 10) ++this.pos
585 if (this.options.locations) {
586 ++this.curLine
587 this.lineStart = this.pos
589 chunkStart = this.pos
591 ++this.pos
599 let ch = this.input.charCodeAt(++this.pos)
600 ++this.pos
604 case 120: return String.fromCharCode(this.readHexChar(2)) // 'x'
605 case 117: return codePointToString(this.readCodePoint()) // 'u'
610 case 13: if (this.input.charCodeAt(this.pos) === 10) ++this.pos // '\r\n'
612 if (this.options.locations) { this.lineStart = this.pos; ++this.curLine }
616 let octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0]
622 if (octalStr !== "0" && (this.strict || inTemplate)) {
623 this.raise(this.pos - 2, "Octal literal in strict mode")
625 this.pos += octalStr.length - 1
635 let codePos = this.pos
636 let n = this.readInt(16, len)
637 if (n === null) this.raise(codePos, "Bad character escape sequence")
641 // Read an identifier, and return it as a string. Sets `this.containsEsc`
648 this.containsEsc = false
649 let word = "", first = true, chunkStart = this.pos
650 let astral = this.options.ecmaVersion >= 6
651 while (this.pos < this.input.length) {
652 let ch = this.fullCharCodeAtPos()
654 this.pos += ch <= 0xffff ? 1 : 2
656 this.containsEsc = true
657 word += this.input.slice(chunkStart, this.pos)
658 let escStart = this.pos
659 if (this.input.charCodeAt(++this.pos) != 117) // "u"
660 this.raise(this.pos, "Expecting Unicode escape sequence \\uXXXX")
661 ++this.pos
662 let esc = this.readCodePoint()
664 this.raise(escStart, "Invalid Unicode escape")
666 chunkStart = this.pos
672 return word + this.input.slice(chunkStart, this.pos)
679 let word = this.readWord1()
681 if (this.keywords.test(word)) {
682 if (this.containsEsc) this.raiseRecoverable(this.start, "Escape sequence in keyword " + word)
685 return this.finishToken(type, word)