ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/selection/SelectionCompiler.cpp
(Generate patch)

Comparing trunk/OOPSE-3.0/src/selection/SelectionCompiler.cpp (file contents):
Revision 1965 by tim, Wed Feb 2 23:13:11 2005 UTC vs.
Revision 1967 by tim, Thu Feb 3 23:14:05 2005 UTC

# Line 560 | Line 560 | bool SelectionCompiler::clausePrimitive() {
560      switch (tok) {
561          case Token::within:
562              return clauseWithin();
563 <        case Token::name :
564 <            return clauseName(Token::name);
565 <        case Token::index :
566 <            return clauseIndex(Token::index);
567 <        case Token::molname :
568 <            return clauseName(Token::molname);
569 <        case Token::molindex :
570 <            return clauseIndex(Token::molindex);
571 <            
563 >
564 >        case Token::asterisk:
565 >        case Token::identifier:
566 >            return clauseChemObjName();
567 >      
568          default:
569              if ((tok & Token::atomproperty) == Token::atomproperty) {
570                  return clauseComparator();
# Line 646 | Line 642 | bool SelectionCompiler::clauseWithin() {
642      
643      return addTokenToPostfix(Token(Token::within, distance));
644   }
645 +
646 + bool SelectionCompiler::clauseChemObjName() {
647 +    std::string chemObjName;
648 +    int tok = tokPeek();
649 +    if (!clauseName(chemObjName)){
650 +        return false;
651 +    }
652  
653  
654 < bool SelectionCompiler:: clauseName(int tok) {
655 <    Token tokenName = tokenNext();
656 <    std::string name = boost::any_cast<std::string>(tokenName.value);
657 <    return addTokenToPostfix(Token(tok, name)); /**@todo */
658 <
654 >    tok = tokPeek();
655 >    //allow two dot at most
656 >    if (tok == Token::dot) {
657 >        if (!clauseName(chemObjName)) {
658 >            return false;
659 >        }
660 >        tok = tokPeek();
661 >        if (tok == Token::dot) {
662 >            if (!clauseName(chemObjName)) {
663 >                return false;
664 >            }
665 >        }        
666 >    }
667 >
668 >    return addTokenToPostfix(Token(Token::name, chemObjName));
669   }
670  
671 < bool SelectionCompiler:: clauseIndex(int tok) {
672 <    //return addTokenToPostfix(Token(tok, )); /**@todo*/
673 <    return true;
671 > bool SelectionCompiler:: clauseName(std::string& name) {
672 >
673 >    int tok = tokPeek();
674 >
675 >    if (tok == Token::asterisk || tok == Token::identifier) {
676 >        name += boost::any_cast<std::string>(tokenNext().value);
677 >        
678 >        while(true){
679 >            tok = tokPeek();
680 >            switch (tok) {
681 >                case Token::asterisk :
682 >                    name += "*";
683 >                    tokenNext();
684 >                    break;
685 >                case Token::identifier :
686 >                    name += boost::any_cast<std::string>(tokenNext().value);
687 >                    break;
688 >                case Token::integer :
689 >                    name += toString(boost::any_cast<int>(tokenNext().value));
690 >                    break;
691 >                case Token::dot :
692 >                    return true;
693 >                default :
694 >                    return true;
695 >            }
696 >        }
697 >        
698 >    }else {
699 >        return false;
700 >    }
701 >
702   }
703  
704 +
705   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines