@@ -123,7 +123,7 @@ const Position = require("./ast/position");
123
123
* @property {Boolean } withPositions - Should locate any node (by default false)
124
124
* @property {Boolean } withSource - Should extract the node original code (by default false)
125
125
*/
126
- const AST = function ( withPositions , withSource ) {
126
+ const AST = function ( withPositions , withSource ) {
127
127
this . withPositions = withPositions ;
128
128
this . withSource = withSource ;
129
129
} ;
@@ -135,7 +135,7 @@ const AST = function(withPositions, withSource) {
135
135
* @return {Position }
136
136
* @private
137
137
*/
138
- AST . prototype . position = function ( parser ) {
138
+ AST . prototype . position = function ( parser ) {
139
139
return new Position (
140
140
parser . lexer . yylloc . first_line ,
141
141
parser . lexer . yylloc . first_column ,
@@ -165,23 +165,23 @@ AST.precedence = {};
165
165
[ "!" ] ,
166
166
[ "instanceof" ] ,
167
167
[ "cast" , "silent" ] ,
168
- [ "**" ]
168
+ [ "**" ] ,
169
169
// TODO: [ (array)
170
170
// TODO: clone, new
171
- ] . forEach ( function ( list , index ) {
172
- list . forEach ( function ( operator ) {
171
+ ] . forEach ( function ( list , index ) {
172
+ list . forEach ( function ( operator ) {
173
173
AST . precedence [ operator ] = index + 1 ;
174
174
} ) ;
175
175
} ) ;
176
176
177
- AST . prototype . isRightAssociative = function ( operator ) {
177
+ AST . prototype . isRightAssociative = function ( operator ) {
178
178
return operator === "**" || operator === "??" ;
179
179
} ;
180
180
181
181
/**
182
182
* Change parent node informations after swapping childs
183
183
*/
184
- AST . prototype . swapLocations = function ( target , first , last , parser ) {
184
+ AST . prototype . swapLocations = function ( target , first , last , parser ) {
185
185
if ( this . withPositions ) {
186
186
target . loc . start = first . loc . start ;
187
187
target . loc . end = last . loc . end ;
@@ -197,7 +197,7 @@ AST.prototype.swapLocations = function(target, first, last, parser) {
197
197
/**
198
198
* Includes locations from first & last into the target
199
199
*/
200
- AST . prototype . resolveLocations = function ( target , first , last , parser ) {
200
+ AST . prototype . resolveLocations = function ( target , first , last , parser ) {
201
201
if ( this . withPositions ) {
202
202
if ( target . loc . start . offset > first . loc . start . offset ) {
203
203
target . loc . start = first . loc . start ;
@@ -217,7 +217,7 @@ AST.prototype.resolveLocations = function(target, first, last, parser) {
217
217
/**
218
218
* Check and fix precence, by default using right
219
219
*/
220
- AST . prototype . resolvePrecedence = function ( result , parser ) {
220
+ AST . prototype . resolvePrecedence = function ( result , parser ) {
221
221
let buffer , lLevel , rLevel ;
222
222
// handling precendence
223
223
if ( result . kind === "call" ) {
@@ -349,14 +349,14 @@ AST.prototype.resolvePrecedence = function(result, parser) {
349
349
* @param {Parser } parser - The parser instance (use for extracting locations)
350
350
* @return {Function }
351
351
*/
352
- AST . prototype . prepare = function ( kind , docs , parser ) {
352
+ AST . prototype . prepare = function ( kind , docs , parser ) {
353
353
let start = null ;
354
354
if ( this . withPositions || this . withSource ) {
355
355
start = this . position ( parser ) ;
356
356
}
357
357
const self = this ;
358
358
// returns the node
359
- const result = function ( ) {
359
+ const result = function ( ) {
360
360
let location = null ;
361
361
const args = Array . prototype . slice . call ( arguments ) ;
362
362
args . push ( docs ) ;
@@ -405,7 +405,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
405
405
}
406
406
AST . stack [ ++ AST . stackUid ] = {
407
407
position : start ,
408
- stack : new Error ( ) . stack . split ( "\n" ) . slice ( 3 , 5 )
408
+ stack : new Error ( ) . stack . split ( "\n" ) . slice ( 3 , 5 ) ,
409
409
} ;
410
410
result . stackUid = AST . stackUid ;
411
411
}
@@ -414,7 +414,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
414
414
* Sets a list of trailing comments
415
415
* @param {* } docs
416
416
*/
417
- result . setTrailingComments = function ( docs ) {
417
+ result . setTrailingComments = function ( docs ) {
418
418
if ( result . instance ) {
419
419
// already created
420
420
result . instance . setTrailingComments ( docs ) ;
@@ -426,7 +426,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
426
426
/**
427
427
* Release a node without using it on the AST
428
428
*/
429
- result . destroy = function ( target ) {
429
+ result . destroy = function ( target ) {
430
430
if ( docs ) {
431
431
// release current docs stack
432
432
if ( target ) {
@@ -446,7 +446,7 @@ AST.prototype.prepare = function(kind, docs, parser) {
446
446
return result ;
447
447
} ;
448
448
449
- AST . prototype . checkNodes = function ( ) {
449
+ AST . prototype . checkNodes = function ( ) {
450
450
const errors = [ ] ;
451
451
for ( const k in AST . stack ) {
452
452
if ( AST . stack . hasOwnProperty ( k ) ) {
@@ -560,8 +560,8 @@ AST.prototype.checkNodes = function() {
560
560
require ( "./ast/variadic" ) ,
561
561
require ( "./ast/while" ) ,
562
562
require ( "./ast/yield" ) ,
563
- require ( "./ast/yieldfrom" )
564
- ] . forEach ( function ( ctor ) {
563
+ require ( "./ast/yieldfrom" ) ,
564
+ ] . forEach ( function ( ctor ) {
565
565
AST . prototype [ ctor . kind ] = ctor ;
566
566
} ) ;
567
567
0 commit comments