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)); }
public bool Parse(string source, ref int index, out Block condition, out Block where) { var input = source.Sub(index); if (matcher.IsMatch(input, @"^\s*{")) { Runtime.Assert(blockParser.Scan(source, index), LOCATION, ERROR_MESSAGE); var result = blockParser.Result; index = result.Position; Block = (Block)result.Value; MultiCapable = true; condition = null; where = null; return(true); } if (matcher.IsMatch(input, @"^\s*=\s*")) { var length = matcher[0].Length; Parser.Color(index, length, IDEColor.EntityType.Structure); index += length; Block = OneLineBlockParser.Parse(source, ref index, false); MultiCapable = false; Block newBlock; if (createCondition(Block, out newBlock, out condition, out where)) { Block = newBlock; } return(true); } condition = null; where = null; return(false); }
public override Verb CreateVerb(string[] tokens) { var tokens1Length = tokens[1].Length; Color(position, tokens1Length, Structures); if (lambdaParser.Scan(source, position + tokens1Length)) { result.Value = lambdaParser.Result.Value; overridePosition = lambdaParser.Result.Position; return(new NullOp()); } return(null); }
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); }