Example #1
0
        public override PredicateNode VisitOperand(PredicateParser.OperandContext context)
        {
            var terminal   = (ITerminalNode)context.GetChild(0);
            var symbolType = terminal.Symbol.Type;

            switch (symbolType)
            {
            case PredicateLexer.String:
                return(new PredicateNode(SymbolType.Operand, new Operand(OperandType.String, terminal.Symbol.Text.Trim('"'))));

            case PredicateLexer.Number:
                return(new PredicateNode(SymbolType.Operand, new Operand(OperandType.Number, decimal.Parse(terminal.Symbol.Text))));

            case PredicateLexer.Property:
                return(new PredicateNode(SymbolType.Operand, new Operand(OperandType.Property, terminal.Symbol.Text.Trim('@'))));
            }

            throw new Exception("Unhandled Operand");
        }
Example #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="PredicateParser.operand"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitOperand([NotNull] PredicateParser.OperandContext context)
 {
     return(VisitChildren(context));
 }