예제 #1
0
파일: Sta.cs 프로젝트: pBactusp/Shpoon
        public static StatementNode Parse(TokenString tStr, ref int index)
        {
            switch (tStr[index].Type)
            {
            case TokenType.cBraceOpen:
                return(CompoundStaNode.Parse(tStr, ref index));

            case TokenType.ifStatement:
                return(ConditionalStaNode.Parse(tStr, ref index));

            case TokenType.doStatement:
                return(DoLoopStaNode.Parse(tStr, ref index));

            case TokenType.whileStatement:
                return(WhileLoopStaNode.Parse(tStr, ref index));

            case TokenType.forStatement:
                return(ForLoopStaNode.Parse(tStr, ref index));

            case TokenType.returnStatement:
                return(ReturnStaNode.Parse(tStr, ref index));

            case TokenType.lineEnd:
                return(NopStaNode.Parse(tStr, ref index));

            default:
                return(ExpressionStaNode.Parse(tStr, ref index));
            }
        }
예제 #2
0
        public static ExpressionStaNode Parse(TokenString tStr, ref int index)
        {

            var expression = Exp.Parse(tStr.GetRangeUntil(ref index, TokenType.lineEnd));

            ExpressionStaNode node = new ExpressionStaNode(expression);

            index++;
            return node;
        }