| 82 |
|
for ( ; true; ichToken += cchToken) { |
| 83 |
|
if (lookingAtLeadingWhitespace()) |
| 84 |
|
continue; |
| 85 |
< |
if (lookingAtComment()) |
| 86 |
< |
continue; |
| 85 |
> |
//if (lookingAtComment()) |
| 86 |
> |
// continue; |
| 87 |
|
bool endOfLine = lookingAtEndOfLine(); |
| 88 |
|
if (endOfLine || lookingAtEndOfStatement()) { |
| 89 |
|
if (tokCommand != Token::nada) { |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
if (lookingAtLookupToken()) { |
| 134 |
< |
std::string ident = script.substr(ichToken, ichToken + cchToken); |
| 135 |
< |
|
| 134 |
> |
std::string ident = script.substr(ichToken, cchToken); |
| 135 |
|
Token token; |
| 136 |
|
Token* pToken = TokenMap::getInstance()->getToken(ident); |
| 137 |
|
if (pToken != NULL) { |
| 418 |
|
return false; |
| 419 |
|
} |
| 420 |
|
case '?': // include question marks in identifier for atom expressions |
| 421 |
< |
while (ichT < cchScript && (std::isalpha(ch = script[ichT]) ||std::isdigit(ch) || |
| 422 |
< |
ch == '_' || ch == '?') ||(ch == '^' && ichT > ichToken && std::isdigit(script[ichT - 1]))) { |
| 423 |
< |
// hack for insertion codes embedded in an atom expression :-( |
| 425 |
< |
// select c3^a |
| 421 |
> |
while (ichT < cchScript && !std::isspace(ch = script[ichT]) && (std::isalpha(ch) ||std::isdigit(ch) || |
| 422 |
> |
ch == '_' || ch == '?') ) { |
| 423 |
> |
|
| 424 |
|
++ichT; |
| 425 |
|
} |
| 426 |
|
break; |
| 558 |
|
switch (tok) { |
| 559 |
|
case Token::within: |
| 560 |
|
return clauseWithin(); |
| 561 |
< |
case Token::name : |
| 562 |
< |
return clauseName(Token::name); |
| 563 |
< |
case Token::index : |
| 564 |
< |
return clauseIndex(Token::index); |
| 565 |
< |
case Token::molname : |
| 568 |
< |
return clauseName(Token::molname); |
| 569 |
< |
case Token::molindex : |
| 570 |
< |
return clauseIndex(Token::molindex); |
| 571 |
< |
|
| 561 |
> |
|
| 562 |
> |
case Token::asterisk: |
| 563 |
> |
case Token::identifier: |
| 564 |
> |
return clauseChemObjName(); |
| 565 |
> |
|
| 566 |
|
default: |
| 567 |
|
if ((tok & Token::atomproperty) == Token::atomproperty) { |
| 568 |
|
return clauseComparator(); |
| 595 |
|
} |
| 596 |
|
|
| 597 |
|
Token tokenValue = tokenNext(); |
| 598 |
< |
if (tokenValue.tok != Token::integer) { |
| 599 |
< |
return integerExpected(); |
| 598 |
> |
if (tokenValue.tok != Token::integer && tokenValue.tok != Token::decimal) { |
| 599 |
> |
return numberExpected(); |
| 600 |
|
} |
| 601 |
< |
int val = tokenValue.intValue; |
| 602 |
< |
// note that a comparator instruction is a complicated instruction |
| 603 |
< |
// int intValue is the tok of the property you are comparing |
| 604 |
< |
// the value against which you are comparing is stored as an Integer |
| 605 |
< |
// in the object value |
| 601 |
> |
|
| 602 |
> |
float val; |
| 603 |
> |
if (tokenValue.value.type() == typeid(int)) { |
| 604 |
> |
val = boost::any_cast<int>(tokenValue.value); |
| 605 |
> |
} else if (tokenValue.value.type() == typeid(float)) { |
| 606 |
> |
val = boost::any_cast<float>(tokenValue.value); |
| 607 |
> |
} else { |
| 608 |
> |
return false; |
| 609 |
> |
} |
| 610 |
> |
|
| 611 |
|
return addTokenToPostfix(Token(tokenComparator.tok, |
| 612 |
|
tokenAtomProperty.tok, boost::any(val))); |
| 613 |
|
} |
| 646 |
|
return addTokenToPostfix(Token(Token::within, distance)); |
| 647 |
|
} |
| 648 |
|
|
| 649 |
+ |
bool SelectionCompiler::clauseChemObjName() { |
| 650 |
+ |
std::string chemObjName; |
| 651 |
+ |
int tok = tokPeek(); |
| 652 |
+ |
if (!clauseName(chemObjName)){ |
| 653 |
+ |
return false; |
| 654 |
+ |
} |
| 655 |
|
|
| 656 |
< |
bool SelectionCompiler:: clauseName(int tok) { |
| 657 |
< |
Token tokenName = tokenNext(); |
| 658 |
< |
std::string name = boost::any_cast<std::string>(tokenName.value); |
| 659 |
< |
return addTokenToPostfix(Token(tok, name)); /**@todo */ |
| 656 |
> |
|
| 657 |
> |
tok = tokPeek(); |
| 658 |
> |
//allow two dot at most |
| 659 |
> |
if (tok == Token::dot) { |
| 660 |
> |
tokenNext(); |
| 661 |
> |
chemObjName += "."; |
| 662 |
> |
if (!clauseName(chemObjName)) { |
| 663 |
> |
return false; |
| 664 |
> |
} |
| 665 |
> |
tok = tokPeek(); |
| 666 |
> |
if (tok == Token::dot) { |
| 667 |
> |
tokenNext(); |
| 668 |
> |
chemObjName += "."; |
| 669 |
|
|
| 670 |
+ |
if (!clauseName(chemObjName)) { |
| 671 |
+ |
return false; |
| 672 |
+ |
} |
| 673 |
+ |
} |
| 674 |
+ |
} |
| 675 |
+ |
|
| 676 |
+ |
return addTokenToPostfix(Token(Token::name, chemObjName)); |
| 677 |
|
} |
| 678 |
|
|
| 679 |
< |
bool SelectionCompiler:: clauseIndex(int tok) { |
| 680 |
< |
//return addTokenToPostfix(Token(tok, )); /**@todo*/ |
| 681 |
< |
return true; |
| 679 |
> |
bool SelectionCompiler:: clauseName(std::string& name) { |
| 680 |
> |
|
| 681 |
> |
int tok = tokPeek(); |
| 682 |
> |
|
| 683 |
> |
if (tok == Token::asterisk || tok == Token::identifier) { |
| 684 |
> |
name += boost::any_cast<std::string>(tokenNext().value); |
| 685 |
> |
|
| 686 |
> |
while(true){ |
| 687 |
> |
tok = tokPeek(); |
| 688 |
> |
switch (tok) { |
| 689 |
> |
case Token::asterisk : |
| 690 |
> |
name += "*"; |
| 691 |
> |
tokenNext(); |
| 692 |
> |
break; |
| 693 |
> |
case Token::identifier : |
| 694 |
> |
name += boost::any_cast<std::string>(tokenNext().value); |
| 695 |
> |
break; |
| 696 |
> |
case Token::integer : |
| 697 |
> |
name += toString(boost::any_cast<int>(tokenNext().value)); |
| 698 |
> |
break; |
| 699 |
> |
case Token::dot : |
| 700 |
> |
return true; |
| 701 |
> |
default : |
| 702 |
> |
return true; |
| 703 |
> |
} |
| 704 |
> |
} |
| 705 |
> |
|
| 706 |
> |
}else { |
| 707 |
> |
return false; |
| 708 |
> |
} |
| 709 |
> |
|
| 710 |
|
} |
| 711 |
|
|
| 712 |
+ |
|
| 713 |
|
} |