protected virtual object EvalPair(ParseTree tree, params object[] paramlist)
 {
     throw new NotImplementedException();
 }
 protected virtual object EvalCoalesceExpression(ParseTree tree, params object[] paramlist)
 {
     throw new NotImplementedException();
 }
 protected virtual object EvalStart(ParseTree tree, params object[] paramlist)
 {
     return("Could not interpret input; no semantics implemented.");
 }
        /// <summary>
        /// this implements the evaluation functionality, cannot be used directly
        /// </summary>
        /// <param name="tree">the parsetree itself</param>
        /// <param name="paramlist">optional input parameters</param>
        /// <returns>a partial result of the evaluation</returns>
        internal object Eval(ParseTree tree, params object[] paramlist)
        {
            object Value = null;

            switch (Token.Type)
            {
            case TokenType.Start:
                Value = EvalStart(tree, paramlist);
                break;

            case TokenType.Expression:
                Value = EvalExpression(tree, paramlist);
                break;

            case TokenType.ConditionalExpression:
                Value = EvalConditionalExpression(tree, paramlist);
                break;

            case TokenType.CoalesceExpression:
                Value = EvalCoalesceExpression(tree, paramlist);
                break;

            case TokenType.OrExpression:
                Value = EvalOrExpression(tree, paramlist);
                break;

            case TokenType.AndExpression:
                Value = EvalAndExpression(tree, paramlist);
                break;

            case TokenType.NotExpression:
                Value = EvalNotExpression(tree, paramlist);
                break;

            case TokenType.Compare:
                Value = EvalCompare(tree, paramlist);
                break;

            case TokenType.Addition:
                Value = EvalAddition(tree, paramlist);
                break;

            case TokenType.Multiplication:
                Value = EvalMultiplication(tree, paramlist);
                break;

            case TokenType.Power:
                Value = EvalPower(tree, paramlist);
                break;

            case TokenType.Negation:
                Value = EvalNegation(tree, paramlist);
                break;

            case TokenType.Member:
                Value = EvalMember(tree, paramlist);
                break;

            case TokenType.MemberAccess:
                Value = EvalMemberAccess(tree, paramlist);
                break;

            case TokenType.IndexAccess:
                Value = EvalIndexAccess(tree, paramlist);
                break;

            case TokenType.Base:
                Value = EvalBase(tree, paramlist);
                break;

            case TokenType.Variable:
                Value = EvalVariable(tree, paramlist);
                break;

            case TokenType.Group:
                Value = EvalGroup(tree, paramlist);
                break;

            case TokenType.FunctionCall:
                Value = EvalFunctionCall(tree, paramlist);
                break;

            case TokenType.ArgumentList:
                Value = EvalArgumentList(tree, paramlist);
                break;

            case TokenType.Literal:
                Value = EvalLiteral(tree, paramlist);
                break;

            case TokenType.ListLiteral:
                Value = EvalListLiteral(tree, paramlist);
                break;

            case TokenType.HashLiteral:
                Value = EvalHashLiteral(tree, paramlist);
                break;

            case TokenType.PairList:
                Value = EvalPairList(tree, paramlist);
                break;

            case TokenType.Pair:
                Value = EvalPair(tree, paramlist);
                break;

            default:
                Value = Token.Text;
                break;
            }
            return(Value);
        }
 protected object GetValue(ParseTree tree, TokenType type, int index)
 {
     return(GetValue(tree, type, ref index));
 }
Esempio n. 6
0
 public ParseTree Parse(string input)
 {
     tree = new ParseTree();
     return(Parse(input, tree));
 }