public override void CheckLL1(ParseNode_Root parser) { foreach (var rule in m_lsRule) { rule.CheckLL1(this); } }
public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { if (FirstSet == null) { FirstSet = new TokenSet(); foreach (var t in nodes) { if (t is ParseNode_ManyOpt_If) { continue; } var set = t.Init_PreCheckSet(parser); if (FirstSet.Accepts(set)) { Debug.LogError(this + ": ambiguous alternatives"); Debug.LogWarning(FirstSet.Intersecton(set).ToString(parser)); } FirstSet.Add(set); } foreach (var t in nodes) { if (t is ParseNode_ManyOpt_If) { var set = t.Init_PreCheckSet(parser); FirstSet.Add(set); } } } return(FirstSet); }
public string ToString(ParseNode_Root parser) { if (cached != null) { return(cached); } var result = new StringBuilder(); var delim = string.Empty; if (empty) { result.Append("[empty]"); delim = ", "; } if (set != null) { for (var n = 0; n < set.Count; ++n) { if (set.Get(n)) { result.Append(delim + parser.GetToken(n)); delim = n == set.Count - 2 ? ", or " : ", "; } } } else if (tokenId >= 0) { result.Append(delim + parser.GetToken(tokenId)); } return(cached = result.ToString()); }
// subtree gets succ. public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { Init_PreCheckSet(parser); FollowSet = succ; node.Init_FollowSet(parser, succ); return(FirstSet); }
public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { if (FirstSet == null) { FirstSet = new TokenSet(); if (nodes.Count == 0) { FirstSet.AddEmpty(); } else { for (int i = 0; i < nodes.Count; ++i) { var t = nodes[i]; var set = t.Init_PreCheckSet(parser); FirstSet.Add(set); if (!set.ContainsEmpty()) { FirstSet.RemoveEmpty(); break; } } } } return(FirstSet); }
public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { foreach (var rule in m_lsRule) { rule.Init_PreCheckSet(this); } return(null); }
public override void CheckLL1(ParseNode_Root parser) { if (!contextualKeyword) { base.CheckLL1(parser); rhs.CheckLL1(parser); } }
// lookahead doesn't include empty. public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { if (FirstSet == null) { FirstSet = new TokenSet(node.Init_PreCheckSet(parser)); } return(FirstSet); }
public override void CheckLL1(ParseNode_Root parser) { base.CheckLL1(parser); foreach (var t in nodes) { t.CheckLL1(parser); } }
public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { if (nodePredicate != null && nodePredicate.FollowSet == null) { nodePredicate.Init_FollowSet(parser, new TokenSet()); } return(base.Init_FollowSet(parser, succ)); }
public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { if (FirstSet == null) { base.Init_PreCheckSet(parser); FirstSet.Add(new TokenSet(parser.TokenToId("IDENTIFIER"))); } return(FirstSet); }
// subtree is checked. public override void CheckLL1(ParseNode_Root parser) { // trust the predicate! //base.CheckLL1(parser); if (FollowSet == null) { throw new Exception(this + ": follow not set"); } node.CheckLL1(parser); }
public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { Init_PreCheckSet(parser); if (LinkedTarget is ParseNode_Rule) { LinkedTarget.Init_FollowSet(parser, succ); } return(FirstSet); }
public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { Init_PreCheckSet(parser); FollowSet = succ; foreach (var node in nodes) { node.Init_FollowSet(parser, succ); } return(FirstSet); }
public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { if (FirstSet == null) { if (inProgress) { throw new Exception(m_sNtName + ": recursive lookahead"); } inProgress = true; FirstSet = rhs.Init_PreCheckSet(parser); } return(FirstSet); }
public virtual void CheckLL1(ParseNode_Root parser) { if (FollowSet == null) { throw new Exception(this + ": follow not set"); } if (FirstSet.ContainsEmpty() && FirstSet.Accepts(FollowSet)) { throw new Exception(this + ": ambiguous\n" + " lookahead " + FirstSet.ToString(parser) + "\n" + " follow " + FollowSet.ToString(parser)); } }
public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { if (FollowSet == null) { followChanged = true; FollowSet = new TokenSet(succ); } else if (FollowSet.Add(succ)) { followChanged = true; } return(FirstSet); }
public string ToString(ParseNode_Root parser) { var result = new StringBuilder(m_sNtName + " : " + rhs + " ."); if (FirstSet != null) { result.Append("\n lookahead " + FirstSet.ToString(parser)); } if (FollowSet != null) { result.Append("\n follow " + FollowSet.ToString(parser)); } return(result.ToString()); }
public void _InitFollowSet_(ParseNode_Root parser) { if (FirstSet == null) { throw new Exception(m_sNtName + ": lookahead not set"); } if (FollowSet == null) { return;// throw new Exception(nt + ": not connected"); } if (inProgress) { rhs.Init_FollowSet(parser, FollowSet); } }
public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { Init_PreCheckSet(parser); FollowSet = succ; for (var n = nodes.Count; n-- > 0;) { var prev = nodes[n].Init_FollowSet(parser, succ); if (prev.ContainsEmpty()) { prev = new TokenSet(prev); prev.RemoveEmpty(); prev.Add(succ); } succ = prev; } return(FirstSet); }
public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { if (FirstSet == null) { LinkedTarget = parser.GetRuleOrTakenCopy(Name); if (LinkedTarget == null) { Debug.LogError("Parser rule \"" + Name + "\" not found!!!"); } else { LinkedTarget.parent = this; LinkedTarget.childIndex = 0; FirstSet = LinkedTarget.Init_PreCheckSet(parser); } } return(FirstSet); }
public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { Rule_Start._InitFollowSet_(); bool followChanged; do { foreach (var rule in m_lsRule) { rule._InitFollowSet_(this); } followChanged = false; foreach (var rule in m_lsRule) { followChanged |= rule.FollowChanged(); } } while (followChanged); return(null); }
public abstract TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ);
// follow is not set; nothing to check. public override void CheckLL1(ParseNode_Root parser) { }
// follow doesn't need to be set. public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { return(FirstSet); }
public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { return(FirstSet ?? (FirstSet = new TokenSet(parser.TokenToId(body)))); }
public abstract TokenSet Init_PreCheckSet(ParseNode_Root parser);
// returns a one-element set, // initialized by the parser. public override TokenSet Init_PreCheckSet(ParseNode_Root parser) { return(FirstSet); }
public override TokenSet Init_FollowSet(ParseNode_Root parser, TokenSet succ) { return(Init_PreCheckSet(parser)); }