Exemplo n.º 1
0
        static void getChildren(string source, ref int index, Values.XML xml)
        {
            Parser parser = new XMLParser();

            while (parser.Scan(source, index))
            {
                xml.AddChild((Values.XML)parser.Result.Value);
                index = parser.Result.Position;
            }

            var matcher = new Matcher();

            if (matcher.IsMatch(source.Substring(index), @"^\s*<%%"))
            {
                var openLength = matcher[0].Length;
                Color(index, openLength, IDEColor.EntityType.Structure);
                index       += openLength;
                xml.Children = OrangeCompiler.Block(source, ref index, "%>");
            }

            parser = new IndirectXMLParser();
            while (parser.Scan(source, index))
            {
                xml.AddChild((Values.XML)parser.Result.Value);
                index = parser.Result.Position;
            }
        }
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, tokens[1].Length, IDEColor.EntityType.Verb);
            Color(tokens[2].Length, IDEColor.EntityType.Structure);
            var index         = position + length;
            var block         = OrangeCompiler.Block(source, ref index, true);
            var parameterList = ParameterParser.GetParameterList(block);
            var parameters    = new Parameters(new[]
            {
                new Parameter(""),
                new Parameter(""),
                new Parameter("")
            });

            if (parser.Scan(source, index))
            {
                block = (Block)parser.Result.Value;
                index = parser.Result.Position;
            }
            else
            {
                block = null;
            }
            overridePosition = index;
            var unpackedVariables = parameterList.Select(t => t.Name).ToList();

            return(new PushArrayParameters(parameters, block, unpackedVariables));
        }
Exemplo n.º 3
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, tokens[1].Length, IDEColor.EntityType.KeyWord);
            var index = position + length;

            if (closureParser.Scan(source, index))
            {
                var closure = (Closure)(closureParser.Result.Value);
                index = closureParser.Result.Position;
                if (matcher.IsMatch(source.Substring(index), @"^(\s*until)(\s*\()"))
                {
                    Color(index, matcher[0, 1].Length, IDEColor.EntityType.KeyWord);
                    Color(matcher[0, 2].Length, IDEColor.EntityType.Structure);
                    index += matcher[0].Length;
                    var checkExpression = OrangeCompiler.Block(source, ref index);
                    if (matcher.IsMatch(source.Substring(index), @"^(\s*then)(\s*\()"))
                    {
                        Color(index, matcher[0, 1].Length, IDEColor.EntityType.KeyWord);
                        Color(matcher[0, 2].Length, IDEColor.EntityType.Structure);
                        index += matcher[0].Length;
                        var finalValue = OrangeCompiler.Block(source, ref index);
                        overridePosition = index;
                        return(new TailCall(closure, checkExpression, finalValue));
                    }
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        public static Block Parse(string source, ref int position, bool addEnd)
        {
            var block = OrangeCompiler.Block(source, ref position, Runtime.REGEX_END, OrangeCompiler.ConsumeEndOfBlockType.SingleLine);

            if (addEnd)
            {
                block.Add(new End());
            }
            return(block);
        }
Exemplo n.º 5
0
        public override Verb CreateVerb(string[] tokens)
        {
            Color(position, length, IDEColor.EntityType.Structure);
            var index = position + length;
            var block = OrangeCompiler.Block(source, ref index, ")");

            result.Value     = block;
            overridePosition = index;
            return(new NullOp());
        }
Exemplo n.º 6
0
        public override Verb CreateVerb(string[] tokens)
        {
            var tokens1Length = tokens[1].Length;

            Color(position, tokens1Length, IDEColor.EntityType.Variable);
            Value value;

            if (tokens[2] == "(")
            {
                Color(1, IDEColor.EntityType.Structure);
                var index = position + tokens1Length + 1;
                var block = OrangeCompiler.Block(source, ref index, ")", true);
                overridePosition = index;
                value            = new FieldBlockVariable(block);
            }
            else
            {
                Color(tokens[2].Length, IDEColor.EntityType.Number);
                var index = tokens[2].ToInt();
                value = new FieldVariable(index);
            }
            result.Value = value;
            return(new Push(value));
        }