/// <summary>
 /// Create a new binary message node.
 /// </summary>
 /// <param name="parent">The parent message sequence node that defines this message node.</param>
 /// <param name="token">Token containing the message selector.</param>
 protected internal BinaryMessageNode(MessageSequenceBase parent, BinarySelectorToken token)
     : base(parent)
 {
     #if DEBUG
     if (token == null)
         throw new ArgumentNullException("token");
     #endif
     this.SelectorToken = token;
 }
 // Initializes the node after being parsed by the parser.
 protected internal void SetContents(BinarySelectorToken openingDelimiter, BinarySelectorToken closingDelimiter,
     KeywordToken apiConvention, IEnumerable<IPrimitiveCallParameterToken> parameters)
 {
     this.OpeningDelimiter = openingDelimiter;
     this.ClosingDelimiter = closingDelimiter;
     this.ApiConvention = apiConvention;
     this.ApiParameters.Clear();
     foreach (IPrimitiveCallParameterToken param in parameters)
         this.ApiParameters.Add(param);
 }
Beispiel #3
0
        protected virtual PrimitiveCallNode ParseApiCall(MethodNode parent, BinarySelectorToken token)
        {
            PrimitiveCallNode result = new PrimitiveCallNode(parent);
            List<IPrimitiveCallParameterToken> parameters = new List<IPrimitiveCallParameterToken>();

            Token apiConvention = this.GetNextTokenxx(Preference.Default);
            if (!(apiConvention is KeywordToken))
                this.ReportParserError(result, SemanticErrors.MissingApiConvention, apiConvention);

            while(true)
            {
                Token tkn = this.GetNextTokenxx(Preference.Default);
                if (tkn is IPrimitiveCallParameterToken)
                {
                    parameters.Add((IPrimitiveCallParameterToken)tkn);
                }
                else if (Parser.IsApiClosingDelimiter(tkn))
                {

                    result.SetContents(token, tkn as BinarySelectorToken, apiConvention as KeywordToken, parameters);
                    return result;
                }
                else
                {
                    this.ReportParserError(result, SemanticErrors.UnexpectedApiParameterToken, tkn);
                    this.ResidueToken = tkn;

                    result.SetContents(token, tkn as BinarySelectorToken, apiConvention as KeywordToken, parameters);
                    return result;
                }
            }
        }
Beispiel #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;
        }
Beispiel #5
0
        protected virtual BinaryMessageNode ParseBinaryMessage(MessageSequenceBase parent, BinarySelectorToken selector)
        {
            // PARSE: <binary message> ::= binarySelector <binary argument>
            BinaryMessageNode result = new BinaryMessageNode(parent, selector);

            Token token = this.GetNextTokenxx(Preference.NegativeSign);
            // Parse the binary argument ... ParseBinaryArgument() does not fail and reports errors self.
            BinaryArgumentNode argument = this.ParseBinaryArgument(result, token);

            if (argument != null)
                result.SetContents(argument);
            return result;
        }
Beispiel #6
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;
        }