private void Parse(GitCmdTokens tokens) { m_exe = tokens.Dequeue(GitCmdTokenType.Literal).Value; var token = tokens.Dequeue(); if (token.Type == GitCmdTokenType.EndOfStram) { return; } if (token.Type != GitCmdTokenType.Literal) { tokens.ParseError(); } m_name = token.Value; while (tokens.Any()) { token = tokens.Dequeue(); if (token.Type == GitCmdTokenType.Dash) { ParseShortSwitch(tokens); } else if (token.Type == GitCmdTokenType.DoubleDash) { ParseLongSwitch(tokens); } else if (token.Type == GitCmdTokenType.Literal) { m_arguments.Add(token.Value); } else if (token.Type == GitCmdTokenType.EndOfStram) { break; } else { tokens.ParseError(); } } }
private void ParseShortSwitch(GitCmdTokens tokens) { var token = tokens.Dequeue(); if (token.Type != GitCmdTokenType.Literal) { tokens.ParseError(); } if (token.Value.Length != 1) { throw new GitCmdException( $"Token '{token}' following single dash must be a single character literal."); } AddSwitch(token); }