private static Factor ParseOperand(Token token, Dictionary<string, Expression> variableMap)
		{
			switch (token.Type)
			{
				case TokenType.Integer:
					return Factor.GetIntegerFactor(token);
				case TokenType.Float:
					return Factor.GetFloatFactor(token);
				case TokenType.Letter:
					return new AlphabeticFactor(token.Value, variableMap);
				case TokenType.String:
					return new StringFactor(token.Value);
			}

			throw new SyntaxErrorException("Couldn't parse operand {0}", token.Value);
		}
示例#2
0
		internal static NumericFactor GetIntegerFactor(Token token)
		{
			var stringVal = token.Value.Replace("⁻", "-");
			return new NumericFactor(new Integer(int.Parse(stringVal)));
		}
		private static bool IsImpliedMultiplication(Token left, Token right)
		{
			return
				(left.Type.IsOperand() && right.Type == TokenType.OpenParenthesis) ||
				(left.Type == TokenType.CloseParenthesis && right.Type.IsOperand()) ||
				(left.Type == TokenType.CloseParenthesis && right.Type == TokenType.OpenParenthesis) ||
				(left.Type.IsOperand() && right.Type == TokenType.Function && FunctionRepository.Get(right.Value).FixType == FixType.PostFix) ||
				(left.Type.IsOperand() && right.Type.IsOperand());
		}
示例#4
0
		internal static NumericFactor GetFloatFactor(Token token)
		{
			var stringVal = token.Value.Replace("⁻", "-");
			return new NumericFactor(new Float(double.Parse(stringVal)));
		}