/// <summary> /// Initializes the node after being parsed by the parser. /// </summary> /// <param name="message">The first (current) message in the message sequence.</param> protected internal void SetContents(KeywordMessageNode message) { if (message == null) { throw new ArgumentNullException("message"); } this.Message = message; }
/// <summary> /// Create a new keyword message argument node. /// </summary> /// <param name="parent">Parent message node that defines this message argument node.</param> protected internal KeywordArgumentNode(KeywordMessageNode parent) { #if DEBUG if (parent == null) { throw new ArgumentNullException("parent"); } #endif this.Parent = parent; }
/// <summary> /// Initializes the node after being parsed by the parser. /// </summary> /// <param name="message">The first (current) message in the message sequence.</param> protected internal void SetContents(KeywordMessageNode message) { if (message == null) throw new ArgumentNullException("message"); this.Message = message; }
/// <summary> /// Create a new keyword message argument node. /// </summary> /// <param name="parent">Parent message node that defines this message argument node.</param> protected internal KeywordArgumentNode(KeywordMessageNode parent) { #if DEBUG if (parent == null) throw new ArgumentNullException("parent"); #endif this.Parent = parent; }
protected virtual KeywordMessageNode ParseKeywordMessage(MessageSequenceNode parent, KeywordToken selector) { // PARSE: <keyword message> ::= (keyword <keyword argument> )+ KeywordMessageNode result = new KeywordMessageNode(parent); List<KeywordToken> selectorTokens = new List<KeywordToken>(); List<KeywordArgumentNode> arguments = new List<KeywordArgumentNode>(); Token token = this.GetNextTokenxx(Preference.NegativeSign); selectorTokens.Add(selector); arguments.Add(this.ParseKeywordArgument(result, token)); // NB: ParseKeywordArgument() may not fail. token = this.GetNextTokenxx(Preference.Default); while (token is KeywordToken) { selectorTokens.Add((KeywordToken)token); token = this.GetNextTokenxx(Preference.NegativeSign); arguments.Add(this.ParseKeywordArgument(result, token)); // NB: ParseKeywordArgument() may not fail. token = this.GetNextTokenxx(Preference.Default); } result.SetContents(selectorTokens, arguments); this.ResidueToken = token; return result; }
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; }