internal ExpressionNode Parse()
{
ExpressionNode node;
OperatorInfo info;
this.expression = null;
this.StartScan();
int num = 0;
goto Label_078F;
Label_0014:
this.Scan();
switch (this.token)
{
case Tokens.Name:
case Tokens.Numeric:
case Tokens.Decimal:
case Tokens.Float:
case Tokens.StringConst:
case Tokens.Date:
case Tokens.Parent:
{
node = null;
string constant = null;
if (this.prevOperand != 0)
{
throw ExprException.MissingOperator(new string(this.text, this.start, this.pos - this.start));
}
if (this.topOperator > 0)
{
info = this.ops[this.topOperator - 1];
if (((info.type == Nodes.Binop) && (info.op == 5)) && (this.token != Tokens.Parent))
{
throw ExprException.InWithoutParentheses();
}
}
this.prevOperand = 1;
switch (this.token)
{
case Tokens.Name:
info = this.ops[this.topOperator - 1];
node = new NameNode(this._table, this.text, this.start, this.pos);
goto Label_0338;
case Tokens.Numeric:
constant = new string(this.text, this.start, this.pos - this.start);
node = new ConstNode(this._table, System.Data.ValueType.Numeric, constant);
goto Label_0338;
case Tokens.Decimal:
constant = new string(this.text, this.start, this.pos - this.start);
node = new ConstNode(this._table, System.Data.ValueType.Decimal, constant);
goto Label_0338;
case Tokens.Float:
constant = new string(this.text, this.start, this.pos - this.start);
node = new ConstNode(this._table, System.Data.ValueType.Float, constant);
goto Label_0338;
case Tokens.StringConst:
constant = new string(this.text, this.start + 1, (this.pos - this.start) - 2);
node = new ConstNode(this._table, System.Data.ValueType.Str, constant);
goto Label_0338;
case Tokens.Date:
constant = new string(this.text, this.start + 1, (this.pos - this.start) - 2);
node = new ConstNode(this._table, System.Data.ValueType.Date, constant);
goto Label_0338;
case Tokens.Parent:
{
string str2;
try
{
this.Scan();
if (this.token == Tokens.LeftParen)
{
this.ScanToken(Tokens.Name);
str2 = NameNode.ParseName(this.text, this.start, this.pos);
this.ScanToken(Tokens.RightParen);
this.ScanToken(Tokens.Dot);
}
else
{
str2 = null;
this.CheckToken(Tokens.Dot);
}
}
catch (Exception exception)
{
if (!ADP.IsCatchableExceptionType(exception))
{
throw;
}
throw ExprException.LookupArgument();
}
this.ScanToken(Tokens.Name);
string columnName = NameNode.ParseName(this.text, this.start, this.pos);
info = this.ops[this.topOperator - 1];
node = new LookupNode(this._table, columnName, str2);
goto Label_0338;
}
}
break;
}
case Tokens.ListSeparator:
{
if (this.prevOperand == 0)
{
throw ExprException.MissingOperandBefore(",");
}
this.BuildExpression(3);
info = this.ops[this.topOperator - 1];
if (info.type != Nodes.Call)
{
throw ExprException.SyntaxError();
}
ExpressionNode argument = this.NodePop();
FunctionNode node4 = (FunctionNode)this.NodePop();
node4.AddArgument(argument);
this.NodePush(node4);
this.prevOperand = 0;
goto Label_0014;
}
case Tokens.LeftParen:
num++;
if (this.prevOperand != 0)
{
this.BuildExpression(0x16);
this.prevOperand = 0;
ExpressionNode node5 = this.NodePeek();
if ((node5 == null) || (node5.GetType() != typeof(NameNode)))
{
throw ExprException.SyntaxError();
}
NameNode node9 = (NameNode)this.NodePop();
node = new FunctionNode(this._table, node9.name);
Aggregate aggregate = (Aggregate)((FunctionNode)node).Aggregate;
if (aggregate != Aggregate.None)
{
node = this.ParseAggregateArgument((FunctionId)aggregate);
this.NodePush(node);
this.prevOperand = 2;
}
else
{
this.NodePush(node);
this.ops[this.topOperator++] = new OperatorInfo(Nodes.Call, 0, 2);
}
}
else
{
info = this.ops[this.topOperator - 1];
if ((info.type != Nodes.Binop) || (info.op != 5))
{
this.ops[this.topOperator++] = new OperatorInfo(Nodes.Paren, 0, 2);
}
else
{
node = new FunctionNode(this._table, "In");
this.NodePush(node);
this.ops[this.topOperator++] = new OperatorInfo(Nodes.Call, 0, 2);
}
}
goto Label_0014;
case Tokens.RightParen:
if (this.prevOperand != 0)
{
this.BuildExpression(3);
}
if (this.topOperator <= 1)
{
throw ExprException.TooManyRightParentheses();
}
this.topOperator--;
info = this.ops[this.topOperator];
if ((this.prevOperand == 0) && (info.type != Nodes.Call))
{
throw ExprException.MissingOperand(info);
}
if (info.type == Nodes.Call)
{
if (this.prevOperand != 0)
{
ExpressionNode node8 = this.NodePop();
FunctionNode node2 = (FunctionNode)this.NodePop();
node2.AddArgument(node8);
node2.Check();
this.NodePush(node2);
}
}
else
{
node = this.NodePop();
node = new UnaryNode(this._table, 0, node);
this.NodePush(node);
}
this.prevOperand = 2;
num--;
goto Label_0014;
case Tokens.ZeroOp:
if (this.prevOperand != 0)
{
throw ExprException.MissingOperator(new string(this.text, this.start, this.pos - this.start));
}
this.ops[this.topOperator++] = new OperatorInfo(Nodes.Zop, this.op, 0x18);
this.prevOperand = 2;
goto Label_0014;
case Tokens.UnaryOp:
goto Label_0647;
case Tokens.BinaryOp:
if (this.prevOperand != 0)
{
this.prevOperand = 0;
this.BuildExpression(Operators.Priority(this.op));
this.ops[this.topOperator++] = new OperatorInfo(Nodes.Binop, this.op, Operators.Priority(this.op));
goto Label_0014;
}
if (this.op != 15)
{
if (this.op != 0x10)
{
throw ExprException.MissingOperandBefore(Operators.ToString(this.op));
}
this.op = 1;
}
else
{
this.op = 2;
}
goto Label_0647;
case Tokens.Dot:
{
ExpressionNode node3 = this.NodePeek();
if ((node3 == null) || !(node3.GetType() == typeof(NameNode)))
{
goto Label_0763;
}
this.Scan();
if (this.token != Tokens.Name)
{
goto Label_0763;
}
NameNode node6 = (NameNode)this.NodePop();
string name = node6.name + "." + NameNode.ParseName(this.text, this.start, this.pos);
this.NodePush(new NameNode(this._table, name));
goto Label_0014;
}
case Tokens.EOS:
if (this.prevOperand != 0)
{
this.BuildExpression(3);
if (this.topOperator != 1)
{
throw ExprException.MissingRightParen();
}
}
else if (this.topNode != 0)
{
info = this.ops[this.topOperator - 1];
throw ExprException.MissingOperand(info);
}
goto Label_078F;
default:
goto Label_0763;
}
Label_0338:
this.NodePush(node);
goto Label_0014;
Label_0647:
this.ops[this.topOperator++] = new OperatorInfo(Nodes.Unop, this.op, Operators.Priority(this.op));
goto Label_0014;
Label_0763:
throw ExprException.UnknownToken(new string(this.text, this.start, this.pos - this.start), this.start + 1);
Label_078F:
if (this.token != Tokens.EOS)
{
goto Label_0014;
}
this.expression = this.NodeStack[0];
return(this.expression);
}