ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/selection/SelectionCompiler.cpp
(Generate patch)

Comparing trunk/src/selection/SelectionCompiler.cpp (file contents):
Revision 288 by tim, Fri Feb 4 22:39:26 2005 UTC vs.
Revision 415 by tim, Wed Mar 9 18:46:16 2005 UTC

# Line 118 | Line 118 | bool SelectionCompiler::internalCompile(){
118              //    continue;
119              //}
120              if (lookingAtDecimal((tokCommand & Token::negnums) != 0)) {
121 <                float value = lexi_cast<float>(script.substr(ichToken, ichToken + cchToken));          
122 <                ltoken.push_back(Token(Token::decimal, value));/**@todo*/
121 >                float value = lexi_cast<float>(script.substr(ichToken, cchToken));        
122 >                ltoken.push_back(Token(Token::decimal, boost::any(value)));
123                  continue;
124              }
125              if (lookingAtInteger((tokCommand & Token::negnums) != 0)) {
126 <                std::string intString = script.substr(ichToken, ichToken + cchToken);
127 <                int val = lexi_cast<int>(intString);
128 <                ltoken.push_back(Token(Token::integer, val, intString));/**@todo*/
126 >
127 >                int val = lexi_cast<int>(script.substr(ichToken, cchToken));
128 >                ltoken.push_back(Token(Token::integer,   boost::any(val)));
129                  continue;
130              }
131          }
# Line 242 | Line 242 | bool SelectionCompiler::internalCompile(){
242        previousCharBackslash = ch == '\\' ? !previousCharBackslash : false;
243      }
244      cchToken = ichT - ichToken;
245 +
246      return true;
247    }
248  
# Line 339 | Line 340 | bool SelectionCompiler::lookingAtDecimal(bool allowNeg
340          return false;
341      }
342  
343 <    // to support 1.ca, let's check the character after the dot
344 <    // to determine if it is an alpha
344 <    if (ch == '.' && (ichT + 1 < cchScript) && std::isalpha(script[ichT + 1])) {
343 >    // to support DMPC.1, let's check the character before the dot
344 >    if (ch == '.' && (ichT > 0) && std::isalpha(script[ichT - 1])) {
345          return false;
346      }
347  
# Line 425 | Line 425 | bool SelectionCompiler::lookingAtLookupToken() {
425              }
426          break;
427      }
428 +
429      cchToken = ichT - ichToken;
430 +
431      return true;
432   }
433  
# Line 562 | Line 564 | bool SelectionCompiler::clausePrimitive() {
564          case Token::asterisk:
565          case Token::identifier:
566              return clauseChemObjName();
567 <      
567 >
568 >        case Token::integer :
569 >            return clauseIndex();
570          default:
571              if ((tok & Token::atomproperty) == Token::atomproperty) {
572                  return clauseComparator();
# Line 608 | Line 612 | bool SelectionCompiler::clauseComparator() {
612          return false;
613      }
614  
615 +    boost::any floatVal;
616 +    floatVal = val;
617      return addTokenToPostfix(Token(tokenComparator.tok,
618 <                       tokenAtomProperty.tok, boost::any(val)));
618 >                       tokenAtomProperty.tok, floatVal));
619   }
620  
621   bool SelectionCompiler::clauseWithin() {
# Line 622 | Line 628 | bool SelectionCompiler::clauseWithin() {
628      Token tokenDistance = tokenNext();       // distance
629      switch(tokenDistance.tok) {
630          case Token::integer:
625            distance = float(tokenDistance.intValue);
626            break;
631          case Token::decimal:
632              distance = tokenDistance.value;
633              break;
# Line 680 | Line 684 | bool SelectionCompiler:: clauseName(std::string& name)
684  
685      int tok = tokPeek();
686  
687 <    if (tok == Token::asterisk || tok == Token::identifier) {
688 <        name += boost::any_cast<std::string>(tokenNext().value);
689 <        
687 >    if (tok == Token::asterisk || tok == Token::identifier || tok == Token::integer) {
688 >
689 >        Token token = tokenNext();
690 >        if (token.value.type() == typeid(std::string)) {
691 >            name += boost::any_cast<std::string>(token.value);
692 >        } else if (token.value.type() == typeid(int)){
693 >            int intVal = boost::any_cast<int>(token.value);
694 >            char buffer[255];
695 >            sprintf(buffer,"%d", intVal);
696 >            name += buffer; /** @todo */
697 >            //name += toString<int>(intVal);
698 >        }
699          while(true){
700              tok = tokPeek();
701              switch (tok) {
# Line 709 | Line 722 | bool SelectionCompiler:: clauseName(std::string& name)
722  
723   }
724  
725 + bool SelectionCompiler::clauseIndex(){
726 +    Token token = tokenNext();
727 +    if (token.tok == Token::integer) {
728 +        int index = boost::any_cast<int>(token.value);
729 +        int tok = tokPeek();
730 +        std::cout << "Token::to is " << Token::to << ", tok = " << tok << std::endl;
731 +        if (tok == Token::to) {
732 +            tokenNext();
733 +            tok = tokPeek();
734 +            if (tok != Token::integer) {
735 +                return numberExpected();
736 +            }
737 +            
738 +            boost::any intVal = tokenNext().value;
739 +            int first = index;
740 +            if (intVal.type() != typeid(int)){
741 +                return false;
742 +            }
743 +            int second = boost::any_cast<int>(intVal);
744  
745 +            return addTokenToPostfix(Token(Token::index, boost::any(std::make_pair(first, second))));
746 +            
747 +        }else {
748 +            return addTokenToPostfix(Token(Token::index, boost::any(index)));
749 +        }
750 +    } else {
751 +        return numberExpected();
752 +    }
753   }
754 +
755 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines