public ExpressionParser(Reader reader, IExpressionParserHooks hooks = null, NodeManager nodeManager = null, ExpressionParserConfig config = null) { this.reader = reader; this.hooks = hooks; this.nodeManager = nodeManager; this.config = config; this.stringLiteralType = null; this.numericLiteralType = null; if (this.config == null) { this.config = ExpressionParser.defaultConfig(); } this.reconfigure(); }
public static ExpressionParserConfig defaultConfig() { var config = new ExpressionParserConfig(); config.unary = new string[] { "++", "--", "!", "not", "+", "-", "~" }; config.precedenceLevels = new PrecedenceLevel[] { new PrecedenceLevel("assignment", new string[] { "=", "+=", "-=", "*=", "/=", "<<=", ">>=" }, true), new PrecedenceLevel("conditional", new string[] { "?" }, false), new PrecedenceLevel("or", new string[] { "||", "or" }, true), new PrecedenceLevel("and", new string[] { "&&", "and" }, true), new PrecedenceLevel("comparison", new string[] { ">=", "!=", "===", "!==", "==", "<=", ">", "<" }, true), new PrecedenceLevel("sum", new string[] { "+", "-" }, true), new PrecedenceLevel("product", new string[] { "*", "/", "%" }, true), new PrecedenceLevel("bitwise", new string[] { "|", "&", "^" }, true), new PrecedenceLevel("exponent", new string[] { "**" }, true), new PrecedenceLevel("shift", new string[] { "<<", ">>" }, true), new PrecedenceLevel("range", new string[] { "..." }, true), new PrecedenceLevel("in", new string[] { "in" }, true), new PrecedenceLevel("prefix", new string[0], false), new PrecedenceLevel("postfix", new string[] { "++", "--" }, false), new PrecedenceLevel("call", new string[] { "(" }, false), new PrecedenceLevel("propertyAccess", new string[0], false), new PrecedenceLevel("elementAccess", new string[] { "[" }, false) }; config.rightAssoc = new string[] { "**" }; config.aliases = new Dictionary <string, string> { ["==="] = "==", ["!=="] = "!=", ["not"] = "!", ["and"] = "&&", ["or"] = "||" }; config.propertyAccessOps = new string[] { ".", "::" }; return(config); }