MCPcopy
hub / github.com/less/less.js / Parser

Function Parser

packages/less/lib/less/parser/parser.js:46–2699  ·  view source on GitHub ↗
(context, imports, fileInfo, currentIndex)

Source from the content-addressed store, hash-verified

44//
45
46const Parser = function Parser(context, imports, fileInfo, currentIndex) {
47 currentIndex = currentIndex || 0;
48 let parsers;
49 const parserInput = getParserInput();
50
51 function error(msg, type) {
52 throw new LessError(
53 {
54 index: parserInput.i,
55 filename: fileInfo.filename,
56 type: type || 'Syntax',
57 message: msg
58 },
59 imports
60 );
61 }
62
63 const deprecationHandler = new DeprecationHandler();
64
65 /**
66 * @param {string} msg
67 * @param {number} index
68 * @param {string} type
69 * @param {string} [deprecationId] - stable deprecation ID for repetition limiting
70 */
71 function warn(msg, index, type, deprecationId) {
72 if (context.quiet) { return; }
73 if (deprecationId && context.quietDeprecations) { return; }
74 if (deprecationId && !deprecationHandler.shouldWarn(deprecationId)) { return; }
75
76 logger.warn(
77 (new LessError(
78 {
79 index: index ?? parserInput.i,
80 filename: fileInfo.filename,
81 type: type ? `${type.toUpperCase()} WARNING` : 'WARNING',
82 message: msg
83 },
84 imports
85 )).toString()
86 );
87 }
88
89 function expect(arg, msg) {
90 // some older browsers return typeof 'function' for RegExp
91 const result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
92 if (result) {
93 return result;
94 }
95
96 error(msg || (typeof arg === 'string'
97 ? `expected '${arg}' got '${parserInput.currentChar()}'`
98 : 'unexpected token'));
99 }
100
101 // Specialization of expect()
102 function expectChar(arg, msg) {
103 if (parserInput.$char(arg)) {

Callers

nothing calls this directly

Calls 15

fFunction · 0.85
expectCharFunction · 0.85
expectFunction · 0.85
getDebugInfoFunction · 0.85
testCurrentCharFunction · 0.85
cssKeywordFunction · 0.85
orFunction · 0.85
insideConditionFunction · 0.85
andFunction · 0.85
matchFunction · 0.85
getPreProcessorsMethod · 0.80

Tested by

no test coverage detected