Exemplo n.º 1
0
 public void Run(Scope previous_scope, ContextOptions options)
 {
     if (options.WRITE_AST)
     {
         Expression    tree = _parse_result.RootExpression;
         StringBuilder sb   = new StringBuilder();
         tree.Print(new Expression.TreeParams(default, write_line: line => sb.Append(line).Append("\n")));
Exemplo n.º 2
0
        public string Eval(Scope previous_scope, ContextOptions options, List <string> diagnostics = null)
        {
            Expression tree = _parse_result.RootExpression;

            tree.Print();
            ScriptScope script_scope = new ScriptScope(previous_scope, _script);

            if (_parse_result.Diagnostics.Length != 0)
            {
                if (diagnostics != null)
                {
                    foreach (var diag in _parse_result.Diagnostics)
                    {
                        diagnostics.Add(diag.ToString());
                    }
                }
                else
                {
                    throw new Exception(_parse_result.Diagnostics.Join("\n"));
                }
            }

            string res = Interpreters.Execute(tree, script_scope).ResultValue.GetStringValue();

            if (options.DEBUG_EXECUTION)
            {
                Console.ReadLine();
            }

            return(res);
        }
Exemplo n.º 3
0
 public Context(ContextOptions options, IParser parser)
 {
     Options   = options ?? new ContextOptions();
     Parser    = parser;
     RootScope = new RootScope(this);
 }