Ejemplo n.º 1
0
        public void cm_AddAction(cLexem a_action)
        {
            if (a_action.cp_Type != eLexType.Action)
            {
                throw new Exception("Попытка добавить к лексеме " + cf_Name + " в качестве действия лексему типа " + cp_Type.ToString());
            }
            cProduction _production = cf_listProducts[cf_listProducts.Count - 1];

            _production.cm_AddAction(a_action);
        }
Ejemplo n.º 2
0
 public void cm_AddChildLexem(cLexem a_lexem, bool a_newProduct)
 {
     if (a_lexem.cp_Type == eLexType.Action)
     {
         throw new Exception("Попытка добавить к продукции лексемы " + cf_Name + " лексему типа " + a_lexem.cp_Type.ToString());
     }
     if (a_newProduct)
     {
         cProduction _production = new cProduction(this);
         _production.cm_Add(a_lexem);
         cf_listProducts.Add(_production);
     }
     else
     {
         cProduction _production = cf_listProducts[cf_listProducts.Count - 1];
         _production.cm_Add(a_lexem);
     }
 }
Ejemplo n.º 3
0
 public static cConfiguration cm_GetConfiguration(cProduction a_production, int a_position, cLexem a_terminal)
 {
     if (!cf_configurationsCache.ContainsKey(a_production))
     {
         cf_configurationsCache.Add(a_production, new Dictionary <int, Dictionary <cLexem, cConfiguration> >());
     }
     if (!cf_configurationsCache[a_production].ContainsKey(a_position))
     {
         cf_configurationsCache[a_production].Add(a_position, new Dictionary <cLexem, cConfiguration>());
     }
     if (!cf_configurationsCache[a_production][a_position].ContainsKey(a_terminal))
     {
         if (a_production.cp_EpsilonProduct & (a_position != 0))
         {
             throw new Exception("Попытка создать некорректную конфигурацию из эпсилон-продукции");
         }
         cf_configurationsCache[a_production][a_position].Add(a_terminal, new cConfiguration(a_production, a_position, a_terminal));
     }
     return(cf_configurationsCache[a_production][a_position][a_terminal]);
 }
Ejemplo n.º 4
0
 private cConfiguration(cProduction a_production, int a_position, cLexem a_terminal)
 {
     cf_Production = a_production;
     cf_Position   = a_position;
     cf_Terminal   = a_terminal;
 }
Ejemplo n.º 5
0
 private cConfiguration(cProduction a_production, int a_position, cLexem a_terminal)
 {
     cf_Production = a_production;
     cf_Position = a_position;
     cf_Terminal = a_terminal;
 }
Ejemplo n.º 6
0
 public static cConfiguration cm_GetConfiguration(cProduction a_production, int a_position, cLexem a_terminal)
 {
     if (!cf_configurationsCache.ContainsKey(a_production))
     {
         cf_configurationsCache.Add(a_production, new Dictionary<int,Dictionary<cLexem,cConfiguration>>());
     }
     if (!cf_configurationsCache[a_production].ContainsKey(a_position))
     {
         cf_configurationsCache[a_production].Add(a_position,new Dictionary<cLexem, cConfiguration>());
     }
     if (!cf_configurationsCache[a_production][a_position].ContainsKey(a_terminal))
     {
         if (a_production.cp_EpsilonProduct & (a_position != 0))
         {
             throw new Exception("Попытка создать некорректную конфигурацию из эпсилон-продукции");
         }
         cf_configurationsCache[a_production][a_position].Add(a_terminal, new cConfiguration(a_production, a_position, a_terminal));
     }
     return cf_configurationsCache[a_production][a_position][a_terminal];
 }
Ejemplo n.º 7
0
 public void cm_AddChildLexem(cLexem a_lexem, bool a_newProduct)
 {
     if (a_lexem.cp_Type == eLexType.Action)
     {
         throw new Exception("Попытка добавить к продукции лексемы " + cf_Name + " лексему типа " + a_lexem.cp_Type.ToString());
     }
     if (a_newProduct)
     {
         cProduction _production = new cProduction(this);
         _production.cm_Add(a_lexem);
         cf_listProducts.Add(_production);
     }
     else
     {
         cProduction _production = cf_listProducts[cf_listProducts.Count - 1];
         _production.cm_Add(a_lexem);
     }
 }