private void buildOrPiece(BuildState state, p_OrPiece orPiece) { var curState = state.nextGoodState++; state.PushGoodLocation("endOfOr" + curState); state.PushBadLocation("curBad" + curState); var itms = Helper.CombineArray(orPiece.RuleExpression1, orPiece.RuleExpressions).ToArray(); int ind = 0; foreach (p_RuleExpression expression in itms) { var j = state.nextGoodState; state.PushBadLocation(string.Format("bottomPiece{0}", j)); buildRuleExpression(state, expression); state.PopBadLocation(); checkBuilder.AppendLine(string.Format("bottomPiece{0}:", j)); if (ind++ == itms.Length-1) checkBuilder.AppendLine("goto " + state.BadLocation() + ";"); else checkBuilder.AppendLine("goto nextPiece" + state.nextGoodState + ";"); } state.PopBadLocation(); state.PopGoodLocation(); checkBuilder.AppendLine("curBad" + curState + ": goto " + state.BadLocation(state.nextGoodState) + ";"); checkBuilder.AppendLine("endOfOr" + curState + ":"); checkBuilder.AppendLine(string.Format("goto {0};", state.GoodLocation)); }
private void buildOrPiece(BuildState state, p_OrPiece orPiece) { var curState = state.nextGoodState++; state.PushGoodLocation("endOfOr" + curState); state.PushBadLocation("curBad" + curState); var itms = Helper.CombineArray(orPiece.RuleExpression1, orPiece.RuleExpressions).ToArray(); int ind = 0; foreach (p_RuleExpression expression in itms) { var j = state.nextGoodState; state.PushBadLocation(string.Format("bottomPiece{0}", j)); buildRuleExpression(state, expression); state.PopBadLocation(); checkBuilder.AppendLine(string.Format("bottomPiece{0}:", j)); if (ind++ == itms.Length - 1) { checkBuilder.AppendLine("goto " + state.BadLocation() + ";"); } else { checkBuilder.AppendLine("goto nextPiece" + state.nextGoodState + ";"); } } state.PopBadLocation(); state.PopGoodLocation(); checkBuilder.AppendLine("curBad" + curState + ": goto " + state.BadLocation(state.nextGoodState) + ";"); checkBuilder.AppendLine("endOfOr" + curState + ":"); checkBuilder.AppendLine(string.Format("goto {0};", state.GoodLocation)); }
private p_OrPiece obtainOrPiece() { p_OrPiece orPiece = new p_OrPiece(); orPiece.RuleExpressions = new List <p_RuleExpression>(); { Debug.Assert(symbolGenerator.Advance().isSymbol("(")); orPiece.RuleExpression1 = obtainRuleExpression(); { while (true) { symbolGenerator.PushState(); if (symbolGenerator.Advance().isSymbol("|")) { if (resetState(checkRuleExpression)) { symbolGenerator.RestoreState(); orPiece.RuleExpressions.Add(obtainRuleExpression()); continue; } symbolGenerator.PopState(); break; } symbolGenerator.PopState(); break; } Debug.Assert(symbolGenerator.Advance().isSymbol(")")); goto goodDone; } } goodDone: return(orPiece); }
public p_RuleExpression_rulePiece_rule(p_RuleExpression_rulePiece_ruleType type, p_OrPiece obtainOrPiece) { ruleType = type; OrPiece = obtainOrPiece; }
private p_OrPiece obtainOrPiece() { p_OrPiece orPiece = new p_OrPiece(); orPiece.RuleExpressions = new List<p_RuleExpression>(); { Debug.Assert(symbolGenerator.Advance().isSymbol("(")); orPiece.RuleExpression1 = obtainRuleExpression(); { while (true) { symbolGenerator.PushState(); if (symbolGenerator.Advance().isSymbol("|")) { if (resetState(checkRuleExpression)) { symbolGenerator.RestoreState(); orPiece.RuleExpressions.Add(obtainRuleExpression()); continue; } symbolGenerator.PopState(); break; } symbolGenerator.PopState(); break; } Debug.Assert(symbolGenerator.Advance().isSymbol(")")); goto goodDone; } } goodDone: return orPiece; }