Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | var TYPE = require('../../tokenizer').TYPE;
|
---|
| 2 |
|
---|
| 3 | var WHITESPACE = TYPE.WhiteSpace;
|
---|
| 4 | var COMMENT = TYPE.Comment;
|
---|
| 5 | var IDENT = TYPE.Ident;
|
---|
| 6 | var LEFTPARENTHESIS = TYPE.LeftParenthesis;
|
---|
| 7 |
|
---|
| 8 | module.exports = {
|
---|
| 9 | name: 'MediaQuery',
|
---|
| 10 | structure: {
|
---|
| 11 | children: [[
|
---|
| 12 | 'Identifier',
|
---|
| 13 | 'MediaFeature',
|
---|
| 14 | 'WhiteSpace'
|
---|
| 15 | ]]
|
---|
| 16 | },
|
---|
| 17 | parse: function() {
|
---|
| 18 | this.scanner.skipSC();
|
---|
| 19 |
|
---|
| 20 | var children = this.createList();
|
---|
| 21 | var child = null;
|
---|
| 22 | var space = null;
|
---|
| 23 |
|
---|
| 24 | scan:
|
---|
| 25 | while (!this.scanner.eof) {
|
---|
| 26 | switch (this.scanner.tokenType) {
|
---|
| 27 | case COMMENT:
|
---|
| 28 | this.scanner.next();
|
---|
| 29 | continue;
|
---|
| 30 |
|
---|
| 31 | case WHITESPACE:
|
---|
| 32 | space = this.WhiteSpace();
|
---|
| 33 | continue;
|
---|
| 34 |
|
---|
| 35 | case IDENT:
|
---|
| 36 | child = this.Identifier();
|
---|
| 37 | break;
|
---|
| 38 |
|
---|
| 39 | case LEFTPARENTHESIS:
|
---|
| 40 | child = this.MediaFeature();
|
---|
| 41 | break;
|
---|
| 42 |
|
---|
| 43 | default:
|
---|
| 44 | break scan;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | if (space !== null) {
|
---|
| 48 | children.push(space);
|
---|
| 49 | space = null;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | children.push(child);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | if (child === null) {
|
---|
| 56 | this.error('Identifier or parenthesis is expected');
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | return {
|
---|
| 60 | type: 'MediaQuery',
|
---|
| 61 | loc: this.getLocationFromList(children),
|
---|
| 62 | children: children
|
---|
| 63 | };
|
---|
| 64 | },
|
---|
| 65 | generate: function(node) {
|
---|
| 66 | this.children(node);
|
---|
| 67 | }
|
---|
| 68 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.