コード例 #1
0
        protected virtual MessageSequenceNode ParseMessages(IMessageSequenceParentNode parent, Token token, MessageType type)
        {
            // <messages> ::=
            //      (<unary message>+ <binary message>* [<keyword message>] ) |
            //      (<binary message>+ [<keyword message>] ) |
            //      <keyword message>
            // <unary message> ::= unarySelector
            // <binary message> ::= binarySelector <binary argument>
            // <binary argument> ::= <primary> <unary message>*
            // <keyword message> ::= (keyword <keyword argument> )+
            // <keyword argument> ::= <primary> <unary message>* <binary message>*

            if ((token is IdentifierToken) && ((type & MessageType.Unary) != 0))
            {
                // (<unary message>+ <binary message>* [<keyword message>] )
                return(this.ParseUnaryBinaryKeywordMessageSequence(parent, (IdentifierToken)token));
            }

            if ((token is BinarySelectorToken) && ((type & MessageType.Binary) != 0))
            {
                // (<binary message>+ [<keyword message>] )
                return(this.ParseBinaryKeywordMessageSequence(parent, (BinarySelectorToken)token));
            }

            if ((token is KeywordToken) && ((type & MessageType.Keyword) != 0))
            {
                // <keyword message>
                return(this.ParseKeywordMessageSequence(parent, (KeywordToken)token));
            }

            this.ResidueToken = token; // Not for us ... let others give it a try.
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Create a new message sequence.
        /// </summary>
        /// <param name="parent">Parent node that defines this parse node.</param>
        protected MessageSequenceBase(IMessageSequenceParentNode parent)
        {
#if DEBUG
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
#endif
            this.Parent = parent;
        }
コード例 #3
0
        protected virtual KeywordMessageSequenceNode ParseKeywordMessageSequence(IMessageSequenceParentNode parent, KeywordToken token)
        {
            // PARSE: <keyword message>
            KeywordMessageSequenceNode result = new KeywordMessageSequenceNode(parent);

            // NB: ParseKeywordMessage() cannot fail, so we don't check result
            KeywordMessageNode message = this.ParseKeywordMessage(result, token);

            result.SetContents(message);
            return(result);
        }
コード例 #4
0
        protected virtual BinaryMessageSequenceNode ParseBinaryMessageSequence(IMessageSequenceParentNode parent, BinarySelectorToken selector)
        {
            // PARSE: <binary message>*
            BinaryMessageSequenceNode result = new BinaryMessageSequenceNode(parent);

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

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

            BinaryMessageSequenceNode nextMessage = null;

            if (token is BinarySelectorToken)
            {
                nextMessage = this.ParseBinaryMessageSequence(result, (BinarySelectorToken)token);
            }
            else
            {
                this.ResidueToken = token;
            }

            result.SetContents(message, nextMessage);
            return(result);
        }
コード例 #5
0
        protected virtual BinaryKeywordMessageSequenceNode ParseBinaryKeywordMessageSequence(IMessageSequenceParentNode parent, BinarySelectorToken selector)
        {
            // PARSE: <binary message>+ [<keyword message>]
            BinaryKeywordMessageSequenceNode result = new BinaryKeywordMessageSequenceNode(parent);

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

            Token token = this.GetNextTokenxx(Preference.Default);
            BinaryKeywordOrKeywordMessageSequenceNode nextMessage = (BinaryKeywordOrKeywordMessageSequenceNode)
                                                                    this.ParseMessages(result, token, MessageType.Binary | MessageType.Keyword);

            result.SetContents(message, nextMessage);
            return(result);
        }
コード例 #6
0
        protected virtual UnaryBinaryKeywordMessageSequenceNode ParseUnaryBinaryKeywordMessageSequence(IMessageSequenceParentNode parent, IdentifierToken selector)
        {
            // PARSE: // <unary message>+ <binary message>* [<keyword message>]
            UnaryBinaryKeywordMessageSequenceNode result = new UnaryBinaryKeywordMessageSequenceNode(parent);

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

            Token token = this.GetNextTokenxx(Preference.Default);
            MessageSequenceNode nextMessage = this.ParseMessages(result, token, MessageType.All);

            result.SetContents(message, nextMessage);
            return(result);
        }
コード例 #7
0
 /// <summary>
 /// Create a new message sequence with a keyword message.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected internal KeywordMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #8
0
 /// <summary>
 /// Create a new message sequence.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected BinaryOrBinaryUnaryMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #9
0
 /// <summary>
 /// Create a new message sequence.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected MessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #10
0
 /// <summary>
 /// Create a new message sequence.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected BinaryKeywordOrKeywordMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #11
0
ファイル: Parser.cs プロジェクト: erlis/IronSmalltalk
        protected virtual UnaryBinaryKeywordMessageSequenceNode ParseUnaryBinaryKeywordMessageSequence(IMessageSequenceParentNode parent, IdentifierToken selector)
        {
            // PARSE: // <unary message>+ <binary message>* [<keyword message>]
            UnaryBinaryKeywordMessageSequenceNode result = new UnaryBinaryKeywordMessageSequenceNode(parent);

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

            Token token = this.GetNextTokenxx(Preference.Default);
            MessageSequenceNode nextMessage = this.ParseMessages(result, token, MessageType.All);

            result.SetContents(message, nextMessage);
            return result;
        }
コード例 #12
0
ファイル: Parser.cs プロジェクト: erlis/IronSmalltalk
        protected virtual MessageSequenceNode ParseMessages(IMessageSequenceParentNode parent, Token token, MessageType type)
        {
            // <messages> ::=
            //      (<unary message>+ <binary message>* [<keyword message>] ) |
            //      (<binary message>+ [<keyword message>] ) |
            //      <keyword message>
            // <unary message> ::= unarySelector
            // <binary message> ::= binarySelector <binary argument>
            // <binary argument> ::= <primary> <unary message>*
            // <keyword message> ::= (keyword <keyword argument> )+
            // <keyword argument> ::= <primary> <unary message>* <binary message>*

            if ((token is IdentifierToken) && ((type & MessageType.Unary) != 0))
                // (<unary message>+ <binary message>* [<keyword message>] )
                return this.ParseUnaryBinaryKeywordMessageSequence(parent, (IdentifierToken)token);

            if ((token is BinarySelectorToken) && ((type & MessageType.Binary) != 0))
                // (<binary message>+ [<keyword message>] )
                return this.ParseBinaryKeywordMessageSequence(parent, (BinarySelectorToken)token);

            if ((token is KeywordToken) && ((type & MessageType.Keyword) != 0))
                // <keyword message>
                return this.ParseKeywordMessageSequence(parent, (KeywordToken)token);

            this.ResidueToken = token; // Not for us ... let others give it a try.
            return null;
        }
コード例 #13
0
ファイル: Parser.cs プロジェクト: erlis/IronSmalltalk
 /// <summary>
 /// Parses a message sequence as defined in X3J20 "3.4.5.3 Messages".
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="token">First token of the message node. If the token is message token, it is returned in the residueToken parameter.</param>
 /// <returns>Message sequence node or null if the given token is not a message token.</returns>
 /// <remarks>
 /// This mehtod does not registers errors if the given token is not a message token.
 /// The 'offending' token is returned in the residueToken parameter, and it is 
 /// responsibility of the called to determine what to do.
 /// </remarks>
 protected virtual MessageSequenceNode ParseMessages(IMessageSequenceParentNode parent, Token token)
 {
     return this.ParseMessages(parent, token, MessageType.All);
 }
コード例 #14
0
ファイル: Parser.cs プロジェクト: erlis/IronSmalltalk
        protected virtual KeywordMessageSequenceNode ParseKeywordMessageSequence(IMessageSequenceParentNode parent, KeywordToken token)
        {
            // PARSE: <keyword message>
            KeywordMessageSequenceNode result = new KeywordMessageSequenceNode(parent);

            // NB: ParseKeywordMessage() cannot fail, so we don't check result
            KeywordMessageNode message = this.ParseKeywordMessage(result, token);

            result.SetContents(message);
            return result;
        }
コード例 #15
0
ファイル: Parser.cs プロジェクト: erlis/IronSmalltalk
        protected virtual BinaryKeywordMessageSequenceNode ParseBinaryKeywordMessageSequence(IMessageSequenceParentNode parent, BinarySelectorToken selector)
        {
            // PARSE: <binary message>+ [<keyword message>]
            BinaryKeywordMessageSequenceNode result = new BinaryKeywordMessageSequenceNode(parent);

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

            Token token = this.GetNextTokenxx(Preference.Default);
            BinaryKeywordOrKeywordMessageSequenceNode nextMessage = (BinaryKeywordOrKeywordMessageSequenceNode)
                this.ParseMessages(result, token, MessageType.Binary | MessageType.Keyword);

            result.SetContents(message, nextMessage);
            return result;
        }
コード例 #16
0
 /// <summary>
 /// Create a new message sequence.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected MessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #17
0
ファイル: Parser.cs プロジェクト: erlis/IronSmalltalk
        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;
        }
コード例 #18
0
 /// <summary>
 /// Create a new message sequence.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected BinaryOrBinaryUnaryMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #19
0
 /// <summary>
 /// Create a new message sequence.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected MessageSequenceBase(IMessageSequenceParentNode parent)
 {
     #if DEBUG
     if (parent == null)
         throw new ArgumentNullException("parent");
     #endif
     this.Parent = parent;
 }
コード例 #20
0
 /// <summary>
 /// Create a new message sequence starting with a unary message.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected internal UnaryMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #21
0
 /// <summary>
 /// Create a new message sequence starting with a binary message.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected internal BinaryKeywordMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #22
0
 /// <summary>
 /// Parses a message sequence as defined in X3J20 "3.4.5.3 Messages".
 /// </summary>
 /// <param name="parent"></param>
 /// <param name="token">First token of the message node. If the token is message token, it is returned in the residueToken parameter.</param>
 /// <returns>Message sequence node or null if the given token is not a message token.</returns>
 /// <remarks>
 /// This method does not registers errors if the given token is not a message token.
 /// The 'offending' token is returned in the residueToken parameter, and it is
 /// responsibility of the called to determine what to do.
 /// </remarks>
 protected virtual MessageSequenceNode ParseMessages(IMessageSequenceParentNode parent, Token token)
 {
     return(this.ParseMessages(parent, token, MessageType.All));
 }
コード例 #23
0
 /// <summary>
 /// Create a new message sequence starting with a binary message.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected internal BinaryMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }
コード例 #24
0
 /// <summary>
 /// Create a new message sequence.
 /// </summary>
 /// <param name="parent">Parent node that defines this parse node.</param>
 protected BinaryKeywordOrKeywordMessageSequenceNode(IMessageSequenceParentNode parent)
     : base(parent)
 {
 }