lib/lexer.js
function(type, regex) {
    var cached = this.regex.create(type, regex);
    var lexer = this;

    var fn = this.lexers[type] = function() {
      var pos = lexer.position();
      var m = lexer.match(cached.val);
      if (!m || !m[0]) return;

      var parent = lexer.prev();
      var node = pos({
        type: type,
        val: m[0]
      });

      utils.define(node, 'parent', parent);
      utils.define(node, 'rawArgs', m[1]);
      utils.define(node, 'args', function() {
        return utils.parseArgs(m[1]);
      });

      parent.nodes.push(node);
    };

    this.addLexer(fn);
    return this;
  }
function(type, regex) {
    var cached = this.regex.create(type, regex);
    var lexer = this;

    var fn = this.lexers[type] = function() {
      var pos = lexer.position();
      var m = lexer.match(cached.val);
      if (!m || !m[0]) return;

      var parent = lexer.prev();
      var node = pos({
        type: type,
        val: m[0]
      });

      utils.define(node, 'parent', parent);
      utils.define(node, 'rawArgs', m[1]);
      utils.define(node, 'args', function() {
        return utils.parseArgs(m[1]);
      });

      parent.nodes.push(node);
    };

    this.addLexer(fn);
    return this;
  }
function ( type , regex ) { var cached = this . regex . create ( type , regex ) ; var lexer = this ; var fn = this . lexers [ type ] = function ( ) { var pos = lexer . position ( ) ; var m = lexer . match ( cached . val ) ; if ( ! m || ! m [ 0 ] ) return ; var parent = lexer . prev ( ) ; var node = pos ( { type : type , val : m [ 0 ] } ) ; utils . define ( node , 'parent' , parent ) ; utils . define ( node , 'rawArgs' , m [ 1 ] ) ; utils . define ( node , 'args' , function ( ) { return utils . parseArgs ( m [ 1 ] ) ; } ) ; parent . nodes . push ( node ) ; } ; this . addLexer ( fn ) ; return this ; }
Capture `type` with the given regex.
@param {String} `type`
@param {RegExp} `regex`
@return {Function}
Capture type with the given regex .