| 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) { |
| 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 |
> |
std::cout << "encount an decimal: " << value << std::endl; |
| 123 |
> |
ltoken.push_back(Token(Token::decimal, boost::any(value))); |
| 124 |
|
continue; |
| 125 |
|
} |
| 126 |
|
if (lookingAtInteger((tokCommand & Token::negnums) != 0)) { |
| 127 |
< |
std::string intString = script.substr(ichToken, ichToken + cchToken); |
| 128 |
< |
int val = lexi_cast<int>(intString); |
| 129 |
< |
ltoken.push_back(Token(Token::integer, val, intString));/**@todo*/ |
| 127 |
> |
|
| 128 |
> |
int val = lexi_cast<int>(script.substr(ichToken, cchToken)); |
| 129 |
> |
std::cout << "encount an integer: " << val << std::endl; |
| 130 |
> |
ltoken.push_back(Token(Token::integer, boost::any(val))); |
| 131 |
|
continue; |
| 132 |
|
} |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
if (lookingAtLookupToken()) { |
| 136 |
< |
std::string ident = script.substr(ichToken, ichToken + cchToken); |
| 135 |
< |
|
| 136 |
> |
std::string ident = script.substr(ichToken, cchToken); |
| 137 |
|
Token token; |
| 138 |
|
Token* pToken = TokenMap::getInstance()->getToken(ident); |
| 139 |
|
if (pToken != NULL) { |
| 244 |
|
previousCharBackslash = ch == '\\' ? !previousCharBackslash : false; |
| 245 |
|
} |
| 246 |
|
cchToken = ichT - ichToken; |
| 247 |
+ |
|
| 248 |
+ |
|
| 249 |
+ |
std::cout << "lookingAtString: encount " << script.substr(ichToken, cchToken) << std::endl; |
| 250 |
|
return true; |
| 251 |
|
} |
| 252 |
|
|
| 423 |
|
return false; |
| 424 |
|
} |
| 425 |
|
case '?': // include question marks in identifier for atom expressions |
| 426 |
< |
while (ichT < cchScript && (std::isalpha(ch = script[ichT]) ||std::isdigit(ch) || |
| 427 |
< |
ch == '_' || ch == '?') ||(ch == '^' && ichT > ichToken && std::isdigit(script[ichT - 1]))) { |
| 428 |
< |
// hack for insertion codes embedded in an atom expression :-( |
| 425 |
< |
// select c3^a |
| 426 |
> |
while (ichT < cchScript && !std::isspace(ch = script[ichT]) && (std::isalpha(ch) ||std::isdigit(ch) || |
| 427 |
> |
ch == '_' || ch == '?') ) { |
| 428 |
> |
|
| 429 |
|
++ichT; |
| 430 |
|
} |
| 431 |
|
break; |
| 432 |
|
} |
| 433 |
+ |
|
| 434 |
|
cchToken = ichT - ichToken; |
| 435 |
+ |
|
| 436 |
+ |
std::cout << "lookingAtLookupToken: encount " << script.substr(ichToken, cchToken) << std::endl; |
| 437 |
|
return true; |
| 438 |
|
} |
| 439 |
|
|
| 570 |
|
case Token::asterisk: |
| 571 |
|
case Token::identifier: |
| 572 |
|
return clauseChemObjName(); |
| 573 |
< |
|
| 573 |
> |
|
| 574 |
> |
case Token::integer : |
| 575 |
> |
return clauseIndex(); |
| 576 |
|
default: |
| 577 |
|
if ((tok & Token::atomproperty) == Token::atomproperty) { |
| 578 |
|
return clauseComparator(); |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
Token tokenValue = tokenNext(); |
| 608 |
< |
if (tokenValue.tok != Token::integer) { |
| 609 |
< |
return integerExpected(); |
| 608 |
> |
if (tokenValue.tok != Token::integer && tokenValue.tok != Token::decimal) { |
| 609 |
> |
return numberExpected(); |
| 610 |
|
} |
| 611 |
< |
int val = tokenValue.intValue; |
| 612 |
< |
// note that a comparator instruction is a complicated instruction |
| 613 |
< |
// int intValue is the tok of the property you are comparing |
| 614 |
< |
// the value against which you are comparing is stored as an Integer |
| 615 |
< |
// in the object value |
| 611 |
> |
|
| 612 |
> |
float val; |
| 613 |
> |
if (tokenValue.value.type() == typeid(int)) { |
| 614 |
> |
val = boost::any_cast<int>(tokenValue.value); |
| 615 |
> |
} else if (tokenValue.value.type() == typeid(float)) { |
| 616 |
> |
val = boost::any_cast<float>(tokenValue.value); |
| 617 |
> |
} else { |
| 618 |
> |
return false; |
| 619 |
> |
} |
| 620 |
> |
|
| 621 |
> |
boost::any floatVal; |
| 622 |
> |
floatVal = val; |
| 623 |
|
return addTokenToPostfix(Token(tokenComparator.tok, |
| 624 |
< |
tokenAtomProperty.tok, boost::any(val))); |
| 624 |
> |
tokenAtomProperty.tok, floatVal)); |
| 625 |
|
} |
| 626 |
|
|
| 627 |
|
bool SelectionCompiler::clauseWithin() { |
| 634 |
|
Token tokenDistance = tokenNext(); // distance |
| 635 |
|
switch(tokenDistance.tok) { |
| 636 |
|
case Token::integer: |
| 622 |
– |
distance = float(tokenDistance.intValue); |
| 623 |
– |
break; |
| 637 |
|
case Token::decimal: |
| 638 |
|
distance = tokenDistance.value; |
| 639 |
|
break; |
| 667 |
|
tok = tokPeek(); |
| 668 |
|
//allow two dot at most |
| 669 |
|
if (tok == Token::dot) { |
| 670 |
+ |
tokenNext(); |
| 671 |
+ |
chemObjName += "."; |
| 672 |
|
if (!clauseName(chemObjName)) { |
| 673 |
|
return false; |
| 674 |
|
} |
| 675 |
|
tok = tokPeek(); |
| 676 |
|
if (tok == Token::dot) { |
| 677 |
+ |
tokenNext(); |
| 678 |
+ |
chemObjName += "."; |
| 679 |
+ |
|
| 680 |
|
if (!clauseName(chemObjName)) { |
| 681 |
|
return false; |
| 682 |
|
} |
| 719 |
|
|
| 720 |
|
} |
| 721 |
|
|
| 722 |
+ |
bool SelectionCompiler::clauseIndex(){ |
| 723 |
+ |
Token token = tokenNext(); |
| 724 |
+ |
if (token.tok == Token::integer) { |
| 725 |
+ |
int index = boost::any_cast<int>(token.value); |
| 726 |
+ |
int tok = tokPeek(); |
| 727 |
+ |
std::cout << "Token::to is " << Token::to << ", tok = " << tok << std::endl; |
| 728 |
+ |
if (tok == Token::to) { |
| 729 |
+ |
tokenNext(); |
| 730 |
+ |
tok = tokPeek(); |
| 731 |
+ |
if (tok != Token::integer) { |
| 732 |
+ |
return numberExpected(); |
| 733 |
+ |
} |
| 734 |
+ |
|
| 735 |
+ |
boost::any intVal = tokenNext().value; |
| 736 |
+ |
int first = index; |
| 737 |
+ |
if (intVal.type() != typeid(int)){ |
| 738 |
+ |
return false; |
| 739 |
+ |
} |
| 740 |
+ |
int second = boost::any_cast<int>(intVal); |
| 741 |
|
|
| 742 |
+ |
return addTokenToPostfix(Token(Token::index, boost::any(std::make_pair(first, second)))); |
| 743 |
+ |
|
| 744 |
+ |
}else { |
| 745 |
+ |
return addTokenToPostfix(Token(Token::index, boost::any(index))); |
| 746 |
+ |
} |
| 747 |
+ |
} else { |
| 748 |
+ |
return numberExpected(); |
| 749 |
+ |
} |
| 750 |
|
} |
| 751 |
+ |
|
| 752 |
+ |
} |