private void A(AnalysisLog log) { log.Action = "acc"; log.GoTo = ""; }
private int S(string sentence, AnalysisLog log, int point, TableItem action) { log.Action = "S" + action.Detail; log.GoTo = ""; CharStack.Push(sentence[point++]); StatusStack.Push(action.Detail); return point; }
private void GoNext(string sentence, ref AnalysisLog log, ref int point, ref int index) { TableItem action; char input = sentence[point]; log = new AnalysisLog(++index,sentence.Substring(point), StackContent(StatusStack), StackContent(CharStack), string.Empty,string.Empty); action = Table.GetAction(new TableIndex(StatusStack.Peek(),input)); if (action.ActionType == 'A') { A(log); } else if (action.ActionType == 'S') { point = S(sentence, log, point, action); } else if (action.ActionType == 'R') { R(log, action); } }
private void R(AnalysisLog log, TableItem action) { log.Action = "R" + action.Detail; Production production = CFG._ProductionsMap[action.Detail]; char emptyChar = System.Configuration.ConfigurationManager.AppSettings["Empty"][0]; int num = production.Right == emptyChar.ToString() ? 0 : production.Right.Length; for (int i = 0; i < num; i++) { CharStack.Pop(); StatusStack.Pop(); } CharStack.Push(production.Left); action = Table.GetAction(new TableIndex(StatusStack.Peek(), production.Left)); StatusStack.Push(action.Detail); log.GoTo = action.Detail.ToString(); }