1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
| var TYPE = require('../../tokenizer').TYPE;
|
| var STRING = TYPE.String;
| var URL = TYPE.Url;
| var RAW = TYPE.Raw;
| var RIGHTPARENTHESIS = TYPE.RightParenthesis;
|
| // url '(' S* (string | raw) S* ')'
| module.exports = {
| name: 'Url',
| structure: {
| value: ['String', 'Raw']
| },
| parse: function() {
| var start = this.scanner.tokenStart;
| var value;
|
| this.scanner.eat(URL);
| this.scanner.skipSC();
|
| switch (this.scanner.tokenType) {
| case STRING:
| value = this.String();
| break;
|
| case RAW:
| value = this.Raw(this.scanner.currentToken, 0, RAW, true, false);
| break;
|
| default:
| this.scanner.error('String or Raw is expected');
| }
|
| this.scanner.skipSC();
| this.scanner.eat(RIGHTPARENTHESIS);
|
| return {
| type: 'Url',
| loc: this.getLocation(start, this.scanner.tokenStart),
| value: value
| };
| },
| generate: function(node) {
| this.chunk('url');
| this.chunk('(');
| this.node(node.value);
| this.chunk(')');
| }
| };
|
|