csso-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,902 +0,0 @@
1
- function CSSOParser() {}
2
-
3
- CSSOParser.prototype.parse = function(s, rule) {
4
- this._src = s;
5
- this._stack = [];
6
- this._chains = [];
7
- this._i = { f: 0, l: 0 };
8
- var r = this.$()._o(rule)._();
9
- return r ? r[0] : null;
10
- };
11
-
12
- CSSOParser.prototype._push = function(o) {
13
- this._stack.push(o);
14
- };
15
-
16
- CSSOParser.prototype._last = function() {
17
- return this._chains[this._chains.length - 1];
18
- };
19
-
20
- CSSOParser.prototype._fail = function() {
21
- this._last().fail = true;
22
- };
23
-
24
- CSSOParser.prototype._failed = function() {
25
- return this._last().fail;
26
- };
27
-
28
- CSSOParser.prototype._apply = function(s) {
29
- switch (s.charAt(0)) {
30
- case '.': return this._s(s.substr(1));
31
- case ',': return this._r(s.substr(1));
32
- default: return this[s]();
33
- }
34
- };
35
-
36
- CSSOParser.prototype._gi = function() {
37
- return this._last().l;
38
- };
39
-
40
- CSSOParser.prototype._si = function(i) {
41
- if (this._chains.length) this._last().l = i;
42
- };
43
-
44
- CSSOParser.prototype._info = function() {
45
- return { f: this._i.f, l: this._i.l };
46
- };
47
-
48
- CSSOParser.prototype.$ = function() {
49
- var i = this._chains.length ? this._last().l + 1 : 0;
50
- this._chains.push({ i: this._stack.length, fail: false, f: i, l: i - 1 });
51
- return this;
52
- };
53
-
54
- CSSOParser.prototype._ = function() {
55
- var c = this._chains.pop(),
56
- r = this._stack.splice(c.i);
57
- if (!c.fail) {
58
- if (c.l >= c.f) this._si(c.l);
59
- this._i = { f: c.f, l: c.l };
60
- return r.length ? r : null;
61
- }
62
- };
63
-
64
- CSSOParser.prototype._o = function() {
65
- if (!this._failed()) {
66
- var a = arguments, b = [], t;
67
- for (var i = 0; i < a.length; i++) {
68
- if (t = this._apply(a[i])) break;
69
- }
70
- t !== undefined ? this._push(t) : this._fail();
71
- }
72
- return this;
73
- };
74
-
75
- CSSOParser.prototype._om = function() {
76
- if (!this._failed()) {
77
- var a = arguments, t, n0, n1 = this._gi() + 1, b = [];
78
- do {
79
- n0 = n1;
80
- for (var i = 0; i < a.length; i++) {
81
- if (t = this._apply(a[i])) {
82
- b.push(t);
83
- n1 = this._gi() + 1;
84
- break;
85
- }
86
- }
87
- } while (n0 !== n1);
88
- b.length ? this._push(b) : this._fail();
89
- }
90
- return this;
91
- };
92
-
93
- CSSOParser.prototype._zm = function() {
94
- if (!this._failed()) {
95
- var a = arguments, t, n0, n1 = this._gi() + 1, b = [];
96
- do {
97
- n0 = n1;
98
- for (var i = 0; i < a.length; i++) {
99
- if (t = this._apply(a[i])) {
100
- b.push(t);
101
- n1 = this._gi() + 1;
102
- break;
103
- }
104
- }
105
- } while (n0 !== n1);
106
- if (b.length) this._push(b);
107
- }
108
- return this;
109
- };
110
-
111
- CSSOParser.prototype._zmn = function() {
112
- if (!this._failed()) {
113
- var i = this._gi() + 1;
114
- this._zm.apply(this, arguments);
115
- if (i === this._gi() + 1) this._push(null);
116
- }
117
- return this;
118
- };
119
-
120
- CSSOParser.prototype._zme = function() {
121
- if (!this._failed()) {
122
- var i = this._gi() + 1;
123
- this._zm.apply(this, arguments);
124
- if (i === this._gi() + 1) this._push([]);
125
- }
126
- return this;
127
- };
128
-
129
- CSSOParser.prototype._zo = function() {
130
- if (!this._failed()) {
131
- var a = arguments, t;
132
- for (var i = 0; i < a.length; i++) {
133
- if (t = this._apply(a[i])) break;
134
- }
135
- this._push(t ? t : null);
136
- }
137
- return this;
138
- };
139
-
140
- CSSOParser.prototype._not = function() {
141
- if (!this._failed()) {
142
- var f = this._gi() + 1,
143
- s = this._src,
144
- a = arguments,
145
- p = new CSSOParser(),
146
- _s, t, l = s.length + 1;
147
- for (var i = f; i < l; i++) {
148
- _s = s.substr(i);
149
- for (var j = 0; j < a.length; j++) {
150
- if ((t = p.parse(_s, a[j])) !== null) {
151
- _s = s.substring(f, i);
152
- i = l;
153
- break;
154
- }
155
- }
156
- }
157
- if (_s) this._si(f + _s.length - 1);
158
- this._push(_s);
159
- }
160
- return this;
161
- };
162
-
163
- CSSOParser.prototype._s = function(s) {
164
- var sl = s.length,
165
- f = this._gi() + 1;
166
- if (this._src.substr(f, sl) === s) {
167
- this._si(f + sl - 1);
168
- return s;
169
- }
170
- };
171
-
172
- CSSOParser.prototype._c = function() {
173
- var s = this._src,
174
- f = this._gi() + 1;
175
- if (f <= s.length) {
176
- this._si(f);
177
- return s.charAt(f);
178
- }
179
- };
180
-
181
- CSSOParser.prototype._r = function(r) {
182
- var n = r.substr(0, r.indexOf(' ')),
183
- f = this._gi() + 1,
184
- s = n !== '0' ? this._src.substring(f, f + new Number(n)) : this._src.substr(f),
185
- rr = new RegExp(r.substr(n.length + 1)).exec(s);
186
- if (rr && rr.index === 0) {
187
- this._si(f + rr[0].length - 1);
188
- return rr[0];
189
- }
190
- };
191
-
192
- CSSOParser.prototype._join = function(a) {
193
- return a ? a.join('') : '';
194
- };
195
-
196
- CSSOParser.prototype._cc = function(x, y) {
197
- y.forEach(function(e) {
198
- x = x.concat(e);
199
- });
200
-
201
- return x;
202
- };
203
- CSSOParser.prototype.unknown = function() {
204
- var _b_;
205
- if (_b_ = this.$()._o('munknown')._()) {
206
- return [this._info(), 'unknown', _b_[0]];
207
- }
208
- };
209
- CSSOParser.prototype.mstring1 = function() {
210
- var _b_;
211
- if (_b_ = this.$()._not('."','.\\"')._()) {
212
- return _b_[0];
213
- }
214
- };
215
- CSSOParser.prototype.mstring2 = function() {
216
- var _b_;
217
- if (_b_ = this.$()._not('.\'','.\\\'')._()) {
218
- return _b_[0];
219
- }
220
- };
221
- CSSOParser.prototype.mstring = function() {
222
- var _b_;
223
- if (_b_ = this.$()._o('."')._zme('.\\"','mstring1')._o('."')._()) {
224
- return ('"' + _b_[1].join('') + '"');
225
- }
226
- if (_b_ = this.$()._o('.\'')._zme('.\\\'','mstring2')._o('.\'')._()) {
227
- return ("'" + _b_[1].join('') + "'");
228
- }
229
- };
230
- CSSOParser.prototype.string = function() {
231
- var _b_;
232
- if (_b_ = this.$()._o('mstring')._()) {
233
- return [this._info(), 'string', _b_[0]];
234
- }
235
- };
236
- CSSOParser.prototype.escape = function() {
237
- var _b_;
238
- if (_b_ = this.$()._o('.\\')._o('_c')._()) {
239
- return ('\\' + _b_[1]);
240
- }
241
- };
242
- CSSOParser.prototype.ident = function() {
243
- var _b_;
244
- if (_b_ = this.$()._o('mident')._()) {
245
- return [this._info(), 'ident', _b_[0]];
246
- }
247
- };
248
- CSSOParser.prototype.atkeyword = function() {
249
- var _b_;
250
- if (_b_ = this.$()._o('.@')._o('ident')._()) {
251
- return [this._info(), 'atkeyword', _b_[1]];
252
- }
253
- };
254
- CSSOParser.prototype.shash = function() {
255
- var _b_;
256
- if (_b_ = this.$()._o('.#')._o('mname')._()) {
257
- return [this._info(), 'shash', _b_[1]];
258
- }
259
- };
260
- CSSOParser.prototype.vhash = function() {
261
- var _b_;
262
- if (_b_ = this.$()._o('.#')._o('mname2')._()) {
263
- return [this._info(), 'vhash', _b_[1]];
264
- }
265
- };
266
- CSSOParser.prototype.number = function() {
267
- var _b_;
268
- if (_b_ = this.$()._o('mnumber')._()) {
269
- return [this._info(), 'number', _b_[0]];
270
- }
271
- };
272
- CSSOParser.prototype.percentage = function() {
273
- var _b_;
274
- if (_b_ = this.$()._o('number')._o('.%')._()) {
275
- return [this._info(), 'percentage', _b_[0]];
276
- }
277
- };
278
- CSSOParser.prototype.ident2 = function() {
279
- var _b_;
280
- if (_b_ = this.$()._o('mname2')._()) {
281
- return [this._info(), 'ident', _b_[0]];
282
- }
283
- };
284
- CSSOParser.prototype.dimension = function() {
285
- var _b_;
286
- if (_b_ = this.$()._o('number')._o('ident2')._()) {
287
- return [this._info(), 'dimension', _b_[0], _b_[1]];
288
- }
289
- };
290
- CSSOParser.prototype.cdo = function() {
291
- var _b_;
292
- if (_b_ = this.$()._o('.<!--')._()) {
293
- return [this._info(), 'cdo'];
294
- }
295
- };
296
- CSSOParser.prototype.cdc = function() {
297
- var _b_;
298
- if (_b_ = this.$()._o('.-->')._()) {
299
- return [this._info(), 'cdc'];
300
- }
301
- };
302
- CSSOParser.prototype.s = function() {
303
- var _b_;
304
- if (_b_ = this.$()._om('mw')._()) {
305
- return [this._info(), 's', _b_[0].join('')];
306
- }
307
- };
308
- CSSOParser.prototype.attrselector = function() {
309
- var _b_;
310
- if (_b_ = this.$()._o('.=','.~=','.^=','.$=','.*=','.|=','.~')._()) {
311
- return [this._info(), 'attrselector', _b_[0]];
312
- }
313
- };
314
- CSSOParser.prototype.delim = function() {
315
- var _b_;
316
- if (_b_ = this.$()._o('.,')._()) {
317
- return [this._info(), 'delim'];
318
- }
319
- };
320
- CSSOParser.prototype.comment = function() {
321
- var _b_;
322
- if (_b_ = this.$()._o('mcomment1')._()) {
323
- return [this._info(), 'comment', _b_[0]];
324
- }
325
- };
326
- CSSOParser.prototype.sc = function() {
327
- var _b_;
328
- if (_b_ = this.$()._o('s','comment')._()) {
329
- return _b_[0];
330
- }
331
- };
332
- CSSOParser.prototype.tset = function() {
333
- var _b_;
334
- if (_b_ = this.$()._o('vhash','any','sc','operator')._()) {
335
- return _b_[0];
336
- }
337
- };
338
- CSSOParser.prototype.stylesheet = function() {
339
- var _b_;
340
- if (_b_ = this.$()._zme('cdo','cdc','sc','statement','unknown')._()) {
341
- return [this._info(), 'stylesheet'].concat(_b_[0]);
342
- }
343
- };
344
- CSSOParser.prototype.statement = function() {
345
- var _b_;
346
- if (_b_ = this.$()._o('ruleset','atrule')._()) {
347
- return _b_[0];
348
- }
349
- };
350
- CSSOParser.prototype.atruleb = function() {
351
- var _b_;
352
- if (_b_ = this.$()._o('atkeyword')._zme('tset')._o('block')._()) {
353
- return [this._info(), 'atruleb', _b_[0]].concat(_b_[1], [_b_[2]]);
354
- }
355
- };
356
- CSSOParser.prototype.atrules = function() {
357
- var _b_;
358
- if (_b_ = this.$()._o('atkeyword')._zme('tset')._o('.;')._()) {
359
- return [this._info(), 'atrules', _b_[0]].concat(_b_[1]);
360
- }
361
- };
362
- CSSOParser.prototype.atrulerq = function() {
363
- var _b_;
364
- if (_b_ = this.$()._zme('tset')._()) {
365
- return [this._info(), 'atrulerq'].concat(_b_[0]);
366
- }
367
- };
368
- CSSOParser.prototype.atrulers = function() {
369
- var _b_;
370
- if (_b_ = this.$()._zme('sc')._zme('ruleset')._zme('sc')._()) {
371
- return [this._info(), 'atrulers'].concat(_b_[0], _b_[1], _b_[2]);
372
- }
373
- };
374
- CSSOParser.prototype.atruler = function() {
375
- var _b_;
376
- if (_b_ = this.$()._o('atkeyword')._o('atrulerq')._o('.{')._o('atrulers')._o('.}')._()) {
377
- return [this._info(), 'atruler', _b_[0], _b_[1], _b_[3]];
378
- }
379
- };
380
- CSSOParser.prototype.atrule = function() {
381
- var _b_;
382
- if (_b_ = this.$()._o('atruler','atruleb','atrules')._()) {
383
- return _b_[0];
384
- }
385
- };
386
- CSSOParser.prototype.blockdecl = function() {
387
- var _b_;
388
- if (_b_ = this.$()._zme('sc')._o('filter','declaration')._o('decldelim')._zme('sc')._()) {
389
- return [].concat(_b_[0], [_b_[1]], [_b_[2]], _b_[3]);
390
- }
391
- if (_b_ = this.$()._zme('sc')._o('filter','declaration')._zme('sc')._()) {
392
- return [].concat(_b_[0], [_b_[1]], _b_[2]);
393
- }
394
- if (_b_ = this.$()._zme('sc')._o('decldelim')._zme('sc')._()) {
395
- return [].concat(_b_[0], [_b_[1]], _b_[2]);
396
- }
397
- if (_b_ = this.$()._om('sc')._()) {
398
- return _b_[0];
399
- }
400
- };
401
- CSSOParser.prototype.decldelim = function() {
402
- var _b_;
403
- if (_b_ = this.$()._o('.;')._()) {
404
- return [this._info(), 'decldelim'];
405
- }
406
- };
407
- CSSOParser.prototype.block = function() {
408
- var _b_;
409
- if (_b_ = this.$()._o('.{')._zme('blockdecl')._o('.}')._()) {
410
- return this._cc([this._info(), 'block'], _b_[1]);
411
- }
412
- };
413
- CSSOParser.prototype.ruleset = function() {
414
- var _b_;
415
- if (_b_ = this.$()._zme('selector')._o('block')._()) {
416
- return [this._info(), 'ruleset'].concat(_b_[0], [_b_[1]]);
417
- }
418
- };
419
- CSSOParser.prototype.combinator = function() {
420
- var _b_;
421
- if (_b_ = this.$()._o('.+','.>','.~')._()) {
422
- return [this._info(), 'combinator', _b_[0]];
423
- }
424
- };
425
- CSSOParser.prototype.attrib = function() {
426
- var _b_;
427
- if (_b_ = this.$()._o('.[')._zme('sc')._o('ident')._zme('sc')._o('attrselector')._zme('sc')._o('ident','string')._zme('sc')._o('.]')._()) {
428
- return [this._info(), 'attrib'].concat(_b_[1], [_b_[2]], _b_[3], [_b_[4]], _b_[5], [_b_[6]], _b_[7]);
429
- }
430
- if (_b_ = this.$()._o('.[')._zme('sc')._o('ident')._zme('sc')._o('.]')._()) {
431
- return [this._info(), 'attrib'].concat(_b_[1], [_b_[2]], _b_[3]);
432
- }
433
- };
434
- CSSOParser.prototype.clazz = function() {
435
- var _b_;
436
- if (_b_ = this.$()._o('..')._o('ident')._()) {
437
- return [this._info(), 'clazz', _b_[1]];
438
- }
439
- };
440
- CSSOParser.prototype.pseudoe = function() {
441
- var _b_;
442
- if (_b_ = this.$()._o('.::')._o('ident')._()) {
443
- return [this._info(), 'pseudoe', _b_[1]];
444
- }
445
- };
446
- CSSOParser.prototype.pseudoc = function() {
447
- var _b_;
448
- if (_b_ = this.$()._o('.:')._o('funktion','ident')._()) {
449
- return [this._info(), 'pseudoc', _b_[1]];
450
- }
451
- };
452
- CSSOParser.prototype.pseudo = function() {
453
- var _b_;
454
- if (_b_ = this.$()._o('pseudoe','pseudoc')._()) {
455
- return _b_[0];
456
- }
457
- };
458
- CSSOParser.prototype.nthf = function() {
459
- var _b_;
460
- if (_b_ = this.$()._o('.:')._o('.nth-')._o('.child','.last-child','.of-type','.last-of-type')._()) {
461
- return [this._info(), 'ident', _b_[1] + _b_[2]];
462
- }
463
- };
464
- CSSOParser.prototype.nth = function() {
465
- var _b_;
466
- if (_b_ = this.$()._om(',1 ^[\\d]','.n')._()) {
467
- return [this._info(), 'nth', _b_[0].join('')];
468
- }
469
- if (_b_ = this.$()._o('.even','.odd')._()) {
470
- return [this._info(), 'nth', _b_[0]];
471
- }
472
- };
473
- CSSOParser.prototype.nthselector = function() {
474
- var _b_;
475
- if (_b_ = this.$()._o('nthf')._o('.(')._zme('sc','unary','nth')._o('.)')._()) {
476
- return [this._info(), 'nthselector', _b_[0]].concat(_b_[2]);
477
- }
478
- };
479
- CSSOParser.prototype.namespace = function() {
480
- var _b_;
481
- if (_b_ = this.$()._o('.|')._()) {
482
- return [this._info(), 'namespace'];
483
- }
484
- };
485
- CSSOParser.prototype.simpleselector = function() {
486
- var _b_;
487
- if (_b_ = this.$()._om('nthselector','combinator','attrib','pseudo','clazz','shash','any','sc','namespace')._()) {
488
- return this._cc([this._info(), 'simpleselector'], [_b_[0]]);
489
- }
490
- };
491
- CSSOParser.prototype.selector = function() {
492
- var _b_;
493
- if (_b_ = this.$()._om('simpleselector','delim')._()) {
494
- return [this._info(), 'selector'].concat(_b_[0]);
495
- }
496
- };
497
- CSSOParser.prototype.declaration = function() {
498
- var _b_;
499
- if (_b_ = this.$()._o('property')._o('.:')._o('value')._()) {
500
- return [this._info(), 'declaration', _b_[0], _b_[2]];
501
- }
502
- };
503
- CSSOParser.prototype.filtern = function() {
504
- var _b_;
505
- if (_b_ = this.$()._o('.-filter','.$filter','._filter','.*filter','.-ms-filter','.filter')._()) {
506
- return [this._info(), 'ident', _b_[0]];
507
- }
508
- };
509
- CSSOParser.prototype.filterp = function() {
510
- var _b_;
511
- if (_b_ = this.$()._o('filtern')._zme('sc')._()) {
512
- return [this._info(), 'property', _b_[0]].concat(_b_[1]);
513
- }
514
- };
515
- CSSOParser.prototype.progid0 = function() {
516
- var _b_;
517
- if (_b_ = this.$()._not('.)','mstring','mcomment2')._()) {
518
- return _b_[0];
519
- }
520
- };
521
- CSSOParser.prototype.progid1 = function() {
522
- var _b_;
523
- if (_b_ = this.$()._o('.progid:DXImageTransform.Microsoft.')._o(',25 ^[a-zA-Z]+')._o('.(')._om('mstring','mcomment2','progid0')._o('.)')._()) {
524
- return [this._info(), 'raw', _b_[0] + _b_[1] + '(' + _b_[3].join('') + ')'];
525
- }
526
- };
527
- CSSOParser.prototype.progid = function() {
528
- var _b_;
529
- if (_b_ = this.$()._zme('sc')._o('progid1')._zme('sc')._()) {
530
- return [this._info(), 'progid'].concat(_b_[0], [_b_[1]], _b_[2]);
531
- }
532
- };
533
- CSSOParser.prototype.filterv = function() {
534
- var _b_;
535
- if (_b_ = this.$()._om('progid')._()) {
536
- return [this._info(), 'filterv'].concat(_b_[0]);
537
- }
538
- };
539
- CSSOParser.prototype.filter = function() {
540
- var _b_;
541
- if (_b_ = this.$()._o('filterp')._o('.:')._o('filterv')._()) {
542
- return [this._info(), 'filter', _b_[0], _b_[2]];
543
- }
544
- };
545
- CSSOParser.prototype.identp = function() {
546
- var _b_;
547
- if (_b_ = this.$()._o('.//')._o('mident')._()) {
548
- return [this._info(), 'ident', _b_[0] + _b_[1]];
549
- }
550
- };
551
- CSSOParser.prototype.property = function() {
552
- var _b_;
553
- if (_b_ = this.$()._o('identp')._zme('sc')._()) {
554
- return [this._info(), 'property', _b_[0]].concat(_b_[1]);
555
- }
556
- if (_b_ = this.$()._o('ident')._zme('sc')._()) {
557
- return [this._info(), 'property', _b_[0]].concat(_b_[1]);
558
- }
559
- };
560
- CSSOParser.prototype.important = function() {
561
- var _b_;
562
- if (_b_ = this.$()._o('.!')._zme('sc')._o('.important')._()) {
563
- return [this._info(), 'important'].concat(_b_[1]);
564
- }
565
- };
566
- CSSOParser.prototype.unary = function() {
567
- var _b_;
568
- if (_b_ = this.$()._o('.-','.+')._()) {
569
- return [this._info(), 'unary', _b_[0]];
570
- }
571
- };
572
- CSSOParser.prototype.operator = function() {
573
- var _b_;
574
- if (_b_ = this.$()._o('./','.,','.:','.=')._()) {
575
- return [this._info(), 'operator', _b_[0]];
576
- }
577
- };
578
- CSSOParser.prototype.uri0 = function() {
579
- var _b_;
580
- if (_b_ = this.$()._not('.)','mw')._()) {
581
- return [this._info(), 'raw', _b_[0]];
582
- }
583
- };
584
- CSSOParser.prototype.uri = function() {
585
- var _b_;
586
- if (_b_ = this.$()._o('.url(')._zme('sc')._o('string')._zme('sc')._o('.)')._()) {
587
- return [this._info(), 'uri'].concat(_b_[1], [_b_[2]], _b_[3]);
588
- }
589
- if (_b_ = this.$()._o('.url(')._zme('sc')._o('uri0')._zme('sc')._o('.)')._()) {
590
- return [this._info(), 'uri'].concat(_b_[1], [_b_[2]], _b_[3]);
591
- }
592
- };
593
- CSSOParser.prototype.value = function() {
594
- var _b_;
595
- if (_b_ = this.$()._om('sc','vhash','any','block','atkeyword','operator','important')._()) {
596
- return [this._info(), 'value'].concat(_b_[0]);
597
- }
598
- };
599
- CSSOParser.prototype.functionBody = function() {
600
- var _b_;
601
- if (_b_ = this.$()._zme('tset')._()) {
602
- return [this._info(), 'functionBody'].concat(_b_[0]);
603
- }
604
- };
605
- CSSOParser.prototype.funktion = function() {
606
- var _b_;
607
- if (_b_ = this.$()._o('notselector')._()) {
608
- return _b_[0];
609
- }
610
- if (_b_ = this.$()._o('ident')._o('.(')._o('functionBody')._o('.)')._()) {
611
- return [this._info(), 'funktion', _b_[0], _b_[2]];
612
- }
613
- };
614
- CSSOParser.prototype.notselectorident = function() {
615
- var _b_;
616
- if (_b_ = this.$()._o('.not')._()) {
617
- return [this._info(), 'ident', _b_[0]];
618
- }
619
- };
620
- CSSOParser.prototype.notselector = function() {
621
- var _b_;
622
- if (_b_ = this.$()._o('notselectorident')._o('.(')._o('notselectorBody')._o('.)')._()) {
623
- return [this._info(), 'funktion', _b_[0], _b_[2]];
624
- }
625
- };
626
- CSSOParser.prototype.notselectorBody = function() {
627
- var _b_;
628
- if (_b_ = this.$()._zo('simpleselector')._()) {
629
- return [this._info(), 'functionBody', _b_[0]];
630
- }
631
- };
632
- CSSOParser.prototype.braces = function() {
633
- var _b_;
634
- if (_b_ = this.$()._o('.(')._zme('tset')._o('.)')._()) {
635
- return [this._info(), 'braces', '(', ')'].concat(_b_[1]);
636
- }
637
- if (_b_ = this.$()._o('.[')._zme('tset')._o('.]')._()) {
638
- return [this._info(), 'braces', '[', ']'].concat(_b_[1]);
639
- }
640
- };
641
- CSSOParser.prototype.jsLT = function() {
642
- var _b_;
643
- if (_b_ = this.$()._o('.\n','.\r')._()) {
644
- return _b_[0];
645
- }
646
- };
647
- CSSOParser.prototype.jsComment = function() {
648
- var _b_;
649
- if (_b_ = this.$()._o('jsMLComment','jsSLComment')._()) {
650
- return _b_[0];
651
- }
652
- };
653
- CSSOParser.prototype.jsMLComment = function() {
654
- var _b_;
655
- if (_b_ = this.$()._o('./*')._not('.*/')._o('.*/')._()) {
656
- return (_b_[0] + (_b_[1] ? _b_[1] : '') + _b_[2]);
657
- }
658
- };
659
- CSSOParser.prototype.jsSLComment = function() {
660
- var _b_;
661
- if (_b_ = this.$()._o('.//')._not('jsLT')._()) {
662
- return ('//' + (_b_[1] ? _b_[1] : ''));
663
- }
664
- };
665
- CSSOParser.prototype.jsString = function() {
666
- var _b_;
667
- if (_b_ = this.$()._o('."')._zme('jsDSChar')._o('."')._()) {
668
- return ('"' + _b_[1].join('') + '"');
669
- }
670
- if (_b_ = this.$()._o('.\'')._zme('jsSSChar')._o('.\'')._()) {
671
- return ('\'' + _b_[1].join('') + '\'');
672
- }
673
- };
674
- CSSOParser.prototype.jsDSChar = function() {
675
- var _b_;
676
- if (_b_ = this.$()._not('."','.\\','jsLT','jsEscapeChar','jsLineContinuation')._()) {
677
- return _b_[0];
678
- }
679
- if (_b_ = this.$()._o('jsEscapeChar')._()) {
680
- return _b_[0];
681
- }
682
- if (_b_ = this.$()._o('jsLineContinuation')._()) {
683
- return _b_[0];
684
- }
685
- };
686
- CSSOParser.prototype.jsSSChar = function() {
687
- var _b_;
688
- if (_b_ = this.$()._not('.\'','.\\','jsLT','jsEscapeChar','jsLineContinuation')._()) {
689
- return _b_[0];
690
- }
691
- if (_b_ = this.$()._o('jsEscapeChar')._()) {
692
- return _b_[0];
693
- }
694
- if (_b_ = this.$()._o('jsLineContinuation')._()) {
695
- return _b_[0];
696
- }
697
- };
698
- CSSOParser.prototype.jsLineContinuation = function() {
699
- var _b_;
700
- if (_b_ = this.$()._o('.\\')._zme('jsLT')._()) {
701
- return ('\\' + _b_[1].join(''));
702
- }
703
- };
704
- CSSOParser.prototype.jsEscapeChar = function() {
705
- var _b_;
706
- if (_b_ = this.$()._o('.\\')._o('_c')._()) {
707
- return ('\\' + _b_[1]);
708
- }
709
- };
710
- CSSOParser.prototype.jsInBraceChar = function() {
711
- var _b_;
712
- if (_b_ = this.$()._not('.(','.)','jsComment','jsString','jsEscapeChar')._()) {
713
- return _b_[0];
714
- }
715
- };
716
- CSSOParser.prototype.jsBracesContent = function() {
717
- var _b_;
718
- if (_b_ = this.$()._om('jsComment','jsString','jsEscapeChar','jsInBraceChar')._()) {
719
- return _b_[0].join('');
720
- }
721
- };
722
- CSSOParser.prototype.feb = function() {
723
- var _b_;
724
- if (_b_ = this.$()._o('functionExpressionBody')._zme('jsBracesContent')._()) {
725
- return (_b_[0] + _b_[1].join(''));
726
- }
727
- };
728
- CSSOParser.prototype.functionExpressionBody = function() {
729
- var _b_;
730
- if (_b_ = this.$()._o('.(')._om('jsBracesContent')._zme('feb')._o('.)')._()) {
731
- return ('(' + _b_[1].join('') + _b_[2].join('') + ')');
732
- }
733
- if (_b_ = this.$()._o('.(')._zme('feb')._o('.)')._()) {
734
- return ('(' + _b_[1].join('') + ')');
735
- }
736
- if (_b_ = this.$()._om('jsBracesContent')._zme('feb')._()) {
737
- return (_b_[0].join('') + _b_[1].join(''));
738
- }
739
- };
740
- CSSOParser.prototype.functionExpression = function() {
741
- var _b_;
742
- if (_b_ = this.$()._o('.expression(')._zme('functionExpressionBody')._o('.)')._()) {
743
- return [this._info(), 'functionExpression', _b_[1].join('')];
744
- }
745
- };
746
- CSSOParser.prototype.any = function() {
747
- var _b_;
748
- if (_b_ = this.$()._o('braces','string','percentage','dimension','number','uri','functionExpression','funktion','ident','unary')._()) {
749
- return _b_[0];
750
- }
751
- };
752
- CSSOParser.prototype.mw = function() {
753
- var s = this._src,
754
- sl = s.length,
755
- f = this._gi() + 1, c, i, v = '';
756
- for (i = f; i < sl; i++) {
757
- c = s.charAt(i);
758
- if (/^[ \n\r\t\f]$/.test(c)) v += c;
759
- else break;
760
- }
761
- if (v.length) {
762
- this._si(f + v.length - 1);
763
- return v;
764
- }
765
- };
766
-
767
- CSSOParser.prototype.mnumber = function() {
768
- var s = this._src,
769
- sl = s.length,
770
- f = this._gi() + 1, c, i, v = '',
771
- n0 = '', d = '', n1 = '';
772
- for (i = f; i < sl; i++) {
773
- c = s.charAt(i);
774
- if (/^[\d]$/.test(c)) n0 += c;
775
- else break;
776
- }
777
- if (s[i++] === '.') {
778
- d = '.';
779
- for (; i < sl; i++) {
780
- c = s.charAt(i);
781
- if (/^[\d]$/.test(c)) n1 += c;
782
- else break;
783
- }
784
- }
785
- if ((v = n0 + d + n1).length) {
786
- this._si(f + v.length - 1);
787
- return v;
788
- }
789
- };
790
-
791
- CSSOParser.prototype.mident = function() {
792
- var s = this._src,
793
- sl = s.length,
794
- f = this._gi() + 1, i = f, v = '', c, n;
795
- if (s.charAt(i) === '-') v = '-', i++; // special case
796
- c = s.charAt(i); n = s.charAt(i + 1);
797
- if (/^[_$a-zA-Z*]$/.test(c)) v += c; // first char
798
- else if (c === '\\') {
799
- v += c;
800
- if (n) v += n, i++;
801
- } else return;
802
- i++;
803
- for (; i < sl; i++) {
804
- c = s.charAt(i);
805
- n = s.charAt(i + 1);
806
- if (/^[_a-zA-Z0-9\-]$/.test(c)) v += c;
807
- else if (c === '\\') {
808
- v += c;
809
- if (n) v += n, i++;
810
- } else break;
811
- }
812
- if (v && v !== '-') {
813
- this._si(f + v.length - 1);
814
- return v;
815
- }
816
- };
817
-
818
- CSSOParser.prototype.mcomment1 = function() {
819
- var s = this._src,
820
- f = this._gi() + 1, v = '', i;
821
- if (s.charAt(f) === '/' && s.charAt(f + 1) === '*') {
822
- if ((i = s.indexOf('*/', f + 2)) !== -1) {
823
- v = s.substring(f + 2, i);
824
- this._si(f + v.length + 3);
825
- } else {
826
- v = s.substr(f + 2);
827
- this._si(f + v.length + 1);
828
- }
829
- return v;
830
- }
831
- };
832
-
833
- CSSOParser.prototype.mcomment2 = function() {
834
- var s = this._src,
835
- f = this._gi() + 1, v = '/*', i;
836
- if (s.charAt(f) === '/' && s.charAt(f + 1) === '*') {
837
- if ((i = s.indexOf('*/', f + 2)) !== -1) {
838
- v += s.substring(f + 2, i) + '*/';
839
- this._si(f + v.length - 1);
840
- } else {
841
- v += s.substr(f + 2);
842
- this._si(f + v.length - 1);
843
- }
844
- return v;
845
- }
846
- };
847
-
848
- CSSOParser.prototype.mname = function() {
849
- var s = this._src,
850
- sl = s.length,
851
- f = this._gi() + 1, i = f, v = '', c, n;
852
- for (; i < sl; i++) {
853
- c = s.charAt(i);
854
- n = s.charAt(i + 1);
855
- if (/^[_a-zA-Z0-9\-]$/.test(c)) v += c;
856
- else if (c === '\\') {
857
- v += c;
858
- if (n) v += n, i++;
859
- } else break;
860
- }
861
- if (v) {
862
- this._si(f + v.length - 1);
863
- return v;
864
- }
865
- };
866
-
867
- CSSOParser.prototype.mname2 = function() {
868
- var s = this._src,
869
- sl = s.length,
870
- f = this._gi() + 1, i = f, v = '', c, n;
871
- for (; i < sl; i++) {
872
- c = s.charAt(i);
873
- n = s.charAt(i + 1);
874
- if (/^[_a-zA-Z0-9]$/.test(c)) v += c;
875
- else if (c === '\\') {
876
- v += c;
877
- if (n) v += n, i++;
878
- } else break;
879
- }
880
- if (v) {
881
- this._si(f + v.length - 1);
882
- return v;
883
- }
884
- };
885
-
886
- CSSOParser.prototype.munknown = function() {
887
- var s = this._src,
888
- sl = s.length,
889
- f = this._gi() + 1, i = f, v = '', c, n;
890
- for (; i < sl; i++) {
891
- c = s.charAt(i);
892
- v += c;
893
- if (c === '\n' || c === '\r') break;
894
- }
895
- if (v) {
896
- this._si(f + v.length - 1);
897
- return v;
898
- }
899
- };
900
- exports.parse = function(s, rule) {
901
- return new CSSOParser().parse(s, rule);
902
- };