Esempio n. 1
0
 public Interpreter(Parser parser, ScopeManager scopeManager, SystemFunctionTable systemFunctionTable,
                    CustomFunctionTable customFunctionTable)
 {
     _parser              = parser ?? throw new ArgumentNullException(nameof(parser));
     _scopeManager        = scopeManager ?? throw new ArgumentNullException(nameof(scopeManager));
     _systemFunctionTable = systemFunctionTable ?? throw new ArgumentNullException(nameof(systemFunctionTable));
     _customFunctionTable = customFunctionTable ?? throw new ArgumentNullException(nameof(customFunctionTable));
 }
Esempio n. 2
0
        static void Main()
        {
            var customFunctionTable = new CustomFunctionTable();
            var scopeManager        = new ScopeManager(new Scope());
            var sysFuncTable        = new SystemFunctionTable(scopeManager, customFunctionTable);

            var lexer  = new Lexer(Code.ToCharArray());
            var parser = new Parser(lexer, sysFuncTable);

            //new Interpreter(lexer, new Scope()).Run();

            new Interpreter(parser, scopeManager, sysFuncTable, customFunctionTable).Execute();
        }
Esempio n. 3
0
 public SystemFunctionTable(ScopeManager scopeManager, CustomFunctionTable customFunctionTable)
 {
     _functions = new Dictionary <string, Function>
     {
         { "+", new AddFunction(scopeManager) },
         { "-", new SubtractFunction(scopeManager) },
         { "*", new MultiplyFunction(scopeManager) },
         { "/", new DivideFunction(scopeManager) },
         { "=", new EqualFunction(scopeManager) },
         { "!=", new NotEqualFunction(scopeManager) },
         { ">", new GreaterThanFunction(scopeManager) },
         { "<", new LessThanFunction(scopeManager) },
         { "print", new PrintFunction(scopeManager) },
         { "concat", new ConcatFunction(scopeManager) },
         { "def", new DefFunction(scopeManager) },
         { "func", new DefFuncFunction(scopeManager, customFunctionTable) },
         { "call", new CallFunction(scopeManager) },
         { "if", new IfFunction(scopeManager) },
         { "list", new ListFunction(scopeManager) },
         { "params", new ParamsFunction(scopeManager) },
         { "return", new ReturnFunction(scopeManager) }
     };
 }