license export class ParserError { public message : string ; constructor ( message , public input , public errLocation , public ctxLocation ? ) { this . message = `Parser Error: ${ message } ${ errLocation } [${ input }] in ${ ctxLocation }` ; } } export class ParseSpan { constructor ( public start , public end ) { } } export class AST { constructor ( public span ) { } visit ( visitor , context = null ) { return null ; } toString ( ) { return "AST" ; } } /**
 * Represents a quoted expression of the form:
 *
 * quote = prefix `:` uninterpretedExpression
 * prefix = identifier
 * uninterpretedExpression = arbitrary string
 *
 * A quoted expression is meant to be pre-processed by an AST transformer that
 * converts it into another AST that no longer contains quoted expressions.
 * It is meant to allow third-party developers to extend Angular template
 * expression language. The `uninterpretedExpression` part of the quote is
 * therefore not interpreted by the Angular's own expression parser.
 */ export class Quote extends AST { constructor ( span , public prefix , public uninterpretedExpression , public location ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitQuote ( this , context ) ; } toString ( ) { return "Quote" ; } } export class EmptyExpr extends AST { visit ( visitor , context = null ) { } } export class ImplicitReceiver extends AST { visit ( visitor , context = null ) { return visitor . visitImplicitReceiver ( this , context ) ; } } /**
 * Multiple expressions separated by a semicolon.
 */ export class Chain extends AST { constructor ( span , public expressions ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitChain ( this , context ) ; } } export class Conditional extends AST { constructor ( span , public condition , public trueExp , public falseExp ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitConditional ( this , context ) ; } } export class PropertyRead extends AST { constructor ( span , public receiver , public name ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitPropertyRead ( this , context ) ; } } export class PropertyWrite extends AST { constructor ( span , public receiver , public name , public value ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitPropertyWrite ( this , context ) ; } } export class SafePropertyRead extends AST { constructor ( span , public receiver , public name ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitSafePropertyRead ( this , context ) ; } } export class KeyedRead extends AST { constructor ( span , public obj , public key ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitKeyedRead ( this , context ) ; } } export class KeyedWrite extends AST { constructor ( span , public obj , public key , public value ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitKeyedWrite ( this , context ) ; } } export class BindingPipe extends AST { constructor ( span , public exp , public name , public args ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitPipe ( this , context ) ; } } export class LiteralPrimitive extends AST { constructor ( span , public value ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitLiteralPrimitive ( this , context ) ; } } export class LiteralArray extends AST { constructor ( span , public expressions ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitLiteralArray ( this , context ) ; } } export interface LiteralMapKey { key : string ; quoted : boolean ; } export class LiteralMap extends AST { constructor ( span , public keys , public values ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitLiteralMap ( this , context ) ; } } export class Interpolation extends AST { constructor ( span , public strings , public expressions ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitInterpolation ( this , context ) ; } } export class Binary extends AST { constructor ( span , public operation , public left , public right ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitBinary ( this , context ) ; } } export class PrefixNot extends AST { constructor ( span , public expression ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitPrefixNot ( this , context ) ; } } export class NonNullAssert extends AST { constructor ( span , public expression ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitNonNullAssert ( this , context ) ; } } export class MethodCall extends AST { constructor ( span , public receiver , public name , public args ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitMethodCall ( this , context ) ; } } export class SafeMethodCall extends AST { constructor ( span , public receiver , public name , public args ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitSafeMethodCall ( this , context ) ; } } export class FunctionCall extends AST { constructor ( span , public target , public args ) { super ( span ) ; } visit ( visitor , context = null ) { return visitor . visitFunctionCall ( this , context ) ; } } export class ASTWithSource extends AST { constructor ( public ast , public source , public location , public errors ) { super ( new ParseSpan ( 0 , source == null ? 0 : source . length ) ) ; } visit ( visitor , context = null ) { return this . ast . visit ( visitor , context ) ; } toString ( ) { return `${ this . source } in ${ this . location }` ; } } export class TemplateBinding { constructor ( public span , public key , public keyIsVar , public name , public expression ) { } } export interface AstVisitor { visitBinary ( ast , context ) : any ; visitChain ( ast , context ) : any ; visitConditional ( ast , context ) : any ; visitFunctionCall ( ast , context ) : any ; visitImplicitReceiver ( ast , context ) : any ; visitInterpolation ( ast , context ) : any ; visitKeyedRead ( ast , context ) : any ; visitKeyedWrite ( ast , context ) : any ; visitLiteralArray ( ast , context ) : any ; visitLiteralMap ( ast , context ) : any ; visitLiteralPrimitive ( ast , context ) : any ; visitMethodCall ( ast , context ) : any ; visitPipe ( ast , context ) : any ; visitPrefixNot ( ast , context ) : any ; visitNonNullAssert ( ast , context ) : any ; visitPropertyRead ( ast , context ) : any ; visitPropertyWrite ( ast , context ) : any ; visitQuote ( ast , context ) : any ; visitSafeMethodCall ( ast , context ) : any ; visitSafePropertyRead ( ast , context ) : any ; visit ? ( ast , context ? ) : any ; } export class RecursiveAstVisitor implements AstVisitor { visitBinary ( ast , context ) { ast . left . visit ( this ) ; ast . right . visit ( this ) ; return null ; } visitChain ( ast , context ) { return this . visitAll ( ast . expressions , context ) ; } visitConditional ( ast , context ) { ast . condition . visit ( this ) ; ast . trueExp . visit ( this ) ; ast . falseExp . visit ( this ) ; return null ; } visitPipe ( ast , context ) { ast . exp . visit ( this ) ; this . visitAll ( ast . args , context ) ; return null ; } visitFunctionCall ( ast , context ) { ast . target ! . visit ( this ) ; this . visitAll ( ast . args , context ) ; return null ; } visitImplicitReceiver ( ast , context ) { return null ; } visitInterpolation ( ast , context ) { return this . visitAll ( ast . expressions , context ) ; } visitKeyedRead ( ast , context ) { ast . obj . visit ( this ) ; ast . key . visit ( this ) ; return null ; } visitKeyedWrite ( ast , context ) { ast . obj . visit ( this ) ; ast . key . visit ( this ) ; ast . value . visit ( this ) ; return null ; } visitLiteralArray ( ast , context ) { return this . visitAll ( ast . expressions , context ) ; } visitLiteralMap ( ast , context ) { return this . visitAll ( ast . values , context ) ; } visitLiteralPrimitive ( ast , context ) { return null ; } visitMethodCall ( ast , context ) { ast . receiver . visit ( this ) ; return this . visitAll ( ast . args , context ) ; } visitPrefixNot ( ast , context ) { ast . expression . visit ( this ) ; return null ; } visitNonNullAssert ( ast , context ) { ast . expression . visit ( this ) ; return null ; } visitPropertyRead ( ast , context ) { ast . receiver . visit ( this ) ; return null ; } visitPropertyWrite ( ast , context ) { ast . receiver . visit ( this ) ; ast . value . visit ( this ) ; return null ; } visitSafePropertyRead ( ast , context ) { ast . receiver . visit ( this ) ; return null ; } visitSafeMethodCall ( ast , context ) { ast . receiver . visit ( this ) ; return this . visitAll ( ast . args , context ) ; } visitAll ( asts , context ) { asts . forEach ( ast => ast . visit ( this , context ) ) ; return null ; } visitQuote ( ast , context ) { return null ; } } export class AstTransformer implements AstVisitor { visitImplicitReceiver ( ast , context ) { return ast ; } visitInterpolation ( ast , context ) { return new Interpolation ( ast . span , ast . strings , this . visitAll ( ast . expressions ) ) ; } visitLiteralPrimitive ( ast , context ) { return new LiteralPrimitive ( ast . span , ast . value ) ; } visitPropertyRead ( ast , context ) { return new PropertyRead ( ast . span , ast . receiver . visit ( this ) , ast . name ) ; } visitPropertyWrite ( ast , context ) { return new PropertyWrite ( ast . span , ast . receiver . visit ( this ) , ast . name , ast . value . visit ( this ) ) ; } visitSafePropertyRead ( ast , context ) { return new SafePropertyRead ( ast . span , ast . receiver . visit ( this ) , ast . name ) ; } visitMethodCall ( ast , context ) { return new MethodCall ( ast . span , ast . receiver . visit ( this ) , ast . name , this . visitAll ( ast . args ) ) ; } visitSafeMethodCall ( ast , context ) { return new SafeMethodCall ( ast . span , ast . receiver . visit ( this ) , ast . name , this . visitAll ( ast . args ) ) ; } visitFunctionCall ( ast , context ) { return new FunctionCall ( ast . span , ast . target ! . visit ( this ) , this . visitAll ( ast . args ) ) ; } visitLiteralArray ( ast , context ) { return new LiteralArray ( ast . span , this . visitAll ( ast . expressions ) ) ; } visitLiteralMap ( ast , context ) { return new LiteralMap ( ast . span , ast . keys , this . visitAll ( ast . values ) ) ; } visitBinary ( ast , context ) { return new Binary ( ast . span , ast . operation , ast . left . visit ( this ) , ast . right . visit ( this ) ) ; } visitPrefixNot ( ast , context ) { return new PrefixNot ( ast . span , ast . expression . visit ( this ) ) ; } visitNonNullAssert ( ast , context ) { return new NonNullAssert ( ast . span , ast . expression . visit ( this ) ) ; } visitConditional ( ast , context ) { return new Conditional ( ast . span , ast . condition . visit ( this ) , ast . trueExp . visit ( this ) , ast . falseExp . visit ( this ) ) ; } visitPipe ( ast , context ) { return new BindingPipe ( ast . span , ast . exp . visit ( this ) , ast . name , this . visitAll ( ast . args ) ) ; } visitKeyedRead ( ast , context ) { return new KeyedRead ( ast . span , ast . obj . visit ( this ) , ast . key . visit ( this ) ) ; } visitKeyedWrite ( ast , context ) { return new KeyedWrite ( ast . span , ast . obj . visit ( this ) , ast . key . visit ( this ) , ast . value . visit ( this ) ) ; } visitAll ( asts ) { const res = new Array ( asts . length ) ; for ( let i = 0 ; i < asts . length ; ++ i ) { res [ i ] = asts [ i ] . visit ( this ) ; } return res ; } visitChain ( ast , context ) { return new Chain ( ast . span , this . visitAll ( ast . expressions ) ) ; } visitQuote ( ast , context ) { return new Quote ( ast . span , ast . prefix , ast . uninterpretedExpression , ast . location ) ; } }