public override Verb CreateVerb(string[] tokens) { Color(position, tokens[1].Length, IDEColor.EntityType.Whitespace); string visibility = tokens[2]; Color(visibility.Length, IDEColor.EntityType.Verb); string scope = tokens[3]; Color(scope.Length, IDEColor.EntityType.Verb); ClassParser.SetScopeAndVisibility(scope, visibility, this); string messageName = tokens[4]; Color(messageName.Length, IDEColor.EntityType.Variable); Color(tokens[5].Length, IDEColor.EntityType.Verb); if (closureParser.Scan(source, position + length)) { var closure = (Closure)closureParser.Result.Value; int parserPosition = closureParser.Result.Position; var multiMethodParser = new MultiMethodParser(); if (multiMethodParser.Scan(source, parserPosition)) { var block = (Block)multiMethodParser.Result.Value; Builder.AddMultiMethod(messageName, closure, block, this); overridePosition = multiMethodParser.Result.Position; } else { Builder.AddMethod(messageName, closure, this); overridePosition = parserPosition; } return(new NullOp()); } if (parameterParser.Scan(source, position + length)) { var closure = parameterParser.Result.Value as Closure; if (closure == null) { return(null); } var multiMethodParser = new MultiMethodParser(); int parserPosition = parameterParser.Result.Position; if (multiMethodParser.Scan(source, parserPosition)) { var block = (Block)multiMethodParser.Result.Value; Builder.AddMultiMethod(messageName, closure, block, this); overridePosition = multiMethodParser.Result.Position; } else { Builder.AddMethod(messageName, closure, this); overridePosition = parserPosition; } return(new NullOp()); } return(null); }
public override Verb CreateVerb(string[] tokens) { Color(position, tokens[1].Length, IDEColor.EntityType.Whitespace); string visibility = tokens[2]; Color(visibility.Length, IDEColor.EntityType.Verb); string scope = tokens[3]; Color(scope.Length, IDEColor.EntityType.Verb); ClassParser.SetScopeAndVisibility(scope, visibility, this); string messageName = tokens[4]; Color(messageName.Length, IDEColor.EntityType.Variable); Color(tokens[5].Length, IDEColor.EntityType.Verb); int index = position + length; var classParser = new ClassParser(); parsers.Insert(0, classParser); foreach (Parser parser in parsers.Where(p => p.Scan(source, index))) { if (parser is ClassParser) { index = parser.Result.Position; if (matcher.IsMatch(source.Substring(index), @"^\.new\b")) { Color(1, IDEColor.EntityType.Structure); int matchedLength = matcher[0].Length; Color(matchedLength - 1, IDEColor.EntityType.Message); var builderValue = (ClassBuilderValue)parser.Result.Value; ClassBuilder builder = builderValue.Builder; builder.AutoInstantiate = true; index += matchedLength; } else { index = parser.Result.Position; } } else { index = parser.Result.Position; } Value value = parser.Result.Value; Block block = null; if (multiMethodParser.Scan(source, index)) { ParserResult innerResult = multiMethodParser.Result; block = (Block)innerResult.Value; index = innerResult.Position; } Builder.AddInitializedVariable(messageName, value, this, block); overridePosition = index; return(new NullOp()); } return(null); }
Verb createMethod(string messageName, Parser parser, Parameters parameters, bool includeMultiMethod) { var block = (Block)parser.Result.Value; int index = parser.Result.Position; var closure = new Closure(new Namespace(), block, parameters, false); if (includeMultiMethod && multiMethodParser.Scan(source, index)) { var comparisand = (Block)multiMethodParser.Result.Value; Builder.AddMultiMethod(messageName, closure, comparisand, this); index = multiMethodParser.Result.Position; } else { Builder.AddMethod(messageName, closure, this); } overridePosition = index; return(new NullOp()); }