コード例 #1
0
        public StmtIfElse(Parser parser)
        {
            string token = parser.GetNextToken();

            if (token != "(")
            {
                throw new CompileException(ErrorHelper.Unexpected("(", token));
            }
            cond  = new StmtExpression(parser);
            token = parser.GetNextToken();
            if (token != ")")
            {
                throw new CompileException(ErrorHelper.Unexpected(")", token));
            }
            ifBlock = new StmtBlock(parser);
            token   = parser.PeekNextToken();
            if (token == "else")
            {
                token     = parser.GetNextToken();
                elseBlock = new StmtBlock(parser);
            }
            if (cond.RequireSwitchLogic)
            {
                var tmp = ifBlock;
                ifBlock   = elseBlock;
                elseBlock = tmp;
            }
        }
コード例 #2
0
        public StmtDoWhile(Parser parser)
        {
            loop = new StmtBlock(parser);
            string token = parser.GetNextToken();

            if (token != "while")
            {
                throw new CompileException(ErrorHelper.Unexpected("while", token));
            }
            token = parser.GetNextToken();
            if (token != "(")
            {
                throw new CompileException(ErrorHelper.Unexpected("(", token));
            }
            cond  = new StmtExpression(parser);
            token = parser.GetNextToken();
            if (token != ")")
            {
                throw new CompileException(ErrorHelper.Unexpected(")", token));
            }
            token = parser.GetNextToken();
            if (token != ";")
            {
                throw new CompileException(ErrorHelper.Unexpected(";", token));
            }
        }
コード例 #3
0
        public StmtAssignment(Parser parser, string d)
        {
            dest = d;
            exp  = new StmtExpression(parser);
            string token = parser.GetNextToken();

            if (token != ";")
            {
                throw new CompileException(ErrorHelper.Unexpected(";", token));
            }
        }