Exemplo n.º 1
0
 /// <summary>
 /// There are various combinations which we don't want to bother executing.
 /// These include:
 /// Certain pairs we ignore - either pointless (e.g "po"), redundant (e.g. "cp" is better expressed as '2t'), or just nasty (e.g "FF").
 /// Certain combinations countain pointless leading chars which have no useful effect on the final result (e.g. "ppp28:tnm" is basically the same as "8:2tnm")
 /// Ends in a number - little more than a guess
 /// </summary>
 public static bool IsGoodGusl(string gusl)
 {
     return(!(gusl.Any(c => !GusLAtoms.Contains(c)) ||
              (gusl.Length > 1 && '1' <= gusl.Last() && '@' >= gusl.Last()) ||
              ContainsBadPairs(gusl) ||
              ContainsUnimportandLeadingOps(gusl)));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Process the specified GusL atom.
        /// TODO - Check for overflows and handle internally
        /// e.g. "e4nmd" on "99 96 91 84 75"
        /// </summary>
        GusStatus Process(char op)
        {
            if (!GusLAtoms.Contains(op))
            {
                LastError = string.Format("Only valid GusL atoms are allowed: {0}.", string.Join(", ", GusLAtoms));
                return(GusStatus.Error);
            }

            if (_verbose)
            {
                Console.WriteLine("Evaluating: {0}", op);
            }

            if (op >= '1' && op <= '@')
            {
                _stack.Push(op - '1' + 1);
                return(GusStatus.OK);
            }
            return((GusStatus)GetMethodInfo(op).Invoke(this, null));
        }