var NgParser = (function() { // .... hundreds of lines of borrowed Angular.js code .... // ------------------------------------------------------------------------------- // // ------------------------------------------------------------------------------- // var lexer = null; var astCreator = null; var astCompiler = null; /** * I parse the given expression into an evaluator function. */ function parse( expression ) { lexer = ( lexer || new Lexer() ); astCreator = ( astCreator || new AST( lexer ) ); astCompiler = ( astCompiler || new ASTInterpreter() ); return astCompiler.compile( astCreator.ast( expression ) ); } return { Lexer: Lexer, AST: AST, ASTInterpreter: ASTInterpreter, parse: parse }; })();