/// <summary> /// Parses the source text into an abstract syntax tree. /// </summary> public override void Parse() { using (var lexer = new Lexer(this.Engine, this.Source)) { var parser = new Parser(this.Engine, lexer, this.InitialScope, this.Options, CodeContext.Global); this.AbstractSyntaxTree = parser.Parse(); this.StrictMode = parser.StrictMode; this.MethodOptimizationHints = parser.MethodOptimizationHints; } }
/// <summary> /// Parses the source text into an abstract syntax tree. /// </summary> public override void Parse() { var lexer = new Lexer(this.Engine, this.Source); var parser = new Parser(this.Engine, lexer, this.InitialScope, this.Options, CodeContext.Eval); // If the eval() is running strict mode, create a new scope. parser.DirectivePrologueProcessedCallback = parser2 => { if (parser2.StrictMode == true) parser2.InitialScope = parser2.Scope = DeclarativeScope.CreateEvalScope(parser2.Scope); }; this.AbstractSyntaxTree = parser.Parse(); this.StrictMode = parser.StrictMode; this.InitialScope = parser.Scope; this.MethodOptimizationHints = parser.MethodOptimizationHints; }
/// <summary> /// Parses the source text into an abstract syntax tree. /// </summary> /// <returns> The root node of the abstract syntax tree. </returns> public override void Parse() { if (this.BodyRoot != null) { this.AbstractSyntaxTree = this.BodyRoot; } else { using (var lexer = new Lexer(this.Engine, this.Source)) { var parser = new Parser(this.Engine, lexer, this.InitialScope, this.Options, CodeContext.Function); this.AbstractSyntaxTree = parser.Parse(); this.StrictMode = parser.StrictMode; this.MethodOptimizationHints = parser.MethodOptimizationHints; } Validate(); } }