public void Execute(UltimateVirtualMachine vm, List<Token> parameters)
 {
     if (vm.Variables.ContainsKey(parameters[1].Value))
     {
         Console.WriteLine(parameters[1].Value + " was already declared!");
     }
     else
     {
         vm.Variables.Add(parameters[1].Value, new Variable() { Value = "", type = parameters[0].Type });
     }
 }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            var lines = File.ReadAllLines (Environment.CurrentDirectory + @"/Language.txt");
            Tokenizer tokenizer = new Tokenizer ();
            LinkedList<Token> tokens = tokenizer.Tokenize(lines);

            foreach (var token in tokens) {
            //	Console.WriteLine (token.ToString ());
            }
            //Console.ReadKey();

            NodeCompiler compiler = new NodeCompiler ();
            DoubleLinkedList nodes = compiler.CompileLinkedList (tokens);

            UltimateVirtualMachine vm = new UltimateVirtualMachine ();
            vm.Run (nodes);
        }
 public void Execute(UltimateVirtualMachine vm, List<Token> parameters)
 {
     foreach (Token token in parameters) {
         string valueToPrint = "";
         switch (token.Type) {
         case TokenEnumeration.QuotedString:
             valueToPrint = token.Value;
             break;
         case TokenEnumeration.Number:
             valueToPrint = token.Value;
             break;
         case TokenEnumeration.Identifier:
             if (vm.Variables.ContainsKey (token.Value)) {
                 valueToPrint = vm.Variables.GetValue (token.Value).Value.ToString ();
             }
             break;
         }
         Console.Write (valueToPrint);
     }
     Console.WriteLine ();
 }
 public NextNodeVisitor(UltimateVirtualMachine vm)
 {
     VM = vm;
 }
 public void Execute(UltimateVirtualMachine vm, List<Token> parameters)
 {
     vm.ReturnValue.Value = parameters[0].Value;
     vm.ReturnValue.type = parameters[0].Type;
 }