Parse an array of tokens into a syntax tree
@param {object[]} tokens
@param {string} basePath
@param {number} iterSuffix
@returns {[object[], number]}
162706
function parse(tokens, basePath, iterSuffix) {
  const len = tokens.length;
  const body = [];

  let i = 0;
  while (i < len) {
    const token = tokens[i];
    if (subroutines[token.tokenType]) {
      const rest = tokens.slice(i + 1);
      const [
        branches,
        tokensHandled,
        shouldBreak,
      ] = subroutines[token.tokenType](token, rest, basePath, iterSuffix);

      body.push(...branches);

      i += tokensHandled;

      if (shouldBreak) {
        break;
      }
    } else {
      i += 1;
    }
  }

  return [body, i + 1];
}
84249
function process_token(token, index, tokens) {
	var last = (index === (tokens.length - 1));
	if (token[0] === "+") return process_single(token, last);
	else if (token[0] === "#") return process_multi(token, last);
	else return process_raw(token, last);
}
499228
function buildRegExps(basePath, dirPaths) {
  return dirPaths.map(folderPath =>
    // Babel `only` option works with forward slashes in the RegExp so replace
    // backslashes for Windows.
    new RegExp(`^${escapeRegExp(path.resolve(basePath, folderPath).replace(/\\/g, '/'))}`)
  );
}
254061
function parseArgumentList() {
                    var token, expr, args = [];

                    while (true) {
                        expr = parseExpression();
                        if (typeof expr === 'undefined') {
                            break;
                        }
                        args.push(expr);
                        token = lexer.peek();
                        if (!matchOp(token, ',')) {
                            break;
                        }
                        lexer.next();
                    }

                    return args;
                }
1139479
function fparse(fpath) {
  if (fs.existsSync(!fpath)) {
    console.error(config_file + ': No such file.');
    return [false, false];
  }

  var fd        = fs.openSync(fpath, 'r');
  var read      = '';
  var pos       = 0;
  var start     = 0;
  var Ns        = {};
  var currentNs = null;
  var currentN  = null;
  var remnant   = '';
  var result    = {};
  var buffsize  = 65535;
  var summary   = null;
  var length    = 0;
  var emptyline = 0;

  function setAtEnd(_summary, _length, _emptyline) {
    // result, and fpath is in outer scope.
    _summary.length = _length - _emptyline;
    result[_summary.id] = new FASTA(_summary, fpath);
  }


  do {
    read = fs.readSync(fd, buffsize, pos);

    var lines = (remnant + read[0]).split('\n');
    remnant = lines.pop();

    lines.forEach(function(line, i) {

      if (line.match('N')) {
        if (!currentN) {
          currentN = {
            line: i,
            start: start + length,
            end : start + length+ line.length
          };
        }
        else {
          currentN.line++;
          currentN.end += line.length;
        }
      }
      else if (currentN) {
        currentNs.push(currentN);
        currentN = null;
      }

      if (line == '') {
        emptyline++;
      }
      else if (line.charAt(0) == '>') {
        // register a previous summary
        if (summary) {
          setAtEnd(summary, length, emptyline);
        }
        start += length;
        emptyline = 0;
        length    = 0;
        // make a new summary
        var id_desc = line.slice(1).split(' ');
        var id = id_desc.shift();
        var desc = (id_desc.length) ? id_desc.join(' ') : null;
        summary = {id: id, desc: desc, start: start, linelen: 0};
        // make a new Ns
        Ns[summary.id] = [];
        currentNs = Ns[summary.id];
      }
      else {
        if (!summary) {
          console.error(fpath +' does not seem to be FASTA format.');
          process.exit();
        }
        if (!summary.linelen) {
          summary.linelen = line.length;
        }
      }
      length += line.length + 1;
    });
    pos = pos + read[1];
  }
  while (read[1] > 0);

  // end
  length += remnant.replace('\n', '').length;
  setAtEnd(summary, length, emptyline);

  fs.closeSync(fd);
  return [result, Ns];
}
1198380
def _parse_tokens(tokens):
    

    index = 0
    parsed_tokens = []

    num_tokens = len(tokens)
    while index < num_tokens:
        tok = Token(*tokens[index])

        assert tok.token_type != token.INDENT
        if tok.token_type == tokenize.NEWLINE:
            # There's only one newline and it's at the end.
            break

        if tok.token_string in '([{':
            (container, index) = _parse_container(tokens, index)
            if not container:
                return None
            parsed_tokens.append(container)
        else:
            parsed_tokens.append(Atom(tok))

        index += 1

    return parsed_tokens
1129260
function tokensToRegExp (tokens, keys, options) {
  if (!isarray(keys)) {
    options = /** @type {!Object} */ (keys || options);
    keys = [];
  }

  options = options || {};

  var strict = options.strict;
  var end = options.end !== false;
  var route = '';

  // Iterate over the tokens and create our regexp string.
  for (var i = 0; i < tokens.length; i++) {
    var token = tokens[i];

    if (typeof token === 'string') {
      route += escapeString(token);
    } else {
      var prefix = escapeString(token.prefix);
      var capture = '(?:' + token.pattern + ')';

      keys.push(token);

      if (token.repeat) {
        capture += '(?:' + prefix + capture + ')*';
      }

      if (token.optional) {
        if (!token.partial) {
          capture = '(?:' + prefix + '(' + capture + '))?';
        } else {
          capture = prefix + '(' + capture + ')?';
        }
      } else {
        capture = prefix + '(' + capture + ')';
      }

      route += capture;
    }
  }

  var delimiter = escapeString(options.delimiter || '/');
  var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;

  // In non-strict mode we allow a slash at the end of match. If the path to
  // match already ends with a slash, we remove it for consistency. The slash
  // is valid at the end of a path match, not in the middle. This is important
  // in non-ending mode, where "/test/" shouldn't match "/test//route".
  if (!strict) {
    route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + '(?:' + delimiter + '(?=$))?';
  }

  if (end) {
    route += '$';
  } else {
    // In non-ending mode, we need the capturing groups to match as much as
    // possible by using a positive lookahead to the end or next path segment.
    route += strict && endsWithDelimiter ? '' : '(?=' + delimiter + '|$)';
  }

  return attachKeys(new RegExp('^' + route, flags(options)), keys)
}
556028
function parseMustaches(s, name, node, prepareBindingFn) {
    if (!s || !s.length)
      return;

    var tokens;
    var length = s.length;
    var startIndex = 0, lastIndex = 0, endIndex = 0;
    var onlyOneTime = true;
    while (lastIndex < length) {
      var startIndex = s.indexOf('{{', lastIndex);
      var oneTimeStart = s.indexOf('[[', lastIndex);
      var oneTime = false;
      var terminator = '}}';

      if (oneTimeStart >= 0 &&
          (startIndex < 0 || oneTimeStart < startIndex)) {
        startIndex = oneTimeStart;
        oneTime = true;
        terminator = ']]';
      }

      endIndex = startIndex < 0 ? -1 : s.indexOf(terminator, startIndex + 2);

      if (endIndex < 0) {
        if (!tokens)
          return;

        tokens.push(s.slice(lastIndex)); // TEXT
        break;
      }

      tokens = tokens || [];
      tokens.push(s.slice(lastIndex, startIndex)); // TEXT
      var pathString = s.slice(startIndex + 2, endIndex).trim();
      tokens.push(oneTime); // ONE_TIME?
      onlyOneTime = onlyOneTime && oneTime;
      var delegateFn = prepareBindingFn &&
                       prepareBindingFn(pathString, name, node);
      // Don't try to parse the expression if there's a prepareBinding function
      if (delegateFn == null) {
        tokens.push(Path.get(pathString)); // PATH
      } else {
        tokens.push(null);
      }
      tokens.push(delegateFn); // DELEGATE_FN
      lastIndex = endIndex + 2;
    }

    if (lastIndex === length)
      tokens.push(''); // TEXT

    tokens.hasOnePath = tokens.length === 5;
    tokens.isSimplePath = tokens.hasOnePath &&
                          tokens[0] == '' &&
                          tokens[4] == '';
    tokens.onlyOneTime = onlyOneTime;

    tokens.combinator = function(values) {
      var newValue = tokens[0];

      for (var i = 1; i < tokens.length; i += 4) {
        var value = tokens.hasOnePath ? values : values[(i - 1) / 4];
        if (value !== undefined)
          newValue += value;
        newValue += tokens[i + 3];
      }

      return newValue;
    }

    return tokens;
  }
239507
function handleEscaping(tokens, token, index) {
	if (index === 0) {
		return [token];
	}

	const previousToken = tokens[index - 1];

	if (!previousToken.endsWith('\\')) {
		return [...tokens, token];
	}

	return [...tokens.slice(0, index - 1), `${previousToken.slice(0, -1)} ${token}`];
}
609553
function parseItemOrGroup(tokenizer) {
  var tkn = tokenizer.next();
  if (!tkn) return null;
  if (tkn.typ == '{') {
    return parseGroup(tokenizer);
  }
  return {tag: tkn.typ, children: tkn.txt};
}
1363729
function parse(path) {
  if (t.Array.is(path)) {
    return path.map(parse).filter(Boolean);
  }
  var component = getComponent(require(path));
  if (component) {
    var comments = getComments(path);
    var descriptions = getDescriptions(comments);
    var type = toObject(getPropsType(component));
    var props = type.kind === 'refinement' ? type.type.props : type.props;
    var defaultProps = getDefaultProps(component);
    var name = getComponentName(component);
    for (var prop in props) {
      if (props.hasOwnProperty(prop)) {
        if (defaultProps.hasOwnProperty(prop)) {
          props[prop].defaultValue = defaultProps[prop];
        }
        if (descriptions.props.hasOwnProperty(prop)) {
          props[prop].description = descriptions.props[prop];
        }
      }
    }
    return {
      name: name,
      description: descriptions.component,
      props: props
    };
  }
}
1225732
protected void parseIntegerLists(TokenList tokens) {
        TokenList.Token t = tokens.getFirst();
        if( t == null || t.next == null )
            return;

        int state = 0;

        TokenList.Token start = null;
        TokenList.Token prev = t;

        boolean last = false;
        while( true ) {
            if( state == 0 ) {
                if( isVariableInteger(t) ) {
                    start = t;
                    state = 1;
                }
            } else if( state == 1 ) {
                // var ?
                if( isVariableInteger(t)) {                 // see if its explicit number sequence
                    state = 2;
                } else {  // just scalar integer, skip
                    state = 0;
                }
            } else if ( state == 2 ) {
                // var var ....
                if( !isVariableInteger(t) ) {
                    // create explicit list sequence
                    IntegerSequence sequence = new IntegerSequence.Explicit(start,prev);
                    VariableIntegerSequence varSequence = functions.getManagerTemp().createIntegerSequence(sequence);
                    replaceSequence(tokens, varSequence, start, prev);
                    state = 0;
                }
            }

            if( last ) {
                break;
            } else if( t.next == null ) {
                // handle the case where it is the last token in the sequence
                last = true;
            }
            prev = t;
            t = t.next;
        }
    }
171296
function buildRegExps(basePath, dirPaths) {
  return dirPaths.map(folderPath =>
    // Babel cares about windows/unix paths since v7b44
    // https://github.com/babel/babel/issues/8184
    // basePath + path.sep + dirPath/dirRegex
    // /home/name/webroot/js + / + relative/path/to/exclude
    // c:\home\name\webroot\js + \ + relative\path\to\exclude
    folderPath instanceof RegExp
      ? new RegExp(
          `^${escapeRegExp(path.resolve(basePath, '.') + path.sep)}${
            folderPath.source // This is actual regex, don't escape it
          }`,
          folderPath.flags,
        )
      : new RegExp('^' + escapeRegExp(path.resolve(basePath, folderPath))),
  );
}
323695
function parseStatement(lex, isRoot = false) {
    return parseFunctionDeclaration(lex) ||
           isRoot && parseOperatorStatement(lex) ||
           isRoot && parseObjectDeclaration(lex) ||
           parseIf(lex) ||
           parseReturn(lex) ||
           isRoot && parseExport(lex) ||
           isRoot && parseImport(lex) ||
           parseSwitchType(lex) ||
           parseWhile(lex) ||
           parseDoWhile(lex) ||
           parseFor(lex) ||
           parseBreak(lex) ||
           parseContinue(lex) ||
           parseExpressionBase(lex);
}
681879
function parse (str, options) {
  var tokens = [];
  var key = 0;
  var index = 0;
  var path = '';
  var defaultDelimiter = options && options.delimiter || '/';
  var res;

  while ((res = PATH_REGEXP.exec(str)) != null) {
    var m = res[0];
    var escaped = res[1];
    var offset = res.index;
    path += str.slice(index, offset);
    index = offset + m.length;

    // Ignore already escaped sequences.
    if (escaped) {
      path += escaped[1];
      continue
    }

    var next = str[index];
    var prefix = res[2];
    var name = res[3];
    var capture = res[4];
    var group = res[5];
    var modifier = res[6];
    var asterisk = res[7];

    // Push the current path onto the tokens.
    if (path) {
      tokens.push(path);
      path = '';
    }

    var partial = prefix != null && next != null && next !== prefix;
    var repeat = modifier === '+' || modifier === '*';
    var optional = modifier === '?' || modifier === '*';
    var delimiter = res[2] || defaultDelimiter;
    var pattern = capture || group;

    tokens.push({
      name: name || key++,
      prefix: prefix || '',
      delimiter: delimiter,
      optional: optional,
      repeat: repeat,
      partial: partial,
      asterisk: !!asterisk,
      pattern: pattern ? escapeGroup(pattern) : (asterisk ? '.*' : '[^' + escapeString(delimiter) + ']+?')
    });
  }

  // Match any characters still remaining.
  if (index < str.length) {
    path += str.substr(index);
  }

  // If the path exists, push it onto the end.
  if (path) {
    tokens.push(path);
  }

  return tokens
}
135796
boolean isPrefixOf(BasePath<B> path) {
    ImmutableList<String> prefixSegments = getSegments();
    ImmutableList<String> childSegments = path.getSegments();
    if (prefixSegments.size() > path.getSegments().size()) {
      return false;
    }
    for (int i = 0; i < prefixSegments.size(); i++) {
      if (!prefixSegments.get(i).equals(childSegments.get(i))) {
        return false;
      }
    }
    return true;
  }
926152
def _parse_join(self, tokens):
        
        children = []
        tokens.pop(0)  # Pop 'join'
        tokens.pop(0)  # Pop '('
        children.append(self._parse_nested_interval(tokens))
        while tokens[0] == ',':
            tokens.pop(0)
            children.append(self._parse_nested_interval(tokens))
        tokens.pop(0)  # Pop ')'

        chromosome, strand = next((child.chromosome, child.strand) for child in children)
        start = min(child.start.position for child in children)
        stop = max(child.stop.position for child in children)
        parent = NestedGenomicInterval(start, stop, chromosome=chromosome, strand=strand)
        parent.children = children
        return parent