/// <summary> /// Parse the method message pattern. /// </summary> protected virtual MethodNode ParseMessagePattern() { // PARSE: <message pattern> ::= <unary pattern> | <binary pattern> | <keyword pattern> // <unary pattern> ::= unarySelector // <binary pattern> ::= binarySelector <method argument> // <keyword pattern> ::= (keyword <method argument>)+ MethodNode result = new MethodNode(); List<IMethodSelectorToken> selectorParts = new List<IMethodSelectorToken>(); List<MethodArgumentNode> arguments = new List<MethodArgumentNode>(); Token token = this.GetNextTokenxx(Preference.Default); // PARSE: <message pattern> ::= <unary pattern> | <binary pattern> | <keyword pattern> if (token is KeywordToken) { // <keyword pattern> ::= (keyword <method argument>)+ selectorParts.Add((IMethodSelectorToken)token); token = this.GetNextTokenxx(Preference.Default); arguments.Add(this.ParseMethodArgument(result, token)); while (true) { token = this.GetNextTokenxx(Preference.VerticalBar | Preference.NegativeSign); if (token is KeywordToken) { selectorParts.Add((IMethodSelectorToken)token); token = this.GetNextTokenxx(Preference.Default); arguments.Add(this.ParseMethodArgument(result, token)); } else { result.SetContents(selectorParts, arguments); this.ResidueToken = token; // temp vars or statement return result; } } } else if (token is BinarySelectorToken) { // <binary pattern> ::= binarySelector <method argument> selectorParts.Add((IMethodSelectorToken)token); token = this.GetNextTokenxx(Preference.Default); arguments.Add(this.ParseMethodArgument(result, token)); result.SetContents(selectorParts, arguments); return result; } else if (token is IdentifierToken) { // <unary pattern> ::= unarySelector selectorParts.Add((IMethodSelectorToken)token); result.SetContents(selectorParts, arguments); return result; } else { this.ReportParserError(result, SemanticErrors.MissingMethodMessagePattern, token); this.ResidueToken = token; return result; } }