Пример #1
0
 void Start()
 {
     Debug.Log("onStart");
       _parser = new Parser(this); // Important to instate it here, not in Awake(). Else vessel is not created yet.
       RenderingManager.AddToPostDrawQueue(0, onDraw);
       Debug.Log("onStartEnd");
 }
Пример #2
0
	public static Lexicon generateToken(float input, Parser parser) {
	  return classify(delimit(input.ToString()).Dequeue(), parser);
	}
Пример #3
0
	public static Lexicon generateToken(string input, Parser parser) {
	  return classify(delimit(input).Dequeue(), parser);
	}
Пример #4
0
	//	Queue<Lexicon> _lexed_input;

	/*	public Lexer(Parser parser) {
	  _parser = parser;
	  _lexed_input = new Queue<Lexicon>();
	}

	//  Used for Unit Testing
	public Lexer() {
	  _lexed_input = new Queue<Lexicon>();
	}
*/

	public static Queue<Lexicon> tokenize(string input, Parser parser) {
	  return classify(delimit(input), parser);
	}
Пример #5
0
	private static Lexicon classify(string symbol, Parser parser) {
	  Queue<string> input = new Queue<string>();
	  input.Enqueue(symbol);
	  return classify(input, parser).Dequeue();
	}
Пример #6
0
	private static Queue<Lexicon> classify(Queue<string> input, Parser parser) {
	  int val;
	  Queue<Lexicon> result = new Queue<Lexicon>();
	  foreach (string symbol in input) {
		if (Int32.TryParse(symbol, out val)) {
		  result.Enqueue(new Number(val));

		  // Not a number
		} else {
		  if (symbol[0] == '"' && symbol.EndsWith("\"")) {
			result.Enqueue(new ComplexAtom(symbol));
		  } else if (symbol[0] == '(' && symbol.EndsWith(")") ||
		             symbol[0] == '{' && symbol.EndsWith("}") ||
		             symbol[0] == '[' && symbol.EndsWith("]")) {
			result.Enqueue(new Function(symbol.Substring(1, symbol.Length - 2))); // not sure why -2
		  } else if (!(symbol.Contains("\"") ||
		             symbol.Contains("{") ||
		             symbol.Contains("}") ||
		             symbol.Contains("(") ||
		             symbol.Contains(")") ||
		             symbol.Contains("[") ||
		             symbol.Contains("]"))) {
			if (parser.commandExists(symbol)) {
			  result.Enqueue(new Command(symbol));
			} else if (symbol == "true") {
			  result.Enqueue(new Bool(true));
			} else if (symbol == "false") {
			  result.Enqueue(new Bool(false));
			} else {
			  result.Enqueue(new Atom(symbol));
			}
		  } else {
			result.Enqueue(new Error("Syntax error")); 
		  }
		}
	  }
	  return result;
	}