Пример #1
0
        public static While TryParse(ref Source s)
        {
            const string WhileName = "while";
            While        res       = null;

            if (!s.SkipIf(WhileName))
            {
                s.Rollback();
                return(null);
            }
            res = new While();

            res.condition = Condition.TryParse(ref s);
            if (res.condition == null)
            {
                s.Rollback();
                return(null);
            }

            Source tempSource = s.Clone();

            res.body     = StatementSequence.TryParse(ref tempSource);
            s.currentPos = tempSource.currentPos;
            s.Save();

            return(res);
        }
Пример #2
0
        public static FuncValue TryParse(ref Source s)
        {
            const string funcName = "function";
            FuncValue    res      = null;

            if (!s.SkipIf(funcName))
            {
                s.Rollback();
                return(null);
            }

            res = new FuncValue();

            if (!ArgumentsFormal.TryParse(ref s, res))
            {
                s.Rollback();
                return(null);
            }


            Source tempSource = s.Clone();

            res.body     = StatementSequence.TryParse(ref tempSource);
            s.currentPos = tempSource.currentPos;
            s.Save();

            return(res);
        }
Пример #3
0
 public void Parse(string str)
 {
     sourceCode = new Source(str);
     statements = StatementSequence.TryParse(ref sourceCode);
 }