| 40 |
|
*/ |
| 41 |
|
|
| 42 |
|
#include "selection/SelectionCompiler.hpp" |
| 43 |
+ |
#include "utils/StringUtils.hpp" |
| 44 |
|
namespace oopse { |
| 45 |
|
|
| 46 |
|
bool SelectionCompiler::compile(const std::string& filename, const std::string& script) { |
| 51 |
|
lineIndices.clear(); |
| 52 |
|
aatokenCompiled.clear(); |
| 53 |
|
|
| 54 |
< |
if (internalcompile()) { |
| 54 |
> |
if (internalCompile()) { |
| 55 |
|
return true; |
| 56 |
|
} |
| 57 |
|
|
| 58 |
|
int icharEnd; |
| 59 |
< |
if ((icharEnd = script.find('\r', ichCurrentCommand)) == std::string:npos && |
| 60 |
< |
(icharEnd = script.find('\n', ichCurrentCommand)) == std::string:npos) { |
| 59 |
> |
if ((icharEnd = script.find('\r', ichCurrentCommand)) == std::string::npos && |
| 60 |
> |
(icharEnd = script.find('\n', ichCurrentCommand)) == std::string::npos) { |
| 61 |
|
icharEnd = script.size(); |
| 62 |
|
} |
| 63 |
|
errorLine = script.substr(ichCurrentCommand, icharEnd); |
| 72 |
|
|
| 73 |
|
error = false; |
| 74 |
|
|
| 75 |
< |
std::vector<Token> lltoken; |
| 75 |
> |
//std::vector<Token> lltoken; |
| 76 |
> |
aatokenCompiled.clear(); |
| 77 |
|
std::vector<Token> ltoken; |
| 78 |
|
|
| 79 |
< |
//Token tokenCommand = null; |
| 80 |
< |
int tokCommand = Token.nada; |
| 79 |
> |
Token tokenCommand; |
| 80 |
> |
int tokCommand = Token::nada; |
| 81 |
|
|
| 82 |
|
for ( ; true; ichToken += cchToken) { |
| 83 |
|
if (lookingAtLeadingWhitespace()) |
| 84 |
|
continue; |
| 85 |
|
if (lookingAtComment()) |
| 86 |
|
continue; |
| 87 |
< |
boolean endOfLine = lookingAtEndOfLine(); |
| 87 |
> |
bool endOfLine = lookingAtEndOfLine(); |
| 88 |
|
if (endOfLine || lookingAtEndOfStatement()) { |
| 89 |
< |
if (tokCommand != Token.nada) { |
| 89 |
> |
if (tokCommand != Token::nada) { |
| 90 |
|
if (! compileCommand(ltoken)) { |
| 91 |
|
return false; |
| 92 |
|
} |
| 93 |
< |
lltoken.push_back(atokenCommand); |
| 94 |
< |
/** @todo*/ |
| 95 |
< |
int iCommand = lltoken.size(); |
| 96 |
< |
lineNumbers[iCommand] = lineCurrent; |
| 97 |
< |
lineIndices[iCommand] = (short) ichCurrentCommand; |
| 96 |
< |
ltoken.clear(); |
| 97 |
< |
tokCommand = Token.nada; |
| 93 |
> |
aatokenCompiled.push_back(atokenCommand); |
| 94 |
> |
lineNumbers.push_back(lineCurrent); |
| 95 |
> |
lineIndices.push_back(ichCurrentCommand); |
| 96 |
> |
ltoken.clear(); |
| 97 |
> |
tokCommand = Token::nada; |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
if (ichToken < cchScript) { |
| 105 |
|
break; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
< |
if (tokCommand != Token.nada) { |
| 108 |
> |
if (tokCommand != Token::nada) { |
| 109 |
|
if (lookingAtString()) { |
| 110 |
|
std::string str = getUnescapedStringLiteral(); |
| 111 |
< |
ltoken.push_back(Token(Token.string, str)); |
| 111 |
> |
ltoken.push_back(Token(Token::string, str)); |
| 112 |
|
continue; |
| 113 |
|
} |
| 114 |
< |
if ((tokCommand & Token.specialstring) != 0 && |
| 115 |
< |
lookingAtSpecialString()) { |
| 116 |
< |
std::string str = script.substr(ichToken, ichToken + cchToken); |
| 117 |
< |
ltoken.push_back(Token(Token.string, str)); |
| 114 |
> |
//if ((tokCommand & Token::specialstring) != 0 && |
| 115 |
> |
// lookingAtSpecialString()) { |
| 116 |
> |
// std::string str = script.substr(ichToken, ichToken + cchToken); |
| 117 |
> |
// ltoken.push_back(Token(Token::string, str)); |
| 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*/ |
| 123 |
|
continue; |
| 124 |
|
} |
| 125 |
< |
if (lookingAtDecimal((tokCommand & Token.negnums) != 0)) { |
| 121 |
< |
float value = lexi_cast<float>((script.substr(ichToken, ichToken + cchToken)); |
| 122 |
< |
ltoken.push_back(Token(Token.decimal, new Float(value)));/**@todo*/ |
| 123 |
< |
continue; |
| 124 |
< |
} |
| 125 |
< |
if (lookingAtInteger((tokCommand & Token.negnums) != 0)) { |
| 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(new Token(Token.integer, val, intString));/**@todo*/ |
| 128 |
> |
ltoken.push_back(Token(Token::integer, val, intString));/**@todo*/ |
| 129 |
|
continue; |
| 130 |
|
} |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
if (lookingAtLookupToken()) { |
| 134 |
< |
std::string ident = script.subst(ichToken, ichToken + cchToken); |
| 134 |
> |
std::string ident = script.substr(ichToken, ichToken + cchToken); |
| 135 |
|
|
| 136 |
< |
/**@todo */ |
| 137 |
< |
Token token = (Token) Token.map.get(ident); |
| 138 |
< |
if (token == NULL) { |
| 139 |
< |
|
| 136 |
> |
Token token; |
| 137 |
> |
Token* pToken = TokenMap::getInstance()->getToken(ident); |
| 138 |
> |
if (pToken != NULL) { |
| 139 |
> |
token = *pToken; |
| 140 |
> |
} else { |
| 141 |
> |
token = Token(Token::identifier, ident); |
| 142 |
|
} |
| 141 |
– |
Token token(Token.identifier, ident); |
| 142 |
– |
|
| 143 |
|
|
| 144 |
|
int tok = token.tok; |
| 145 |
|
|
| 146 |
|
switch (tokCommand) { |
| 147 |
< |
case Token.nada: |
| 147 |
> |
case Token::nada: |
| 148 |
|
ichCurrentCommand = ichToken; |
| 149 |
|
//tokenCommand = token; |
| 150 |
|
tokCommand = tok; |
| 151 |
< |
if ((tokCommand & Token.command) == 0) |
| 151 |
> |
if ((tokCommand & Token::command) == 0) |
| 152 |
|
return commandExpected(); |
| 153 |
|
break; |
| 154 |
|
|
| 155 |
< |
case Token.define: |
| 155 |
> |
case Token::define: |
| 156 |
|
if (ltoken.size() == 1) { |
| 157 |
|
// we are looking at the variable name |
| 158 |
< |
if (tok != Token.identifier && |
| 159 |
< |
(tok & Token.predefinedset) != Token.predefinedset) |
| 158 |
> |
if (tok != Token::identifier && |
| 159 |
> |
(tok & Token::predefinedset) != Token::predefinedset) |
| 160 |
|
return invalidExpressionToken(ident); |
| 161 |
|
} else { |
| 162 |
|
// we are looking at the expression |
| 163 |
< |
if (tok != Token.identifier && tok != Token.set && |
| 164 |
< |
(tok & (Token.expression | Token.predefinedset)) == 0) |
| 163 |
> |
if (tok != Token::identifier && |
| 164 |
> |
(tok & (Token::expression | Token::predefinedset)) == 0) |
| 165 |
|
return invalidExpressionToken(ident); |
| 166 |
|
} |
| 167 |
|
|
| 168 |
|
break; |
| 169 |
|
|
| 170 |
< |
case Token.select: |
| 171 |
< |
if (tok != Token.identifier && (tok & Token.expression) == 0) |
| 170 |
> |
case Token::select: |
| 171 |
> |
if (tok != Token::identifier && (tok & Token::expression) == 0) |
| 172 |
|
return invalidExpressionToken(ident); |
| 173 |
|
break; |
| 174 |
|
} |
| 183 |
|
return unrecognizedToken(); |
| 184 |
|
} |
| 185 |
|
|
| 186 |
– |
aatokenCompiled.push_back(lltoken); |
| 186 |
|
return true; |
| 187 |
|
} |
| 188 |
|
|
| 235 |
|
int ichT = ichToken + 1; |
| 236 |
|
// while (ichT < cchScript && script.charAt(ichT++) != chFirst) |
| 237 |
|
char ch; |
| 238 |
< |
boolean previousCharBackslash = false; |
| 238 |
> |
bool previousCharBackslash = false; |
| 239 |
|
while (ichT < cchScript) { |
| 240 |
< |
ch = script.[ichT++]; |
| 240 |
> |
ch = script[ichT++]; |
| 241 |
|
if (ch == '"' && !previousCharBackslash) |
| 242 |
|
break; |
| 243 |
|
previousCharBackslash = ch == '\\' ? !previousCharBackslash : false; |
| 248 |
|
|
| 249 |
|
|
| 250 |
|
std::string SelectionCompiler::getUnescapedStringLiteral() { |
| 251 |
< |
StringBuffer sb = new StringBuffer(cchToken - 2); |
| 251 |
> |
/** @todo */ |
| 252 |
> |
std::string sb(cchToken - 2, ' '); |
| 253 |
> |
|
| 254 |
|
int ichMax = ichToken + cchToken - 1; |
| 255 |
|
int ich = ichToken + 1; |
| 256 |
|
|
| 293 |
|
} |
| 294 |
|
} |
| 295 |
|
} |
| 296 |
< |
sb.append(ch); |
| 296 |
> |
sb.append(1, ch); |
| 297 |
|
} |
| 298 |
|
|
| 299 |
< |
return "" + sb; |
| 299 |
> |
return sb; |
| 300 |
|
} |
| 301 |
|
|
| 302 |
< |
static int SelectionCompiler::getHexitValue(char ch) { |
| 302 |
> |
int SelectionCompiler::getHexitValue(char ch) { |
| 303 |
|
if (ch >= '0' && ch <= '9') |
| 304 |
|
return ch - '0'; |
| 305 |
|
else if (ch >= 'a' && ch <= 'f') |
| 320 |
|
return cchToken > 0; |
| 321 |
|
} |
| 322 |
|
|
| 323 |
< |
bool SelectionCompiler::lookingAtDecimal(boolean allowNegative) { |
| 323 |
> |
bool SelectionCompiler::lookingAtDecimal(bool allowNegative) { |
| 324 |
|
if (ichToken == cchScript) { |
| 325 |
|
return false; |
| 326 |
|
} |
| 329 |
|
if (script[ichT] == '-') { |
| 330 |
|
++ichT; |
| 331 |
|
} |
| 332 |
< |
boolean digitSeen = false; |
| 332 |
> |
bool digitSeen = false; |
| 333 |
|
char ch = 'X'; |
| 334 |
|
while (ichT < cchScript && std::isdigit(ch = script[ichT])) { |
| 335 |
|
++ichT; |
| 355 |
|
return digitSeen; |
| 356 |
|
} |
| 357 |
|
|
| 358 |
< |
bool SelectionCompiler::lookingAtInteger(boolean allowNegative) { |
| 358 |
> |
bool SelectionCompiler::lookingAtInteger(bool allowNegative) { |
| 359 |
|
if (ichToken == cchScript) { |
| 360 |
|
return false; |
| 361 |
|
} |
| 431 |
|
return true; |
| 432 |
|
} |
| 433 |
|
|
| 434 |
< |
bool SelectionCompiler::compileCommand(Vector ltoken) { |
| 435 |
< |
/** todo */ |
| 435 |
< |
Token tokenCommand = (Token)ltoken.firstElement(); |
| 434 |
> |
bool SelectionCompiler::compileCommand(const std::vector<Token>& ltoken) { |
| 435 |
> |
const Token& tokenCommand = ltoken[0]; |
| 436 |
|
int tokCommand = tokenCommand.tok; |
| 437 |
< |
|
| 438 |
< |
atokenCommand = new Token[ltoken.size()]; |
| 439 |
< |
ltoken.copyInto(atokenCommand); |
| 440 |
< |
if ((tokCommand & Token.expressionCommand) != 0 && !compileExpression()) { |
| 437 |
> |
|
| 438 |
> |
atokenCommand = ltoken; |
| 439 |
> |
if ((tokCommand & Token::expressionCommand) != 0 && !compileExpression()) { |
| 440 |
|
return false; |
| 441 |
|
} |
| 442 |
+ |
|
| 443 |
|
return true; |
| 444 |
|
} |
| 445 |
|
|
| 447 |
|
/** todo */ |
| 448 |
|
int i = 1; |
| 449 |
|
int tokCommand = atokenCommand[0].tok; |
| 450 |
< |
if (tokCommand == Token.define) |
| 451 |
< |
i = 2; |
| 452 |
< |
else if ((tokCommand & Token.embeddedExpression) != 0) { |
| 453 |
< |
// look for the open parenthesis |
| 454 |
< |
while (i < atokenCommand.length && |
| 455 |
< |
atokenCommand[i].tok != Token.leftparen) |
| 450 |
> |
if (tokCommand == Token::define) { |
| 451 |
> |
i = 2; |
| 452 |
> |
} else if ((tokCommand & Token::embeddedExpression) != 0) { |
| 453 |
> |
// look for the open parenthesis |
| 454 |
> |
while (i < atokenCommand.size() && |
| 455 |
> |
atokenCommand[i].tok != Token::leftparen) |
| 456 |
|
++i; |
| 457 |
|
} |
| 458 |
< |
if (i >= atokenCommand.length) |
| 459 |
< |
return true; |
| 458 |
> |
|
| 459 |
> |
if (i >= atokenCommand.size()) { |
| 460 |
> |
return true; |
| 461 |
> |
} |
| 462 |
|
return compileExpression(i); |
| 463 |
|
} |
| 464 |
|
|
| 465 |
|
|
| 466 |
< |
bool SelectionCompiler::addTokenToPostfix(Token token) { |
| 466 |
> |
bool SelectionCompiler::addTokenToPostfix(const Token& token) { |
| 467 |
|
ltokenPostfix.push_back(token); |
| 468 |
|
return true; |
| 469 |
|
} |
| 470 |
|
|
| 471 |
|
bool SelectionCompiler::compileExpression(int itoken) { |
| 472 |
< |
ltokenPostfix = new Vector(); |
| 473 |
< |
for (int i = 0; i < itoken; ++i) |
| 472 |
> |
ltokenPostfix.clear(); |
| 473 |
> |
for (int i = 0; i < itoken; ++i) { |
| 474 |
|
addTokenToPostfix(atokenCommand[i]); |
| 475 |
< |
|
| 475 |
> |
} |
| 476 |
> |
|
| 477 |
|
atokenInfix = atokenCommand; |
| 478 |
|
itokenInfix = itoken; |
| 479 |
|
|
| 480 |
< |
addTokenToPostfix(Token.tokenExpressionBegin); |
| 480 |
> |
addTokenToPostfix(Token::tokenExpressionBegin); |
| 481 |
|
if (!clauseOr()) { |
| 482 |
|
return false; |
| 483 |
|
} |
| 484 |
|
|
| 485 |
< |
addTokenToPostfix(Token.tokenExpressionEnd); |
| 486 |
< |
if (itokenInfix != atokenInfix.length) { |
| 485 |
> |
addTokenToPostfix(Token::tokenExpressionEnd); |
| 486 |
> |
if (itokenInfix != atokenInfix.size()) { |
| 487 |
|
return endOfExpressionExpected(); |
| 488 |
|
} |
| 489 |
|
|
| 492 |
|
} |
| 493 |
|
|
| 494 |
|
Token SelectionCompiler::tokenNext() { |
| 495 |
< |
if (itokenInfix == atokenInfix.length) |
| 496 |
< |
return null; |
| 497 |
< |
return atokenInfix[itokenInfix++]; |
| 495 |
> |
if (itokenInfix == atokenInfix.size()) { |
| 496 |
> |
return Token(); |
| 497 |
> |
} |
| 498 |
> |
return atokenInfix[itokenInfix++]; |
| 499 |
|
} |
| 500 |
|
|
| 501 |
< |
Object SelectionCompiler::valuePeek() { |
| 502 |
< |
if (itokenInfix == atokenInfix.length) { |
| 503 |
< |
return null; |
| 501 |
> |
boost::any SelectionCompiler::valuePeek() { |
| 502 |
> |
if (itokenInfix == atokenInfix.size()) { |
| 503 |
> |
return boost::any(); |
| 504 |
|
} else { |
| 505 |
|
return atokenInfix[itokenInfix].value; |
| 506 |
|
} |
| 507 |
|
} |
| 508 |
|
|
| 509 |
|
int SelectionCompiler::tokPeek() { |
| 510 |
< |
if (itokenInfix == atokenInfix.length) { |
| 510 |
> |
if (itokenInfix == atokenInfix.size()) { |
| 511 |
|
return 0; |
| 512 |
|
}else { |
| 513 |
|
return atokenInfix[itokenInfix].tok; |
| 519 |
|
return false; |
| 520 |
|
} |
| 521 |
|
|
| 522 |
< |
while (tokPeek() == Token.opOr) { |
| 522 |
> |
while (tokPeek() == Token::opOr) { |
| 523 |
|
Token tokenOr = tokenNext(); |
| 524 |
|
if (!clauseAnd()) { |
| 525 |
|
return false; |
| 534 |
|
return false; |
| 535 |
|
} |
| 536 |
|
|
| 537 |
< |
while (tokPeek() == Token.opAnd) { |
| 537 |
> |
while (tokPeek() == Token::opAnd) { |
| 538 |
|
Token tokenAnd = tokenNext(); |
| 539 |
|
if (!clauseNot()) { |
| 540 |
|
return false; |
| 545 |
|
} |
| 546 |
|
|
| 547 |
|
bool SelectionCompiler::clauseNot() { |
| 548 |
< |
if (tokPeek() == Token.opNot) { |
| 548 |
> |
if (tokPeek() == Token::opNot) { |
| 549 |
|
Token tokenNot = tokenNext(); |
| 550 |
|
if (!clauseNot()) { |
| 551 |
|
return false; |
| 558 |
|
bool SelectionCompiler::clausePrimitive() { |
| 559 |
|
int tok = tokPeek(); |
| 560 |
|
switch (tok) { |
| 561 |
< |
case Token.within: |
| 561 |
> |
case Token::within: |
| 562 |
|
return clauseWithin(); |
| 563 |
< |
case Token.hyphen: // selecting a negative residue spec |
| 564 |
< |
case Token.integer: |
| 565 |
< |
case Token.seqcode: |
| 566 |
< |
case Token.asterisk: |
| 567 |
< |
case Token.leftsquare: |
| 564 |
< |
case Token.identifier: |
| 565 |
< |
case Token.x: |
| 566 |
< |
case Token.y: |
| 567 |
< |
case Token.z: |
| 568 |
< |
case Token.colon: |
| 569 |
< |
return clauseResidueSpec(); |
| 563 |
> |
|
| 564 |
> |
case Token::asterisk: |
| 565 |
> |
case Token::identifier: |
| 566 |
> |
return clauseChemObjName(); |
| 567 |
> |
|
| 568 |
|
default: |
| 569 |
< |
if ((tok & Token.atomproperty) == Token.atomproperty) { |
| 569 |
> |
if ((tok & Token::atomproperty) == Token::atomproperty) { |
| 570 |
|
return clauseComparator(); |
| 571 |
|
} |
| 572 |
< |
if ((tok & Token.predefinedset) != Token.predefinedset) { |
| 572 |
> |
if ((tok & Token::predefinedset) != Token::predefinedset) { |
| 573 |
|
break; |
| 574 |
|
} |
| 575 |
|
// fall into the code and below and just add the token |
| 576 |
< |
case Token.all: |
| 577 |
< |
case Token.none: |
| 576 |
> |
case Token::all: |
| 577 |
> |
case Token::none: |
| 578 |
|
return addTokenToPostfix(tokenNext()); |
| 579 |
< |
case Token.leftparen: |
| 579 |
> |
case Token::leftparen: |
| 580 |
|
tokenNext(); |
| 581 |
|
if (!clauseOr()) { |
| 582 |
|
return false; |
| 583 |
|
} |
| 584 |
< |
if (tokenNext().tok != Token.rightparen) { |
| 584 |
> |
if (tokenNext().tok != Token::rightparen) { |
| 585 |
|
return rightParenthesisExpected(); |
| 586 |
|
} |
| 587 |
|
return true; |
| 592 |
|
bool SelectionCompiler::clauseComparator() { |
| 593 |
|
Token tokenAtomProperty = tokenNext(); |
| 594 |
|
Token tokenComparator = tokenNext(); |
| 595 |
< |
if ((tokenComparator.tok & Token.comparator) == 0) { |
| 595 |
> |
if ((tokenComparator.tok & Token::comparator) == 0) { |
| 596 |
|
return comparisonOperatorExpected(); |
| 597 |
|
} |
| 598 |
|
|
| 599 |
|
Token tokenValue = tokenNext(); |
| 600 |
< |
if (tokenValue.tok != Token.integer) { |
| 600 |
> |
if (tokenValue.tok != Token::integer) { |
| 601 |
|
return integerExpected(); |
| 602 |
|
} |
| 603 |
|
int val = tokenValue.intValue; |
| 605 |
|
// int intValue is the tok of the property you are comparing |
| 606 |
|
// the value against which you are comparing is stored as an Integer |
| 607 |
|
// in the object value |
| 608 |
< |
return addTokenToPostfix(new Token(tokenComparator.tok, |
| 609 |
< |
tokenAtomProperty.tok, |
| 612 |
< |
new Integer(val))); |
| 608 |
> |
return addTokenToPostfix(Token(tokenComparator.tok, |
| 609 |
> |
tokenAtomProperty.tok, boost::any(val))); |
| 610 |
|
} |
| 611 |
|
|
| 612 |
|
bool SelectionCompiler::clauseWithin() { |
| 613 |
|
tokenNext(); // WITHIN |
| 614 |
< |
if (tokenNext().tok != Token.leftparen) { // ( |
| 614 |
> |
if (tokenNext().tok != Token::leftparen) { // ( |
| 615 |
|
return leftParenthesisExpected(); |
| 616 |
|
} |
| 617 |
|
|
| 618 |
< |
Object distance; |
| 618 |
> |
boost::any distance; |
| 619 |
|
Token tokenDistance = tokenNext(); // distance |
| 620 |
|
switch(tokenDistance.tok) { |
| 621 |
< |
case Token.integer: |
| 622 |
< |
distance = new Float((tokenDistance.intValue * 4) / 1000f); |
| 621 |
> |
case Token::integer: |
| 622 |
> |
distance = float(tokenDistance.intValue); |
| 623 |
|
break; |
| 624 |
< |
case Token.decimal: |
| 624 |
> |
case Token::decimal: |
| 625 |
|
distance = tokenDistance.value; |
| 626 |
|
break; |
| 627 |
|
default: |
| 628 |
|
return numberOrKeywordExpected(); |
| 629 |
|
} |
| 630 |
|
|
| 631 |
< |
if (tokenNext().tok != Token.opOr) { // , |
| 631 |
> |
if (tokenNext().tok != Token::opOr) { // , |
| 632 |
|
return commaExpected(); |
| 633 |
|
} |
| 634 |
|
|
| 636 |
|
return false; |
| 637 |
|
} |
| 638 |
|
|
| 639 |
< |
if (tokenNext().tok != Token.rightparen) { // )T |
| 639 |
> |
if (tokenNext().tok != Token::rightparen) { // )T |
| 640 |
|
return rightParenthesisExpected(); |
| 641 |
|
} |
| 642 |
|
|
| 643 |
< |
return addTokenToPostfix(new Token(Token.within, distance)); |
| 643 |
> |
return addTokenToPostfix(Token(Token::within, distance)); |
| 644 |
|
} |
| 645 |
|
|
| 646 |
< |
bool SelectionCompiler:: clauseChemObject() { |
| 647 |
< |
} |
| 646 |
> |
bool SelectionCompiler::clauseChemObjName() { |
| 647 |
> |
std::string chemObjName; |
| 648 |
> |
int tok = tokPeek(); |
| 649 |
> |
if (!clauseName(chemObjName)){ |
| 650 |
> |
return false; |
| 651 |
> |
} |
| 652 |
|
|
| 652 |
– |
bool SelectionCompiler:: clauseMolecule() { |
| 653 |
– |
} |
| 653 |
|
|
| 654 |
< |
bool SelectionCompiler:: clauseMolName() { |
| 655 |
< |
} |
| 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 |
< |
bool SelectionCompiler:: clauseMolIndex() { |
| 668 |
> |
return addTokenToPostfix(Token(Token::name, chemObjName)); |
| 669 |
|
} |
| 670 |
|
|
| 671 |
< |
bool SelectionCompiler:: clauseName() { |
| 662 |
< |
} |
| 671 |
> |
bool SelectionCompiler:: clauseName(std::string& name) { |
| 672 |
|
|
| 673 |
< |
bool SelectionCompiler:: clauseIndex() { |
| 665 |
< |
} |
| 673 |
> |
int tok = tokPeek(); |
| 674 |
|
|
| 675 |
< |
bool SelectionCompiler:: clauseStuntDoubleName() { |
| 676 |
< |
} |
| 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 |
|
|
| 670 |
– |
bool SelectionCompiler:: clauseStuntDoubleIndex() { |
| 702 |
|
} |
| 703 |
|
|
| 704 |
+ |
|
| 705 |
|
} |