source: trip-planner-front/node_modules/css-tree/lib/syntax/scope/default.js@ 6a3a178

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

initial commit

  • Property mode set to 100644
File size: 2.7 KB
Line 
1var cmpChar = require('../../tokenizer').cmpChar;
2var cmpStr = require('../../tokenizer').cmpStr;
3var TYPE = require('../../tokenizer').TYPE;
4
5var IDENT = TYPE.Ident;
6var STRING = TYPE.String;
7var NUMBER = TYPE.Number;
8var FUNCTION = TYPE.Function;
9var URL = TYPE.Url;
10var HASH = TYPE.Hash;
11var DIMENSION = TYPE.Dimension;
12var PERCENTAGE = TYPE.Percentage;
13var LEFTPARENTHESIS = TYPE.LeftParenthesis;
14var LEFTSQUAREBRACKET = TYPE.LeftSquareBracket;
15var COMMA = TYPE.Comma;
16var DELIM = TYPE.Delim;
17var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
18var ASTERISK = 0x002A; // U+002A ASTERISK (*)
19var PLUSSIGN = 0x002B; // U+002B PLUS SIGN (+)
20var HYPHENMINUS = 0x002D; // U+002D HYPHEN-MINUS (-)
21var SOLIDUS = 0x002F; // U+002F SOLIDUS (/)
22var U = 0x0075; // U+0075 LATIN SMALL LETTER U (u)
23
24module.exports = function defaultRecognizer(context) {
25 switch (this.scanner.tokenType) {
26 case HASH:
27 return this.Hash();
28
29 case COMMA:
30 context.space = null;
31 context.ignoreWSAfter = true;
32 return this.Operator();
33
34 case LEFTPARENTHESIS:
35 return this.Parentheses(this.readSequence, context.recognizer);
36
37 case LEFTSQUAREBRACKET:
38 return this.Brackets(this.readSequence, context.recognizer);
39
40 case STRING:
41 return this.String();
42
43 case DIMENSION:
44 return this.Dimension();
45
46 case PERCENTAGE:
47 return this.Percentage();
48
49 case NUMBER:
50 return this.Number();
51
52 case FUNCTION:
53 return cmpStr(this.scanner.source, this.scanner.tokenStart, this.scanner.tokenEnd, 'url(')
54 ? this.Url()
55 : this.Function(this.readSequence, context.recognizer);
56
57 case URL:
58 return this.Url();
59
60 case IDENT:
61 // check for unicode range, it should start with u+ or U+
62 if (cmpChar(this.scanner.source, this.scanner.tokenStart, U) &&
63 cmpChar(this.scanner.source, this.scanner.tokenStart + 1, PLUSSIGN)) {
64 return this.UnicodeRange();
65 } else {
66 return this.Identifier();
67 }
68
69 case DELIM:
70 var code = this.scanner.source.charCodeAt(this.scanner.tokenStart);
71
72 if (code === SOLIDUS ||
73 code === ASTERISK ||
74 code === PLUSSIGN ||
75 code === HYPHENMINUS) {
76 return this.Operator(); // TODO: replace with Delim
77 }
78
79 // TODO: produce a node with Delim node type
80
81 if (code === NUMBERSIGN) {
82 this.error('Hex or identifier is expected', this.scanner.tokenStart + 1);
83 }
84
85 break;
86 }
87};
Note: See TracBrowser for help on using the repository browser.