Changeset 589249e in tol


Ignore:
Timestamp:
Apr 3, 2009, 5:27:39 PM (18 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
e0792b1
Parents:
299cfe9
Message:

Fixes #674

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@876 be4846ae-f051-483a-831f-b64e7d08527f

Location:
tol
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tol/bparser/par.cpp

    r299cfe9 r589249e  
    894894  else
    895895  {
    896 
    897896    if(NextSymbol()->Name()==";")
    898897    {
  • tol/btol/bgrammar/class.cpp

    r299cfe9 r589249e  
    8080    if(expression[0]=='[')
    8181    {
    82       expression = expression.SubString(2,expression.Length()-4);
     82      expression = expression.SubString(2,expression.Length()-3);
    8383    }
    8484    else if(expression[0]=='{')
  • tol/btol/bgrammar/graimp.cpp

    r299cfe9 r589249e  
    540540//--------------------------------------------------------------------
    541541{
     542  static BEqualOperator* BNameBlock_BEqualOperator =
     543    (BEqualOperator*)GraNameBlock()->FindOperator("=");
    542544  static BText none;
    543545  eval_depth_t eval_depth_helper;
    544546  bool error = false;
    545547  BGrammar* newGrammar = NIL;
     548  BClass* newClass = NIL;
    546549  BBool enableCasting=BTRUE;
    547550  bool isCreatingNameBlock = BEqualOperator::IsCreatingNameBlock();
    … …  
    574577  int stackPos = -1;
    575578
    576   if((this==GraNameBlock()) && (name=="SetOfAnything"))
     579  if((this==GraNameBlock()) &&
     580    ((name=="SetOfAnything")||(name=="#DefaultInstance")))
    577581  {
    578582    return(BNameBlock::EvaluateTree(tre));
    … …  
    669673    }
    670674  }
     675  else if((type == TYPE) && (newClass=FindClass(name)))
     676  {
     677    result = BNameBlock_BEqualOperator->Evaluate(tre);
     678  }
    671679  else if (type == BINARY && this == GraAnything() &&
    672680           name != "=" && name != "#F#" &&
  • tol/btol/bgrammar/nameblock.cpp

    r299cfe9 r589249e  
    261261{
    262262  int n;
     263  BToken* tok = (BToken*)_tre->car();
     264  bool isDefaultInstance = tok->Name()=="#DefaultInstance";
    263265  BText name  = BEqualOperator::CreatingName();
    264266  BText fullName = BEqualOperator::CurrentFullName();
    … …  
    316318    else
    317319    {
    318       List* tre = _tre->duplicate();
     320      List* tre = NULL;
     321      if(!isDefaultInstance) { tre = _tre->duplicate(); }
    319322      newNameBlock.PutTree(tre);
     323      newNameBlock.CreateParentHashes();
     324      newNameBlock.CreateMemberHashes();
    320325      newNameBlock.AddParent((BClass*)cls);
    321       newNameBlock.AddMemberList(tre->cdr());
     326      if(!isDefaultInstance) {
     327      //Std(BText("BNameBlock::EvaluateTree:\n")+BParser::treWrite((List*)tre,"  "));
     328        newNameBlock.AddMemberList(tre->cdr());
     329      }
    322330      newNameBlock.SortMembers();
    323331      int stackPos = BGrammar::StackSize();
    324 
    325332
    326333      if(newNameBlock.isGood_ && newNameBlock.mbrDecHash_->size())
  • tol/btol/bgrammar/oprimp.cpp

    r299cfe9 r589249e  
    811811  BStruct* str = NULL;
    812812  BClass*  cls = NULL;
    813   BGrammar* gra = GetLeft(Grammar(),
    814                           Tree::treNode((List*) argList),
    815                           name, rest, str, cls);
     813
     814  bool carIsList = argList->car()->IsListClass();
     815  List* dec = carIsList?Tree::treNode((List*) argList):(List*)argList;
     816  BGrammar* gra = GetLeft(Grammar(), dec, name, rest, str, cls);
     817  List* left = NULL;
     818  bool defInst = false;
     819  if(!carIsList && cls && !rest)
     820  {
     821    defInst = true;
     822    BToken* tok = new BToken("#DefaultInstance",ARGUMENT);
     823    left = new List(tok, NIL);
     824  }
     825  else
     826  {
     827    left = Tree::treLeft((List*)argList);
     828  }
    816829  creatingClass_ = NULL;
    817830  bool oldIsCreatingNameBlock = isCreatingNameBlock_;
    … …  
    840853  if(!rest && gra)
    841854  {
    842           result = CreateObject(Tree::treLeft((List*)argList), gra, name);
     855    if(defInst)
     856    {
     857            result = CreateObject(left, gra, name);
     858    }
     859    else
     860    {
     861            result = CreateObject(left, gra, name);
     862    }
    843863    if(str && result)
    844864    {
    … …  
    871891    creatingClass_   = oldClass;
    872892    isCreatingNameBlock_ = oldIsCreatingNameBlock;
     893  }
     894  if(defInst)
     895  {
     896    DESTROY(left);
    873897  }
    874898  return(result);
Note: See TracChangeset for help on using the changeset viewer.