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.3 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | var TYPE = require('../../tokenizer').TYPE;
|
---|
| 2 | var rawMode = require('./Raw').mode;
|
---|
| 3 |
|
---|
| 4 | var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
|
---|
| 5 |
|
---|
| 6 | function consumeRaw(startToken) {
|
---|
| 7 | return this.Raw(startToken, rawMode.leftCurlyBracket, true);
|
---|
| 8 | }
|
---|
| 9 |
|
---|
| 10 | function consumePrelude() {
|
---|
| 11 | var prelude = this.SelectorList();
|
---|
| 12 |
|
---|
| 13 | if (prelude.type !== 'Raw' &&
|
---|
| 14 | this.scanner.eof === false &&
|
---|
| 15 | this.scanner.tokenType !== LEFTCURLYBRACKET) {
|
---|
| 16 | this.error();
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | return prelude;
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | module.exports = {
|
---|
| 23 | name: 'Rule',
|
---|
| 24 | structure: {
|
---|
| 25 | prelude: ['SelectorList', 'Raw'],
|
---|
| 26 | block: ['Block']
|
---|
| 27 | },
|
---|
| 28 | parse: function() {
|
---|
| 29 | var startToken = this.scanner.tokenIndex;
|
---|
| 30 | var startOffset = this.scanner.tokenStart;
|
---|
| 31 | var prelude;
|
---|
| 32 | var block;
|
---|
| 33 |
|
---|
| 34 | if (this.parseRulePrelude) {
|
---|
| 35 | prelude = this.parseWithFallback(consumePrelude, consumeRaw);
|
---|
| 36 | } else {
|
---|
| 37 | prelude = consumeRaw.call(this, startToken);
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | block = this.Block(true);
|
---|
| 41 |
|
---|
| 42 | return {
|
---|
| 43 | type: 'Rule',
|
---|
| 44 | loc: this.getLocation(startOffset, this.scanner.tokenStart),
|
---|
| 45 | prelude: prelude,
|
---|
| 46 | block: block
|
---|
| 47 | };
|
---|
| 48 | },
|
---|
| 49 | generate: function(node) {
|
---|
| 50 | this.node(node.prelude);
|
---|
| 51 | this.node(node.block);
|
---|
| 52 | },
|
---|
| 53 | walkContext: 'rule'
|
---|
| 54 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.