@@ -48,6 +48,13 @@ var _implicitReceiver = new ImplicitReceiver();
48
48
// TODO(tbosch): Cannot make this const/final right now because of the transpiler...
49
49
var INTERPOLATION_REGEXP = / \{ \{ ( .* ?) \} \} / g;
50
50
51
+ class ParseException extends BaseException {
52
+ constructor ( message : string , input : string , errLocation : string , ctxLocation ?: any ) {
53
+ super ( `Parser Error: ${ message } ${ errLocation } [${ input } ] in ${ ctxLocation } ` , null , null ,
54
+ ctxLocation ) ;
55
+ }
56
+ }
57
+
51
58
@Injectable ( )
52
59
export class Parser {
53
60
_reflector : Reflector ;
@@ -88,14 +95,17 @@ export class Parser {
88
95
var expressions = [ ] ;
89
96
90
97
for ( var i = 0 ; i < parts . length ; i ++ ) {
91
- var part = parts [ i ] ;
98
+ var part : string = parts [ i ] ;
92
99
if ( i % 2 === 0 ) {
93
100
// fixed string
94
101
strings . push ( part ) ;
95
- } else {
102
+ } else if ( part . trim ( ) . length > 0 ) {
96
103
var tokens = this . _lexer . tokenize ( part ) ;
97
104
var ast = new _ParseAST ( input , location , tokens , this . _reflector , false ) . parseChain ( ) ;
98
105
expressions . push ( ast ) ;
106
+ } else {
107
+ throw new ParseException ( 'Blank expressions are not allowed in interpolated strings' , input ,
108
+ '' , location ) ;
99
109
}
100
110
}
101
111
return new ASTWithSource ( new Interpolation ( strings , expressions ) , input , location ) ;
@@ -596,8 +606,7 @@ export class _ParseAST {
596
606
var location = ( index < this . tokens . length ) ? `at column ${ this . tokens [ index ] . index + 1 } in` :
597
607
`at the end of the expression` ;
598
608
599
- throw new BaseException (
600
- `Parser Error: ${ message } ${ location } [${ this . input } ] in ${ this . location } ` ) ;
609
+ throw new ParseException ( message , this . input , location , this . location ) ;
601
610
}
602
611
}
603
612
0 commit comments