예제 #1
0
	public void Parse(FGTextBuffer.FormatedLine[] lines, string bufferName)
	{
	//	var s = new Stopwatch();
	//	s.Start();

		//FGGramar.GoalDebugger.debug = new StringBuilder();

		var scanner = new Scanner(this, lines, bufferName);
		try
		{
			/*ParseTree parseTree =*/ parser.ParseAll(scanner);
		//	Debug.Log(parseTree);
		}
		catch (Exception e)
		{
			Debug.LogError("Parsing crashed at line: " + scanner.CurrentLine() + ", token " + scanner.CurrentTokenIndex() + " with:\n    " + e + " at " + e.StackTrace);
			Debug.Log("Current token: " + scanner.Current.tokenKind + " '" + scanner.Current.text + "'");
		}

	//	Debug.Log(FGGramar.GoalDebugger.debug.ToString());

	//	s.Stop();
	//	Debug.Log("Parsing " + System.IO.Path.GetFileName(bufferName) + " (" + lines.Length + " lines) took " + s.ElapsedMilliseconds + " ms.");

		//var sb = new StringBuilder();
		//foreach (var node in scanner.numLookaheads.Keys)
		//    sb.AppendLine(node + ": " + scanner.numLookaheads[node] + " times in " + scanner.timeLookaheads[node] + " ticks (" + scanner.timeLookaheads[node] * 1000 / Stopwatch.Frequency + " ms)");
		//Debug.Log(sb);
	}