示例#1
0
        private bool TryCombinator()
        {
            //combinator
            //  /* combinators can be surrounded by whitespace */
            //  : PLUS S* | GREATER S* | TILDE S* | S+
            //  ;

            var token = TryRead(ToTokenSpec(TokenKind.Plus), ToTokenSpec(TokenKind.Greater), ToTokenSpec(TokenKind.Tilde), ToTokenSpec(TokenKind.WhiteSpace));

            if (token == null)
            {
                return(false);
            }

            if (token.Value.Kind == TokenKind.WhiteSpace)
            {
                _generator.Descendant();
            }
            else
            {
                switch (token.Value.Kind)
                {
                case TokenKind.Tilde: _generator.GeneralSibling(); break;

                case TokenKind.Greater: _generator.Child(); break;

                case TokenKind.Plus: _generator.Adjacent(); break;
                }

                TryRead(ToTokenSpec(TokenKind.WhiteSpace));
            }

            return(true);
        }