Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 public void add(TableIndex i, TableItem a)
 {
     if (dic.ContainsKey(i))
     {
         if (dic[i].Equals(a)) return;
         else throw new Exception("写入分析表冲突,该文法不是LR(1)文法");
     }
     else
     {
         dic.Add(i, a);
     }
 }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
 public void add(TableIndex i, TableItem a)
 {
     if (dic.ContainsKey(i))
     {
         if (dic[i].Equals(a))
         {
             return;
         }
         else
         {
             throw new Exception("写入分析表冲突,该文法不是LR(1)文法");
         }
     }
     else
     {
         dic.Add(i, a);
     }
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 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();
 }