Ejemplo n.º 1
0
TopGenerator::TopGenerator(const DataMap &data) 
 : lang(data.getLang().lang)
 {
  DynArray<TypeDef::Kind *> kind_list(DoReserve,1024);
  
  for(auto &synt : data.getLang().synts.getRange() )
    for(auto &kind : synt.kinds.getRange() )
      kind_list.append_copy(&kind);
  
  ulen len=kind_list.getLen();
  
  table.extend_default(len);
  
  ulen count=0;
  
  while( count<len )
    {
     bool flag=false;
     
     for(ulen ind=count; ind<len ;ind++)
       {
        auto *kind=kind_list[ind];
       
        if( auto *rule=findRule(kind) )
          {
           defRule(kind,rule);
           
           if( ind>count ) Swap(kind_list[ind],kind_list[count]);
           
           count++;
           flag=true;
          }
       }
     
     if( !flag )
       {
        Printf(Exception,"App::TopGenerator::TopGenerator(...) : bad lang");
       }
    }
 }
Ejemplo n.º 2
0
TopParser::TopParser(const DataMap &data)
 : start_state(data.getLang().states.getRange().ptr), 
   lang(data.getLang().lang)
 {
  reset();
 }