Пример #1
0
        //>> PrimaryExpr ::= Literal | Number | VariableReference | '(' Expr ')' | FunctionCall
        private AstNode ParsePrimaryExpr(AstNode  qyInput) {
            Debug.Assert(IsPrimaryExpr(this.scanner));
            AstNode  opnd = null;
            switch (this.scanner.Kind) {
            case XPathScanner.LexKind.String:
                opnd = new Operand(this.scanner.StringValue);
                NextLex();
                break;
            case XPathScanner.LexKind.Number:
                opnd = new Operand(this.scanner.NumberValue);
                NextLex();
                break;
            case XPathScanner.LexKind.Dollar:
                NextLex();
                CheckToken(XPathScanner.LexKind.Name);
                opnd = new Variable(this.scanner.Name, this.scanner.Prefix);
                NextLex();
                break;
            case XPathScanner.LexKind.LParens:
                NextLex();
                opnd = ParseExpresion(qyInput);
                if (opnd.TypeOfAst != AstNode.QueryType.ConstantOperand) {
                    opnd = new Group(opnd);
                }
                PassToken(XPathScanner.LexKind.RParens);
                break;
            case XPathScanner.LexKind.Name :
                if (this.scanner.CanBeFunction && ! IsNodeType(this.scanner)) {
                    opnd = ParseMethod(null); 
                }
                break;
            }
			Debug.Assert(opnd != null, "IsPrimaryExpr() was true. We should recognize this lex.");
            return opnd;
        }
Пример #2
0
        private static void ComposeOperand(Operand node, StringBuilder expr) {
            switch (node.ReturnType) {
                case XPathResultType.Number:
                    expr.Append(node.OperandValue.ToString());
                    break;
                case XPathResultType.String:
                    expr.Append(s_Apos);
                    expr.Append(node.OperandValue.ToString());
                    expr.Append(s_Apos);
                    break;
                case XPathResultType.Boolean:
                    bool value = (bool) node.OperandValue;
                    expr.Append(s_Apos);
                    expr.Append(value ? s_True : s_False);
                    expr.Append(s_Apos);
                    break;
                default:
                    Debug.Fail("Unexpected operand type");
		    break;
            }
        }
Пример #3
0
 private IQuery ProcessOperand(Operand root) {
     return new OperandQuery(root.OperandValue, root.ReturnType);
 }