source: trip-planner-front/node_modules/css-tree/lib/syntax/node/Combinator.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1var TYPE = require('../../tokenizer').TYPE;
2
3var IDENT = TYPE.Ident;
4var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
5var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
6var GREATERTHANSIGN = 0x003E; // U+003E GREATER-THAN SIGN (>)
7var TILDE = 0x007E; // U+007E TILDE (~)
8
9// + | > | ~ | /deep/
10module.exports = {
11 name: 'Combinator',
12 structure: {
13 name: String
14 },
15 parse: function() {
16 var start = this.scanner.tokenStart;
17 var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
18
19 switch (code) {
20 case GREATERTHANSIGN:
21 case PLUSSIGN:
22 case TILDE:
23 this.scanner.next();
24 break;
25
26 case SOLIDUS:
27 this.scanner.next();
28
29 if (this.scanner.tokenType !== IDENT || this.scanner.lookupValue(0, 'deep') === false) {
30 this.error('Identifier `deep` is expected');
31 }
32
33 this.scanner.next();
34
35 if (!this.scanner.isDelim(SOLIDUS)) {
36 this.error('Solidus is expected');
37 }
38
39 this.scanner.next();
40 break;
41
42 default:
43 this.error('Combinator is expected');
44 }
45
46 return {
47 type: 'Combinator',
48 loc: this.getLocation(start, this.scanner.tokenStart),
49 name: this.scanner.substrToCursor(start)
50 };
51 },
52 generate: function(node) {
53 this.chunk(node.name);
54 }
55};
Note: See TracBrowser for help on using the repository browser.