Esempio n. 1
0
        public void TestParseExpression()
        {
            var main = new Interpreter.Sequence();

            for (int i = 0; i < testExpressions.Length; ++i)
            {
                Assert.AreEqual(resultExpressions[i], main.Expression(testExpressions[i]));
            }
        }
Esempio n. 2
0
        public static void CombineWith(Interpreter.Sequence receiver, string line, BinaryOperation Combine)
        {
            string left = "", op = "", right = "";

            if (Interpreter.Sequence.SplitTrinomial(ref left, ref op, ref right, line, Operators.assignops, Patterns.getbinaryop))
            {
                if (Operators.right_to_left.Contains(op))
                {
                    receiver.ParseLeftValueExpression(left, Combine(receiver.Expression(left), receiver.Expression(right)));
                }
                else if (Operators.left_to_right.Contains(op))
                {
                    receiver.ParseLeftValueExpression(right, Combine(receiver.Expression(right), receiver.Expression(left)));
                }
            }
            else
            {
                throw new FormatException("Not a valid assign-statement.");
            }
        }
Esempio n. 3
0
 public static void ReturnValue(Interpreter.Sequence receiver, string line)
 {
     throw new Return(receiver.Expression(line));
 }
Esempio n. 4
0
 public static void ErrorLine(Interpreter.Sequence receiver, string line)
 {
     Console.Error.WriteLine(receiver.Expression(line));
 }
Esempio n. 5
0
 public static void OutputLine(Interpreter.Sequence receiver, string line)
 {
     Console.WriteLine(String.IsNullOrWhiteSpace(line) ? "" : receiver.Expression(line));
 }
Esempio n. 6
0
 public static void Output(Interpreter.Sequence receiver, string line)
 {
     Console.Write(receiver.Expression(line));
 }
Esempio n. 7
0
 public static void Decrement(Interpreter.Sequence receiver, string line)
 {
     receiver.ParseLeftValueExpression(line, Algorithms.Arithmetic.Difference(receiver.Expression(line), 1L));
 }
Esempio n. 8
0
//      public static void Declare
//
//                  ( Interpreter.Sequence receiver,
//                    string line,
//                    string key,
//                    bool read,
//                    bool write,
//                    Dictionary<string, Named> table = null,
//                    string typename = "",
//                    string expression = "" )
//      {
//          object payload = String.IsNullOrWhiteSpace(expression) ? Value.NOVALUE : receiver.Expression(expression);
//
//          if (String.IsNullOrWhiteSpace(typename))
//          {
//              if (table == null)
//              {
//                  AddDynamicNamedValue(receiver.name_table, key, new Named.Value(payload, read, write), line);
//              }
//              else
//              {
//                  AddNonStandardNamedValue(receiver.name_table, key, new Named.Reference(table, payload, read, write), line);
//              }
//          }
//          else
//          {
//              if (table == null)
//              {
//                  AddNonStandardNamedValue(receiver.name_table, key, new Named.Static.Value(typename, payload, read, write), line);
//              }
//              else
//              {
//                  AddNonStandardNamedValue(receiver.name_table, key, new Named.Static.Reference(typename, table, payload, read, write), line);
//              }
//          }
//      }

        public static void Declare

            (Interpreter.Sequence receiver,
            string line,
            string key,
            bool read,
            bool write,
            Dictionary <string, Named> table = null,
            string typename   = "",
            string expression = "")
        {
            if (String.IsNullOrWhiteSpace(typename))
            {
                if (table == null)
                {
                    object payload = String.IsNullOrWhiteSpace(expression) ? Value.NOVALUE : receiver.Expression(expression);

                    AddDynamicNamedValue(receiver.Names, key, new Named.Value(payload, read, write), line);
                }
                else
                {
                    AddNonStandardNamedValue(receiver.Names, key, new Named.Reference(table, expression, read, write), line);
                }
            }
            else
            {
                if (table == null)
                {
                    object payload = String.IsNullOrWhiteSpace(expression) ? Value.NOVALUE : receiver.Expression(expression);

                    AddNonStandardNamedValue(receiver.Names, key, new Named.Static.Value(typename, payload, read, write), line);
                }
                else
                {
                    AddNonStandardNamedValue(receiver.Names, key, new Named.Static.Reference(typename, table, expression, read, write), line);
                }
            }
        }