MCPcopy
hub / github.com/meteor/meteor / LooseParser

Class LooseParser

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

Source from the content-addressed store, hash-verified

6export const pluginsLoose = {}
7
8export class LooseParser {
9 constructor(input, options = {}) {
10 this.toks = tokenizer(input, options)
11 this.options = this.toks.options
12 this.input = this.toks.input
13 this.tok = this.last = {type: tt.eof, start: 0, end: 0}
14 this.tok.validateRegExpFlags = noop
15 this.tok.validateRegExpPattern = noop
16 if (this.options.locations) {
17 let here = this.toks.curPosition()
18 this.tok.loc = new SourceLocation(this.toks, here, here)
19 }
20 this.ahead = [] // Tokens ahead
21 this.context = [] // Indentation contexted
22 this.curIndent = 0
23 this.curLineStart = 0
24 this.nextLineStart = this.lineEnd(this.curLineStart) + 1
25 this.inAsync = false
26 // Load plugins
27 this.options.pluginsLoose = options.pluginsLoose || {}
28 this.loadPlugins(this.options.pluginsLoose)
29 }
30
31 startNode() {
32 return new Node(this.toks, this.tok.start, this.options.locations ? this.tok.loc.start : null)
33 }
34
35 storeCurrentPos() {
36 return this.options.locations ? [this.tok.start, this.tok.loc.start] : this.tok.start
37 }
38
39 startNodeAt(pos) {
40 if (this.options.locations) {
41 return new Node(this.toks, pos[0], pos[1])
42 } else {
43 return new Node(this.toks, pos)
44 }
45 }
46
47 finishNode(node, type) {
48 node.type = type
49 node.end = this.last.end
50 if (this.options.locations)
51 node.loc.end = this.last.loc.end
52 if (this.options.ranges)
53 node.range[1] = this.last.end
54 return node
55 }
56
57 dummyNode(type) {
58 let dummy = this.startNode()
59 dummy.type = type
60 dummy.end = dummy.start
61 if (this.options.locations)
62 dummy.loc.end = dummy.loc.start
63 if (this.options.ranges)
64 dummy.range[1] = dummy.start
65 this.last = {type: tt.name, start: dummy.start, end: dummy.start, loc: dummy.loc}

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…