static void ShiftCase(CleanupAstNodeStates cleanStates, int advancePosition) { var colon = cleanStates.GeNextTokenKind(TokenKind.Colon, advancePosition); var tokenAfterColon = cleanStates[colon + 1].Token; switch (tokenAfterColon) { case TokenKind.Continue: case TokenKind.Return: case TokenKind.Break: case TokenKind.Case: cleanStates.ShiftByNodeType(colon + 1); cleanStates.ReduceRangeOfTokensAsParent(colon + 1, colon + 1, RuleKind.CaseBlock); cleanStates.ReduceRangeOfTokensAsParent(advancePosition, colon + 1, RuleKind.Case); return; } var breakPos = cleanStates.GeNextTokenOfAny(new[] { TokenKind.Break, TokenKind.Return, TokenKind.Continue, TokenKind.Case, }, colon); if (breakPos == 0) { cleanStates.ReduceRangeOfTokensAsParent(colon + 1, cleanStates.Count - 2, RuleKind.CaseBlock); cleanStates.ReduceRangeOfTokensAsParent(advancePosition, colon + 1, RuleKind.Case); return; } var breakToken = cleanStates[breakPos].Token; switch (breakToken) { case TokenKind.Case: cleanStates.ReduceRangeOfTokensAsParent(colon + 1, breakPos - 1, RuleKind.CaseBlock); cleanStates.ReduceRangeOfTokensAsParent(advancePosition, colon + 1, RuleKind.Case); return; case TokenKind.Return: cleanStates.ShiftByNodeType(breakPos); cleanStates.ReduceRangeOfTokensAsParent(colon + 1, breakPos, RuleKind.CaseBlock); cleanStates.ReduceRangeOfTokensAsParent(advancePosition, colon + 1, RuleKind.Case); return; } cleanStates.ReduceRangeOfTokensAsParent(colon + 1, breakPos + 1, RuleKind.CaseBlock); cleanStates.ReduceRangeOfTokensAsParent(advancePosition, colon + 1, RuleKind.Case); }