예제 #1
0
        public Token Next()
        {
            this.NextTokenIndentMode = TokenIndentMode.None;
            this.IsStartOfLine       = (CurrentToken == null || CurrentToken.Kind == TokenKind.NewLine);

            ++Index;

            this.CurrentToken = this.NextToken;
            this.NextToken    = PeekToken(1);

            this.IsEndOfLine = (CurrentToken.Kind == TokenKind.NewLine ||
                                CurrentToken.Kind == TokenKind.EndOfInput ||
                                NextToken.Kind == TokenKind.NewLine ||
                                NextToken.Kind == TokenKind.EndOfInput);

            //Set indent level
            switch (CurrentToken.GetPSTokenType())
            {
            case PSTokenType.GroupStart:
            {
                ++IndentLevel;
                break;
            }

            case PSTokenType.GroupEnd:
            {
                if (IndentLevel != 0)
                {
                    --IndentLevel;
                }
                break;
            }
            }

            return(this.CurrentToken);
        }
예제 #2
0
 public int GetIndentLevel()
 {
     return((this.IsStartOfLine && CurrentToken.GetPSTokenType() == PSTokenType.GroupStart)
         ? this.IndentLevel - 1
         : this.IndentLevel);
 }