IdSelector.js 595 B

123456789101112131415161718192021222324252627
  1. var TYPE = require('../../tokenizer').TYPE;
  2. var HASH = TYPE.Hash;
  3. // <hash-token>
  4. module.exports = {
  5. name: 'IdSelector',
  6. structure: {
  7. name: String
  8. },
  9. parse: function() {
  10. var start = this.scanner.tokenStart;
  11. // TODO: check value is an ident
  12. this.eat(HASH);
  13. return {
  14. type: 'IdSelector',
  15. loc: this.getLocation(start, this.scanner.tokenStart),
  16. name: this.scanner.substrToCursor(start + 1)
  17. };
  18. },
  19. generate: function(node) {
  20. this.chunk('#');
  21. this.chunk(node.name);
  22. }
  23. };