Пример #1
0
        protected virtual UnaryBinaryMessageSequenceNode ParseUnaryBinaryMessageSequence(IMessageSequenceParentNode parent, IdentifierToken selector)
        {
            // PARSE: <unary message>* <binary message>*
            UnaryBinaryMessageSequenceNode result = new UnaryBinaryMessageSequenceNode(parent);

            // NB: ParseUnaryMessage() cannot fail, so we don't check result
            UnaryMessageNode message = this.ParseUnaryMessage(result, selector);

            Token token = this.GetNextTokenxx(Preference.Default);

            BinaryOrBinaryUnaryMessageSequenceNode nextMessage = null;

            if (token is IdentifierToken)
            {
                // <unary message>*
                nextMessage = this.ParseUnaryBinaryMessageSequence(result, (IdentifierToken)token);
            }
            else if (token is BinarySelectorToken)
            {
                // <binary message>*
                nextMessage = this.ParseBinaryMessageSequence(result, (BinarySelectorToken)token);
            }
            else
            {
                this.ResidueToken = token;
            }

            result.SetContents(message, nextMessage);
            return(result);
        }
Пример #2
0
        protected virtual KeywordArgumentNode ParseKeywordArgument(KeywordMessageNode parent, Token token)
        {
            // PARSE: <keyword argument> ::= <primary> <unary message>* <binary message>*
            KeywordArgumentNode result = new KeywordArgumentNode(parent);

            IPrimaryNode primary = this.ParsePrimary(result, token);

            if (primary == null)
            {
                this.ReportParserError(result, SemanticErrors.MissingPrimary, token);
                return(result);
            }

            token = this.GetNextTokenxx(Preference.Default);

            BinaryOrBinaryUnaryMessageSequenceNode messages = null;

            if (token is IdentifierToken)
            {
                // <unary message>*
                messages = this.ParseUnaryBinaryMessageSequence(result, (IdentifierToken)token);
            }
            else if (token is BinarySelectorToken)
            {
                messages = this.ParseBinaryMessageSequence(result, (BinarySelectorToken)token);
            }
            else
            {
                this.ResidueToken = token;
            }

            result.SetContents(primary, messages);
            return(result);
        }