source: trip-planner-front/node_modules/css-tree/lib/syntax/atrule/supports.js@ 6a80231

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

initial commit

  • Property mode set to 100644
File size: 1.9 KB
Line 
1var TYPE = require('../../tokenizer').TYPE;
2
3var WHITESPACE = TYPE.WhiteSpace;
4var COMMENT = TYPE.Comment;
5var IDENT = TYPE.Ident;
6var FUNCTION = TYPE.Function;
7var COLON = TYPE.Colon;
8var LEFTPARENTHESIS = TYPE.LeftParenthesis;
9
10function consumeRaw() {
11 return this.createSingleNodeList(
12 this.Raw(this.scanner.tokenIndex, null, false)
13 );
14}
15
16function parentheses() {
17 this.scanner.skipSC();
18
19 if (this.scanner.tokenType === IDENT &&
20 this.lookupNonWSType(1) === COLON) {
21 return this.createSingleNodeList(
22 this.Declaration()
23 );
24 }
25
26 return readSequence.call(this);
27}
28
29function readSequence() {
30 var children = this.createList();
31 var space = null;
32 var child;
33
34 this.scanner.skipSC();
35
36 scan:
37 while (!this.scanner.eof) {
38 switch (this.scanner.tokenType) {
39 case WHITESPACE:
40 space = this.WhiteSpace();
41 continue;
42
43 case COMMENT:
44 this.scanner.next();
45 continue;
46
47 case FUNCTION:
48 child = this.Function(consumeRaw, this.scope.AtrulePrelude);
49 break;
50
51 case IDENT:
52 child = this.Identifier();
53 break;
54
55 case LEFTPARENTHESIS:
56 child = this.Parentheses(parentheses, this.scope.AtrulePrelude);
57 break;
58
59 default:
60 break scan;
61 }
62
63 if (space !== null) {
64 children.push(space);
65 space = null;
66 }
67
68 children.push(child);
69 }
70
71 return children;
72}
73
74module.exports = {
75 parse: {
76 prelude: function() {
77 var children = readSequence.call(this);
78
79 if (this.getFirstListNode(children) === null) {
80 this.error('Condition is expected');
81 }
82
83 return children;
84 },
85 block: function() {
86 return this.Block(false);
87 }
88 }
89};
Note: See TracBrowser for help on using the repository browser.