MCPcopy
hub / github.com/meteor/meteor / Parser

Class Parser

tools/tests/apps/modules/imports/links/acorn/src/state.js:13–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11}
12
13export class Parser {
14 constructor(options, input, startPos) {
15 this.options = options = getOptions(options)
16 this.sourceFile = options.sourceFile
17 this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5])
18 let reserved = ""
19 if (!options.allowReserved) {
20 for (let v = options.ecmaVersion;; v--)
21 if (reserved = reservedWords[v]) break
22 if (options.sourceType == "module") reserved += " await"
23 }
24 this.reservedWords = keywordRegexp(reserved)
25 let reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict
26 this.reservedWordsStrict = keywordRegexp(reservedStrict)
27 this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind)
28 this.input = String(input)
29
30 // Used to signal to callers of `readWord1` whether the word
31 // contained any escape sequences. This is needed because words with
32 // escape sequences must not be interpreted as keywords.
33 this.containsEsc = false
34
35 // Load plugins
36 this.loadPlugins(options.plugins)
37
38 // Set up token state
39
40 // The current position of the tokenizer in the input.
41 if (startPos) {
42 this.pos = startPos
43 this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1
44 this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length
45 } else {
46 this.pos = this.lineStart = 0
47 this.curLine = 1
48 }
49
50 // Properties of the current token:
51 // Its type
52 this.type = tt.eof
53 // For tokens that include more information than their type, the value
54 this.value = null
55 // Its start and end offset
56 this.start = this.end = this.pos
57 // And, if locations are used, the {line, column} object
58 // corresponding to those offsets
59 this.startLoc = this.endLoc = this.curPosition()
60
61 // Position information for the previous token
62 this.lastTokEndLoc = this.lastTokStartLoc = null
63 this.lastTokStart = this.lastTokEnd = this.pos
64
65 // The context stack is used to superficially track syntactic
66 // context to predict whether a regular expression is allowed in a
67 // given position.
68 this.context = this.initialContext()
69 this.exprAllowed = true
70

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…