protected EarleyItem(DottedRule dottedRule, int origin, IForestNode parseNode) { DottedRule = dottedRule; Origin = origin; ParseNode = parseNode; this.hashCode = (DottedRule, Origin).GetHashCode(); }
private int ComputeHashCode() { return(HashCode.Compute( DottedRule.GetHashCode(), Origin.GetHashCode(), Recognized.GetHashCode(), Reduction.GetHashCode(), Index.GetHashCode())); }
private void Seed(IEnumerable <Production> productions) { foreach (var production in productions) { var rules = new DottedRule[production.Count + 1]; this.index.Add(production, rules); for (var dot = 0; dot <= production.Count; dot++) { rules[dot] = new DottedRule(production, dot); } } }
public bool Contains(DottedRule dottedRule, int origin) { if (dottedRule.IsComplete) { return(CompletionContains(dottedRule, origin)); } var currentSymbol = dottedRule.PostDotSymbol; return(currentSymbol is NonTerminal ? PredictionsContains(dottedRule, origin) : ScansContains(dottedRule, origin)); }
public EarleyItem NewState(DottedRule dottedRule, int origin, IForestNode parseNode = null) { if (dottedRule.IsComplete) { return(new CompletedState(dottedRule, origin, parseNode)); } if (dottedRule.PostDotSymbol is NonTerminal) { return(new PredictionState(dottedRule, origin, parseNode)); } return(new ScanState(dottedRule, origin, parseNode)); }
public bool Contains(DottedRule rule, int origin) { return(this.lookup.TryGetValue(rule, out var origins) && origins.TryGetValue(origin, out var _)); }
public PredictionState(DottedRule dottedRule, int origin, IForestNode parseNode) : base(dottedRule, origin, parseNode) { }
public DottedRule GetNext(DottedRule dottedRule) { return(Get(dottedRule.Production, dottedRule.Dot + 1)); }
private bool ScansContains(DottedRule rule, int origin) { return(this.scans.Contains(rule, origin)); }
private bool PredictionsContains(DottedRule rule, int origin) { return(this.predictions.Contains(rule, origin)); }
private bool CompletionContains(DottedRule rule, int origin) { return(this.completions.Contains(rule, origin)); }
protected override bool ThisEquals(EarleyItem other) { return(DottedRule.Equals(other.DottedRule) && Origin.Equals(other.Origin)); }
public bool Contains(int location, DottedRule dottedRule, int origin) { return(GetEarleySet(location).Contains(dottedRule, origin)); }
public CompletedState(DottedRule dottedRule, int origin, IForestNode parseNode) : base(dottedRule, origin, parseNode) { }