static SimpleParser()
{
_functions = new Dictionary<string, FuncData>
{
{"sqrt", new FuncData() {Func = new Sqrt(), IsFunctionOrUnary = true}},
{"abs", new FuncData() {Func = new Abs(), IsFunctionOrUnary = true}},
{"sign", new FuncData() {Func = new Sign(), IsFunctionOrUnary = true}},
{"sq", new FuncData() {Func = new Sq(), IsFunctionOrUnary = true}},
{"exp", new FuncData() {Func = new Exp(), IsFunctionOrUnary = true}},
{"lg", new FuncData() {Func = new Lg(), IsFunctionOrUnary = true}},
{"ln", new FuncData() {Func = new Ln(), IsFunctionOrUnary = true}},
{"log", new FuncData() {Func = new Log(), IsFunctionOrUnary = true}},
{"sin", new FuncData() {Func = new Sin(), IsFunctionOrUnary = true}},
{"cos", new FuncData() {Func = new Cos(), IsFunctionOrUnary = true}},
{"tan", new FuncData() {Func = new Tan(), IsFunctionOrUnary = true}},
{"sinh", new FuncData() {Func = new Sinh(), IsFunctionOrUnary = true}},
{"cosh", new FuncData() {Func = new Cosh(), IsFunctionOrUnary = true}},
{"tanh", new FuncData() {Func = new Tanh(), IsFunctionOrUnary = true}}
};
//special operators
_soperators = new Dictionary<char, FuncData>
{
{'(', new FuncData() {SpecialKind = SpecialOperandKind.LeftParenthesis}},
{')', new FuncData() {SpecialKind = SpecialOperandKind.RightParenthesis}},
{',', new FuncData() {SpecialKind = SpecialOperandKind.Comma}}
};
//'normal' ops
_operators = new Dictionary<char, FuncData>
{
{'+', new FuncData() {Func = new Sum(), Precedence = 2}},
{'*', new FuncData() {Func = new Mul(), Precedence = 3}},
{'-', new FuncData() {Func = new Sub(), Precedence = 2}},
{'/', new FuncData() {Func = new Div(), Precedence = 3}},
{'%', new FuncData() {Func = new Mod(), Precedence = 3}},
{'^', new FuncData() {Func = new Pow(), Precedence = 4}},
//comparison ops can be used in both ways: as switches in expressions and as "main" ops of equalities and inequalities
{'>', new FuncData() {Func = new Greater(), Precedence = 1}},
{'<', new FuncData() {Func = new Less(), Precedence = 1}},
{'=', new FuncData() {Func = new Equal(), Precedence = 1}},
{'&', new FuncData() {Func = new And(), Precedence = 0}},
{'|', new FuncData() {Func = new And(), Precedence = 0}},
};
//etc
//unary ops
//negate, since it must be distinct from binary minus
_uoperators = new Dictionary<char, FuncData>
{
{'-', new FuncData() {Func = new Negate(), IsFunctionOrUnary = true}},
{'!', new FuncData() {Func = new Not(), IsFunctionOrUnary = true}}
};
//constants: e, pi
_consts = new Dictionary<string, IExpressionElement> { { "e", new E() }, { "pi", new Pi() } };
}