// MAKE_NODE(B ::= αx · β, j, i, w, v, V) { private SppfNode MakeNodeSimplified(DecoratedProduction decoratedProduction, int j, int i, SppfNode w, SppfNode v) { SppfNode y; Production production = null; // if β = ϵ { let s = B } else { let s = (B ::= αx · β) } if (decoratedProduction.AtEnd) { // s = ValueTuple.Create<Word, DecoratedProduction>(decoratedProduction.Production.Lhs, null); y = _V.GetOrSet(decoratedProduction.Production.Lhs, j, i); production = decoratedProduction.Production; } else { // s = ValueTuple.Create<Word, DecoratedProduction>(null, decoratedProduction); y = _V.GetOrSet(decoratedProduction, j, i); } // if w = null and y does not have a family of children (v) add one if (w == null) { y.AddFamily(production, v); } // if w ̸= null and y does not have a family of children(w, v) add one else { y.AddFamily(production, w, v); } return(y); }
internal SppfBranch GetOrSet(DecoratedProduction item, int j, int i) { var tup = ValueTuple.Create(item, j, i); SppfBranch y; if (!_prodDict.TryGetValue(tup, out y)) { var newY = new SppfBranch(item, j, i); _prodDict[tup] = newY; y = newY; } return(y); }
public EarleyItem(DecoratedProduction decoratedProduction, int startPosition, SppfNode sppfNode) { if (decoratedProduction == null) { throw new ArgumentNullException(); } DecoratedProduction = decoratedProduction; StartPosition = startPosition; SppfNode = sppfNode; unchecked { int hash = 17; hash = hash * 23 + this.DecoratedProduction.GetHashCode(); hash = hash * 23 + this.StartPosition.GetHashCode(); _cachedHash = hash; } }
// MAKE_NODE(B ::= αx · β, j, i, w, v, V) { private SppfNode MakeNodeOriginal(DecoratedProduction decoratedProduction, int j, int i, SppfNode w, SppfNode v) { // var α = decoratedProduction.Prefix; // if α = ϵ and β ̸= ϵ { let y = v } if (decoratedProduction.CurrentPosition == 1 && !decoratedProduction.AtEnd) { return(v); } Production production = null; SppfNode y; // if β = ϵ { let s = B } else { let s = (B ::= αx · β) } // if there is no node y ∈ V labelled (s,j,i) create one and add it to V if (decoratedProduction.AtEnd) { production = decoratedProduction.Production; var s = production.Lhs; y = _V.GetOrSet(s, j, i); } else { var s = decoratedProduction; y = _V.GetOrSet(s, j, i); } // if w = null and y does not have a family of children (v) add one if (w == null) { y.AddFamily(production, v); } // if w ̸= null and y does not have a family of children(w, v) add one else { y.AddFamily(production, w, v); } return(y); }
// MAKE_NODE(B ::= αx · β, j, i, w, v, V) { private SppfNode MakeNode(DecoratedProduction decoratedProduction, int j, int i, SppfNode w, SppfNode v) { return(MakeNodeOriginal(decoratedProduction, j, i, w, v)); }