Example #1
0
		public ExposableParseTreeNode Parse(string input)
		{
			_Scanner = new Scanner(input);
			ExposableParseTreeNode answer = Expression();
			if (answer == null)
				throw new ExpectedTokenParseException(ExpectedWhat, ButGotToken);
			if (!Scanner.AtEnd)
				throw new UnexpectedTokenParseException(Scanner.Next());
			return answer;
		}
Example #2
0
		public ExposableParseTreeNode Parse(string input)
		{
			_Scanner = new Scanner(input);
			ExposableParseTreeNode answer = ExpressionChain();
			if (answer == null)
				throw new ExpectedTokenParseException(LocationFromToken(ButGotToken), ExpectedWhat, ButGotToken);
			if (!Scanner.AtEnd)
			{
				Token x = Scanner.Next();
				throw new UnexpectedTokenParseException(LocationFromToken(x), x);
			}
			return answer;
		}
Example #3
0
		void Lex()
		{
			listBoxTokens.Items.Clear();
			Scanner scanner = new Scanner(textBoxInput.Text);
			Token token;
			while (true)
			{
				token = scanner.Next();
				if (token.Type == TokenType.TokenEndOfInput)
					break;
				string s = token.Type.ToString();
				if (token.Value != null)
					s += "(" + token.Value + ")";
				listBoxTokens.Items.Add(s);
			}
		}