var.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var TYPE = require('../../tokenizer').TYPE;
  2. var IDENTIFIER = TYPE.Identifier;
  3. var COMMA = TYPE.Comma;
  4. var SEMICOLON = TYPE.Semicolon;
  5. var HYPHENMINUS = TYPE.HyphenMinus;
  6. var EXCLAMATIONMARK = TYPE.ExclamationMark;
  7. // var '(' ident (',' <value>? )? ')'
  8. module.exports = function() {
  9. var children = this.createList();
  10. this.scanner.skipSC();
  11. var identStart = this.scanner.tokenStart;
  12. this.scanner.eat(HYPHENMINUS);
  13. if (this.scanner.source.charCodeAt(this.scanner.tokenStart) !== HYPHENMINUS) {
  14. this.scanner.error('HyphenMinus is expected');
  15. }
  16. this.scanner.eat(IDENTIFIER);
  17. children.push({
  18. type: 'Identifier',
  19. loc: this.getLocation(identStart, this.scanner.tokenStart),
  20. name: this.scanner.substrToCursor(identStart)
  21. });
  22. this.scanner.skipSC();
  23. if (this.scanner.tokenType === COMMA) {
  24. children.push(this.Operator());
  25. children.push(this.parseCustomProperty
  26. ? this.Value(null)
  27. : this.Raw(this.scanner.currentToken, EXCLAMATIONMARK, SEMICOLON, false, false)
  28. );
  29. }
  30. return children;
  31. };