using System;
using System.Collections.Generic;
using System.Text;
namespace Mesnac.Basic
{
class Analyzer
{
}
///
/// 运算符类型(从上到下优先级依次递减)
///
public enum OperatorType
{
///
/// 左括号:(,left bracket
///
LB = 10,
///
/// 右括号),right bracket
///
RB = 11,
///
/// 逻辑非,!,NOT
///
NOT = 20,
///
/// 正号,+,positive sign
///
PS = 21,
///
/// 负号,-,negative sign
///
NS = 22,
///
/// 乘,*,multiplication
///
MUL = 30,
///
/// 除,/,division
///
DIV = 31,
///
/// 余,%,modulus
///
MOD = 32,
///
/// 加,+,Addition
///
ADD = 40,
///
/// 减,-,subtraction
///
SUB = 41,
///
/// 小于,less than
///
LT = 50,
///
/// 小于或等于,less than or equal to
///
LE = 51,
///
/// 大于,>,greater than
///
GT = 52,
///
/// 大于或等于,>=,greater than or equal to
///
GE = 53,
///
/// 等于,=,equal to
///
ET = 60,
///
/// 不等于,unequal to
///
UT = 61,
///
/// 逻辑与,&,AND
///
AND = 70,
///
/// 逻辑或,|,OR
///
OR = 71,
///
/// 逗号,comma
///
CA = 80,
///
/// 结束符号
///
END = 255,
///
/// 错误符号
///
ERR = 256
}
///
/// 运算符
///
public class Operator
{
private OperatorType type = OperatorType.END;
private string value = "";
public Operator(OperatorType type, string value)
{
this.type = type;
this.value = value;
}
///
/// 运算符类型
///
public OperatorType Type
{
get
{
return this.type;
}
set
{
this.type = value;
}
}
///
/// 运算符值
///
public string Value
{
get
{
return this.value;
}
set
{
this.value = value;
}
}
}
///
/// 操作数类型
///
public enum OperandType
{
///
/// 函数
///
FUNC = 1,
///
/// 日期
///
DATE = 2,
///
/// 数字
///
NUMBER = 3,
///
/// 布尔
///
BOOLEAN = 4,
///
/// 字符串
///
STRING = 5
}
///
/// 操作数
///
public class Operand
{
private OperandType type = OperandType.STRING;
private string key = "";
private object value = null;
public Operand(OperandType type, object value)
{
this.type = type;
this.value = value;
}
///
/// 操作数类型
///
public OperandType Type
{
get
{
return this.type;
}
set
{
this.type = value;
}
}
///
/// 关键字
///
public string Key
{
get
{
return this.key;
}
set
{
this.key = value;
}
}
///
/// 操作数值
///
public object Value
{
get
{
return this.value;
}
set
{
this.value = value;
}
}
}
///
/// 语法分析器
///
public class AccidenceAnalyzer
{
private string m_Operator = "()!*/%+-<>=&|,"; //运算符
private Stack