public override Verb CreateVerb(string[] tokens) { var matcher = new Matcher(); Color(position, length, Structures); var index = position + length; var parameters = new Parameters(); if (variableParser.Scan(source, index)) { var parserResult = variableParser.Result; var value = parserResult.Value; var variable = value.As <Variable>(); if (variable.IsSome) { parameters = new Parameters(new[] { new Parameter(variable.Value.Name) }); index = parserResult.Position; } else { return(null); } } else if (matcher.IsMatch(source.Skip(index), @"^ /s* '('")) { var matcherLength = matcher[0].Length; Color(matcherLength, Structures); index += matcherLength; var patternParametersParser = new ParametersParser(ParametersType.Pattern); if (patternParametersParser.Parse(source, ref index)) { parameters = patternParametersParser.Parameters; } else { return(null); } } var block = anyBlockParser.Parse(source, ref index, false); if (block == null) { return(null); } var spatting = anyBlockParser.Splatting; overridePosition = index; return(new CreateLambda(parameters, block, spatting)); }
public override Verb CreateVerb(string[] tokens) { Color(position, length, IDEColor.EntityType.Structure); var index = position + length; var block = blockParser.Parse(source, ref index, false); block.Stem = true; result.Value = block; overridePosition = index; return(new NullOp()); }
public Block Parse(string source, ref int index) { if (matcher.IsMatch(source.Substring(index), Runtime.REGEX_STEM)) { var length = matcher[0].Length; Parser.Color(index, length, IDEColor.EntityType.Structure); index += length; return(blockParser.Parse(source, ref index, false)); } return(null); }
public override Verb CreateVerb(string[] tokens) { Color(position, tokens[0].Length, IDEColor.EntityType.KeyWord); var type = tokens[1]; var index = position + length; var block = anyBlockParser.Parse(source, ref index, false); overridePosition = index; result.Value = block; return(new Signal(type, block)); }
public override Verb CreateVerb(string[] tokens) { Color(position, length, IDEColor.EntityType.Structure); var parser = new AnyBlockParser(); var index = position + length; bool isMacro; result.Value = parser.Parse(source, ref index, false, out isMacro); overridePosition = index; MultiCapable = !parser.SingleLine; return(new NullOp()); }
public override Verb CreateVerb(string[] tokens) { Color(position, length, IDEColor.EntityType.KeyWord); var index = position + length; var block = anyBlockParser.Parse(source, ref index, false); result.Verbs = new List <Verb> { new Then(), new Push(block) }; overridePosition = index; return(new NullOp()); }
public Block Parse(string source, ref int index, out bool isMacro, out bool splatting) { isMacro = false; var input = source.Substring(index); if (matcher.IsMatch(input, "^ /s* ['=-'] '>'")) { var length = matcher[0].Length; Parser.Color(index, length, IDEColor.EntityType.Structure); index += length; var block = blockParser.Parse(source, ref index, false); splatting = blockParser.Splatting; return(block); } splatting = false; return(null); }
public override Verb CreateVerb(string[] tokens) { Color(position, tokens[1].Length, KeyWords); var index = position + length; Block condition; var comparisand = ComparisandParser.Parse(source, ref index, out condition, @"^ /s* [':{']"); if (source.Substring(index - 1, 1) == ":") { index--; } var block = anyBlockParser.Parse(source, ref index, false); if (block == null) { return(null); } overridePosition = index; return(new CaseExecute(comparisand, block, tokens[1].EndsWith("required"), condition)); }
public override Verb CreateVerb(string[] tokens) { Color(position, length, Structures); var index = position + length; var parametersParser = new ParametersParser(); if (parametersParser.Parse(source, ref index)) { var parameters = parametersParser.Parameters; var block = blockParser.Parse(source, ref index, false); overridePosition = index; var unpackedVariables = new List <string>(); if (parameters.Length > 3) { for (var i = 3; i < parameters.Length; i++) { unpackedVariables.Add(parameters[i].Name); } } parameters.Splatting = blockParser.Splatting; return(new PushArrayParameters(parameters, block, unpackedVariables)); } return(null); }