code: function(selector) {
          var token = {},     // one token per simple selector (left selector holds combinator)
              tokens = [],    // array of tokens
              id,             // unique id for the simple selector (if found)
              found = false,  // whether or not any matches were found this pass
              patterns = Y.Selector._patterns,
              match;          // the regex match
  
          selector = Y.Selector._replaceShorthand(selector); // convert ID and CLASS shortcuts to attributes
  
          /*
              Search for selector patterns, store, and strip them from the selector string
              until no patterns match (invalid selector) or we run out of chars.
  
              Multiple attributes and pseudos are allowed, in any order.
              for example:
                  'form:first-child[type=button]:not(button)[lang|=en]'
          */
          do {
              found = false; // reset after full pass
              for (var re in patterns) {
                  if (YAHOO.lang.hasOwnProperty(patterns, re)) {
                      if (re != 'tag' && re != 'combinator') { // only one allowed
                          token[re] = token[re] || [];
                      }
                      if ( (match = patterns[re].exec(selector)) ) { // note assignment
                          found = true;
                          if (re != 'tag' && re != 'combinator') { // only one allowed
                              // capture ID for fast path to element
                              if (re === 'attributes' && match[1] === 'id') {
                                  token.id = match[3];
                              }
  
                              token[re].push(match.slice(1));
                          } else { // single selector (tag, combinator)
                              token[re] = match[1];
                          }
                          selector = selector.replace(match[0], ''); // strip current match from selector
                          if (re === 'combinator' || !selector.length) { // next token or done
                              token.attributes = Y.Selector._fixAttributes(token.attributes);
                              token.pseudos = token.pseudos || [];
                              token.tag = token.tag ? token.tag.toUpperCase() : '*';
                              tokens.push(token);
  
                              token = { // prep next token
                                  previous: token
                              };
                          }
                      }
                  }
              }
          } while (found);
  
          return tokens;
      }
docs: Break selector into token units per simple selector.
  Combinator is attached to left-hand selector.