src/rsql-parser.js
/**
 *  for each parenthesized section, 
 *    remove unnessisary parentheses if exist;
 *    add to array if it is operation unit;
 *    recursivly tokenize the section if it is not an operation unit 
 */
for each parenthesized section,
remove unnessisary parentheses if exist;
add to array if it is operation unit;
recursivly tokenize the section if it is not an operation unit
for each parenthesized section remove unnessisary parentheses if exist ; add to array if it is operation unit ; recursivly tokenize the section if it is not an operation unit
function analyzeNAddSection(token, _and_or) {
  logger.debug('Into rsqlParser.analyzeNAddSection() token', token);
  var tokenSections = [];
  peerParenthesizedSections(token, tokenSections);
  logger.debug('for this token - peer parenthesized sections', tokenSections);
  if (tokenSections.length === 0) {
    _and_or.push(token);
  }
  else if (tokenSections.length === 1) {
    if (isParenthesized(tokenSections[0])) {
      analyzeNAddSection(tokenSections[0], _and_or);
    }
    tokenSections[0] = tokenSections[0].replace(/\*/g, ';');
    tokenSections[0] = tokenSections[0].replace(/\#/g, ',');
    tokenSections[0] = maskParenthesizedSections(tokenSections[0]);
    _and_or.push(tokenizeRsqlSection(tokenSections[0]));
  }
  else {
    logger.error('The parenthesized token should only contains one outer section');
  }
}
function analyzeNAddSection ( token , _and_or ) { logger . debug ( 'Into rsqlParser.analyzeNAddSection() token' , token ) ; var tokenSections = [ ] ; peerParenthesizedSections ( token , tokenSections ) ; logger . debug ( 'for this token - peer parenthesized sections' , tokenSections ) ; if ( tokenSections . length === 0 ) { _and_or . push ( token ) ; } else if ( tokenSections . length === 1 ) { if ( isParenthesized ( tokenSections [ 0 ] ) ) { analyzeNAddSection ( tokenSections [ 0 ] , _and_or ) ; } tokenSections [ 0 ] = tokenSections [ 0 ] . replace ( / \* / g , ';' ) ; tokenSections [ 0 ] = tokenSections [ 0 ] . replace ( / \# / g , ',' ) ; tokenSections [ 0 ] = maskParenthesizedSections ( tokenSections [ 0 ] ) ; _and_or . push ( tokenizeRsqlSection ( tokenSections [ 0 ] ) ) ; } else { logger . error ( 'The parenthesized token should only contains one outer section' ) ; } }
for each parenthesized section,
    remove unnessisary parentheses if exist;
    add to array if it is operation unit;
    recursivly tokenize the section if it is not an operation unit
for each parenthesized section remove unnessisary parentheses if exist ; add to array if it is operation unit ; recursivly tokenize the section if it is not an operation unit
// do not add empty token /*
  if (objUtil.isEmpty(token)) {
    return;
  }
  */ // continue deal with non empty token // the token itself is not parenthesized, add it to _and_or array // check and see if tokenSections[0] is a parenthesized section itself // analyze the parenthesized section recursivly to remove outer parentheses /* if the element is a section(not operation unit) 
        continue tokenize section recursively.
        this token should be parenthesized.
    */ // un-mask replace '*' with ';' and '#' with ',' // mask parenthesized section // tokenize this section