react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / node_modules / syntax-error / node_modules / acorn / src / node.js
80744 viewsimport {Parser} from "./state"1import {SourceLocation} from "./location"23// Start an AST node, attaching a start offset.45const pp = Parser.prototype67export class Node {}89pp.startNode = function() {10let node = new Node11node.start = this.start12if (this.options.locations)13node.loc = new SourceLocation(this, this.startLoc)14if (this.options.directSourceFile)15node.sourceFile = this.options.directSourceFile16if (this.options.ranges)17node.range = [this.start, 0]18return node19}2021pp.startNodeAt = function(pos, loc) {22let node = new Node23node.start = pos24if (this.options.locations)25node.loc = new SourceLocation(this, loc)26if (this.options.directSourceFile)27node.sourceFile = this.options.directSourceFile28if (this.options.ranges)29node.range = [pos, 0]30return node31}3233// Finish an AST node, adding `type` and `end` properties.3435pp.finishNode = function(node, type) {36node.type = type37node.end = this.lastTokEnd38if (this.options.locations)39node.loc.end = this.lastTokEndLoc40if (this.options.ranges)41node.range[1] = this.lastTokEnd42return node43}4445// Finish node at given position4647pp.finishNodeAt = function(node, type, pos, loc) {48node.type = type49node.end = pos50if (this.options.locations)51node.loc.end = loc52if (this.options.ranges)53node.range[1] = pos54return node55}565758