source: trip-planner-front/node_modules/css-tree/lib/syntax/create.js@ 76712b2

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

initial commit

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[6a3a178]1var List = require('../common/List');
2var SyntaxError = require('../common/SyntaxError');
3var TokenStream = require('../common/TokenStream');
4var Lexer = require('../lexer/Lexer');
5var definitionSyntax = require('../definition-syntax');
6var tokenize = require('../tokenizer');
7var createParser = require('../parser/create');
8var createGenerator = require('../generator/create');
9var createConvertor = require('../convertor/create');
10var createWalker = require('../walker/create');
11var clone = require('../utils/clone');
12var names = require('../utils/names');
13var mix = require('./config/mix');
14
15function createSyntax(config) {
16 var parse = createParser(config);
17 var walk = createWalker(config);
18 var generate = createGenerator(config);
19 var convert = createConvertor(walk);
20
21 var syntax = {
22 List: List,
23 SyntaxError: SyntaxError,
24 TokenStream: TokenStream,
25 Lexer: Lexer,
26
27 vendorPrefix: names.vendorPrefix,
28 keyword: names.keyword,
29 property: names.property,
30 isCustomProperty: names.isCustomProperty,
31
32 definitionSyntax: definitionSyntax,
33 lexer: null,
34 createLexer: function(config) {
35 return new Lexer(config, syntax, syntax.lexer.structure);
36 },
37
38 tokenize: tokenize,
39 parse: parse,
40 walk: walk,
41 generate: generate,
42
43 find: walk.find,
44 findLast: walk.findLast,
45 findAll: walk.findAll,
46
47 clone: clone,
48 fromPlainObject: convert.fromPlainObject,
49 toPlainObject: convert.toPlainObject,
50
51 createSyntax: function(config) {
52 return createSyntax(mix({}, config));
53 },
54 fork: function(extension) {
55 var base = mix({}, config); // copy of config
56 return createSyntax(
57 typeof extension === 'function'
58 ? extension(base, Object.assign)
59 : mix(base, extension)
60 );
61 }
62 };
63
64 syntax.lexer = new Lexer({
65 generic: true,
66 types: config.types,
67 atrules: config.atrules,
68 properties: config.properties,
69 node: config.node
70 }, syntax);
71
72 return syntax;
73};
74
75exports.create = function(config) {
76 return createSyntax(mix({}, config));
77};
Note: See TracBrowser for help on using the repository browser.