Esempio n. 1
0
        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 message = tokens[4];

            Color(message.Length, IDEColor.EntityType.Variable);
            Color(tokens[5].Length, IDEColor.EntityType.Verb);
            string super       = tokens[6];
            int    superLength = super.Length;

            if (superLength > 0)
            {
                Color(superLength - 1, IDEColor.EntityType.Variable);
                Color(1, IDEColor.EntityType.Verb);
            }
            string messageDelegatedTo = tokens[7];

            Color(messageDelegatedTo.Length, IDEColor.EntityType.Variable);
            Builder.AddDelegate(message, super + messageDelegatedTo, this);
            return(new NullOp());
        }
        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.Structure);

            var              compiler       = new OrangeCompiler(source, position + length);
            Block            parameterBlock = compiler.Compile();
            int              index          = compiler.Position;
            List <Parameter> parameterList  = ParameterParser.GetParameterList(parameterBlock);
            var              parameters     = new Parameters(parameterList);

            if (functionBodyParser.Scan(source, index))
            {
                return(createMethod(messageName, functionBodyParser, parameters, false));
            }
            return(equalBlockParser.Scan(source, index) ? createMethod(messageName, equalBlockParser, parameters, true) : null);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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];

            ClassParser.SetScopeAndVisibility(scope, visibility, this);
            Color(scope.Length, IDEColor.EntityType.Verb);
            string messageName = tokens[4];

            Color(messageName.Length, IDEColor.EntityType.Variable);
            Color(tokens[5].Length, IDEColor.EntityType.Verb);
            Builder.AddAbstractMessage(messageName, this);
            return(new NullOp());
        }
Esempio n. 6
0
        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);
            Color(tokens[6].Length, IDEColor.EntityType.Structure);

            int   index    = position + length;
            var   compiler = new OrangeCompiler(source, index);
            Block block    = compiler.Compile();

            result.Position = compiler.Position;
            Builder.AddInitializedVariable(messageName, block, this, null);
            return(new NullOp());
        }