lib/tokenizer.js
function parseNextToken(template, grammar, stack) {
    grammar.some(function(token) {
      var capture = token.test.exec(template);

      // Ignore empty captures.
      if (capture && capture[0]) {
        template = template.replace(token.test, "");
        stack.push({ name: token.name, capture: capture });
        return true;
      }
    });

    return template;
  }
function parseNextToken(template, grammar, stack) {
    grammar.some(function(token) {
      var capture = token.test.exec(template);

      // Ignore empty captures.
      if (capture && capture[0]) {
        template = template.replace(token.test, "");
        stack.push({ name: token.name, capture: capture });
        return true;
      }
    });

    return template;
  }
function parseNextToken ( template , grammar , stack ) { grammar . some ( function ( token ) { var capture = token . test . exec ( template ) ; // Ignore empty captures. if ( capture && capture [ 0 ] ) { template = template . replace ( token . test , "" ) ; stack . push ( { name : token . name , capture : capture } ) ; return true ; } } ) ; return template ; }
Loop through the grammar and return on the first source match.  Remove
matches from the source, after pushing to the stack.

@private
@param {string} template that is searched on till its length is 0.
@param {array} grammar array of test regexes.
@param {array} stack to push found tokens to.
@returns {string} template that has been truncated.
Loop through the grammar and return on the first source match . Remove matches from the source after pushing to the stack .