public Signature(String name, Access access, IParseFunction func, Boolean isMemoized) { this.Name = name; this.Access = access; this.Func = func; this.IsMemoized = isMemoized; }
private static Invoker CreateStatelessInvoker(String baseName) => (i, p, s, f) => $"{baseName}({i}, {p})"; // Invocation private Boolean AddSignature(IParseFunction target, Access access, Boolean requiresGeneration) { if (requiresGeneration || this.mustAddSignature) { this.signatures.Add(new Signature(baseName, access, target, isMemoized)); return(true); } return(false); }
private void BasicTargetWithInterfaceMethod(IParseFunction target, InterfaceMethod interfaceMethod, Signature signature) { var resultName = "r"; var nodeName = $"{resultName}.Node"; var invoker = this.invokers[target]; writer.VarAssign(resultName, invoker("input", "inputPosition", "states", "factory")); // Invocation writer.IfNullReturnNull(resultName); var decl = new Decl(target.ReturnType, nodeName); var returnExpression = GetReturnExpression(target.ReturnType, new[] { decl }, $"{resultName}.Advanced", "factory", interfaceMethod); if (signature.IsMemoized) { var memField = NameGen.MemoizedFieldName(signature.Name); returnExpression = $"states[inputPosition].{memField} = {returnExpression}"; } writer.Return(returnExpression); }
public (IParseFunction, IReadOnlyList <InterfaceMethod>) Visit(Selection target, INodeType input) { var interfaceMethods = new List <InterfaceMethod>(); var newSteps = new List <SelectionStep>(); foreach (var step in target.Steps) { IParseFunction func = step.Function; INodeType funcReturnType = func.ReturnType; InterfaceMethod interfaceMethod = null; if (input != EmptyNodeType.Instance) { var name = $"{interfaceMethodName}{++count}"; interfaceMethod = new InterfaceMethod(input, name, GetParameterTypesFromReturnType(funcReturnType)); interfaceMethods.Add(interfaceMethod); } var newStep = new SelectionStep(func, interfaceMethod); newSteps.Add(newStep); } return(new Selection(newSteps), interfaceMethods); }
private void AddInvoker(IParseFunction target, Invoker invoker) { this.invokers[target] = invoker; }
public SequenceStep(IParseFunction parseFunction, MatchAction matchAction) { this.Function = parseFunction; this.MatchAction = matchAction; }
public Series(IParseFunction repeatedToken, IParseFunction delimiterToken, InterfaceMethod interfaceMethod) { this.RepeatedToken = repeatedToken; this.DelimiterToken = delimiterToken; this.InterfaceMethod = interfaceMethod; }
public Repetition(IParseFunction innerParseFunction, Cardinality cardinality, InterfaceMethod interfaceMethod) { this.InnerParseFunction = innerParseFunction; this.Cardinality = cardinality; this.InterfaceMethod = interfaceMethod; }
public SelectionStep(IParseFunction parseFunction, InterfaceMethod interfaceMethod) { this.Function = parseFunction; this.InterfaceMethod = interfaceMethod; }
public static Rule WithParseFunction(this Rule rule, IParseFunction func) => new Rule(rule.RuleIdentifier, rule.ReturnType, func);
public Rule(String ruleIdentifier, INodeType returnType, IParseFunction parseFunction) { this.RuleIdentifier = ruleIdentifier; this.ReturnType = returnType; this.ParseFunction = parseFunction; }