Пример #1
0
        public static ExprStatement TryParse(ref Source s)
        {
            ExprStatement res = null;

            Spaces.Skip(ref s);
            Expression expr = new Expression(ref s);

            if (expr.Correct())
            {
                res = new ExprStatement(expr);
            }

            Spaces.Skip(ref s);
            if (!s.SkipIf(";"))
            {
                s.Rollback();
                return(null);
            }

            return(res);
        }
Пример #2
0
        public static Statement TryParseAny(ref Source s)
        {
            Spaces.Skip(ref s);

            Statement res;

            s.Save();

            res = If.TryParse(ref s);
            if (res == null)
            {
                s.Rollback();
                res = While.TryParse(ref s);
            }
            if (res == null)
            {
                s.Rollback();
                res = Return.TryParse(ref s);
            }
            if (res == null)
            {
                s.Rollback();
                res = Assignment.TryParse(ref s);
            }
            if (res == null)
            {
                s.Rollback();
                res = ExprStatement.TryParse(ref s);
            }
            if (res == null)
            {
                s.Rollback();
                s.SkipIf(";");
            }

            s.Check(res);
            return(res);
        }