8
8
* Or gives undesired access to variables likes document or window? *
9
9
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
10
11
- var $parseMinErr = function ( ...args ) {
12
- console . error ( args ) ;
13
- throw "ERROR" ;
11
+ var $parseMinErr = function ( error , template , ...templateArgs ) {
12
+ var errRegExp = new RegExp ( '[\\s\\S]*' , 'g' ) ;
13
+
14
+ var message = template . replace ( / \{ \d + \} / g, function ( match ) {
15
+ var index = + match . slice ( 1 , - 1 ) ;
16
+
17
+ return templateArgs [ index ] ;
18
+ } ) ;
19
+
20
+ throw new Error ( error + " " + message ) ;
14
21
} ;
15
22
16
23
var objectValueOf = { } . constructor . prototype . valueOf ;
@@ -33,6 +40,12 @@ function getStringValue(name) {
33
40
return name + '' ;
34
41
}
35
42
43
+ var LITERALS = {
44
+ 'true' : true ,
45
+ 'false' : false ,
46
+ 'null' : null ,
47
+ 'undefined' : undefined
48
+ } ;
36
49
37
50
var OPERATORS = { }
38
51
@@ -409,7 +422,9 @@ AST.prototype = {
409
422
} else if ( this . expect ( '{' ) ) {
410
423
primary = this . object ( ) ;
411
424
} else if ( this . selfReferential . hasOwnProperty ( this . peek ( ) . text ) ) {
412
- primary = copy ( this . selfReferential [ this . consume ( ) . text ] ) ;
425
+ primary = Object . assign ( { } , this . selfReferential [ this . consume ( ) . text ] ) ;
426
+ } else if ( LITERALS . hasOwnProperty ( this . peek ( ) . text ) ) {
427
+ primary = { type : AST . Literal , value : LITERALS [ this . consume ( ) . text ] } ;
413
428
} else if ( this . peek ( ) . identifier ) {
414
429
primary = this . identifier ( ) ;
415
430
} else if ( this . peek ( ) . constant ) {
@@ -1225,4 +1240,4 @@ function $ParseProvider() {
1225
1240
}
1226
1241
}
1227
1242
1228
- export default $ParseProvider ;
1243
+ module . exports = $ParseProvider ;
0 commit comments