示例#1
0
        public static Expression Parse(string s)
        {
            Lexer l = new Lexer(new StringReader(s),
                                new[] { TD_SPACE, TD_COMMENT, TD_INT, TD_FLOAT, TD_STR, TD_BOOL, TD_ID, TD_LEFT_PAREN, TD_RIGHT_PAREN });
            var ctx = new Context {
                lexer     = l,
                errorList = new List <ParseError>()
            };
            var exp = ParseImpl(ctx);

            if (ctx.errorList.Count > 0)
            {
                XDebug.Error("Failed parsing expression, errors: ");
                foreach (var err in ctx.errorList)
                {
                    XDebug.Error($"    {err}");
                }
            }
            return(exp);
        }