/// <summary>
        /// Consume token of a specific type.
        /// Does nothing if token type does not match.
        /// </summary>
        /// <param name="type">Token type to consume</param>
        /// <param name="token">The consumed token (if types match)</param>
        /// <returns><c>true</c> if tokens were consumed, otherwise <c>false</c> (wrong type, too few tokens in stream)</returns>
        public bool TryConsume(TokenType type, out ClassDiagramToken token)
        {
            token = null;

            if (Count == 0)
            {
                return(false);
            }
            token = this[0];

            if (token.TokenType == type)
            {
                SetCurrentLocation(this[0]);
                RemoveAt(0);
                return(true);
            }

            return(false);
        }
 public ErrorReturnCode Unexpected(TokenType expected, ClassDiagramToken actualToken)
 {
     _errors.Add(Error.Unexpected(expected, actualToken));
     return(ErrorReturnCode.StopParsing);
 }
Пример #3
0
#pragma warning restore 649

            public RuleMatchInfo(ClassDiagramToken token)
            {
                Token     = token;
                IsSuccess = true;
            }