Example #1
0
        public Block Parse(string source, ref int position, bool addEnd)
        {
            IsMacro   = false;
            Splatting = false;
            if (source.Skip(position).IsMatch("^ /s* ['{(']"))
            {
                var blockParser = new BlockParser(true);
                if (blockParser.Scan(source, position))
                {
                    position   = blockParser.Result.Position;
                    SingleLine = false;
                    Splatting  = false;
                    return((Block)blockParser.Result.Value);
                }
                Splatting = false;
                return(null);
            }
            if (source.Skip(position).IsMatch("^ /s* '.('"))
            {
                var macroParser = new MacroLiteralParser();
                if (macroParser.Scan(source, position))
                {
                    position   = macroParser.Result.Position;
                    SingleLine = false;
                    IsMacro    = true;
                    Splatting  = false;
                    return((Block)macroParser.Result.Value);
                }
            }
            SingleLine = true;
            Splatting  = false;
            if (bridge.IsNotEmpty())
            {
                if (matcher.IsMatch(source.Substring(position), bridge))
                {
                    var length = matcher[0].Length;
                    Parser.Color(length, Structures);
                    position += length;
                    Splatting = matcher.GroupCount(0) > 1 && matcher[0, 1] == "=>";
                }
                else
                {
                    return(null);
                }
            }
            var oneLineBlockParser = new OneLineBlockParser(addEnd);

            return(oneLineBlockParser.Parse(source, ref position) ? oneLineBlockParser.Block : null);
        }
Example #2
0
        static Value getInnerText(string source, ref int index)
        {
            Parser parser    = new StringParser();
            var    innerText = Parse(parser, source, ref index);

            if (innerText != null)
            {
                return(innerText);
            }
            parser    = new InterpolatedStringParser();
            innerText = Parse(parser, source, ref index);
            if (innerText != null)
            {
                return(innerText);
            }
            parser    = new BlockParser(false);
            innerText = Parse(parser, source, ref index);
            return(innerText);
        }
 public ArrayFieldsParameterParser()
     : base(@"^(\s*->)(\s*\|:)")
 {
     parser = new BlockParser();
 }
 public AttachedLambdaParser()
     : base("^ /(/s* '.') '{' ['|<']")
 {
     lambdaParser = new BlockParser(false);
 }
Example #5
0
 public FunctionBodyParser2()
 {
     matcher     = new Matcher();
     blockParser = new BlockParser(false);
 }