You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
811 B

4 years ago
  1. var consumeNumber = require('../../tokenizer/utils').consumeNumber;
  2. var TYPE = require('../../tokenizer').TYPE;
  3. var DIMENSION = TYPE.Dimension;
  4. module.exports = {
  5. name: 'Dimension',
  6. structure: {
  7. value: String,
  8. unit: String
  9. },
  10. parse: function() {
  11. var start = this.scanner.tokenStart;
  12. var numberEnd = consumeNumber(this.scanner.source, start);
  13. this.eat(DIMENSION);
  14. return {
  15. type: 'Dimension',
  16. loc: this.getLocation(start, this.scanner.tokenStart),
  17. value: this.scanner.source.substring(start, numberEnd),
  18. unit: this.scanner.source.substring(numberEnd, this.scanner.tokenStart)
  19. };
  20. },
  21. generate: function(node) {
  22. this.chunk(node.value);
  23. this.chunk(node.unit);
  24. }
  25. };