MCPcopy
hub / github.com/perkeep/perkeep / Parser

Function Parser

clients/web/embed/less/less.js:3110–4906  ·  view source on GitHub ↗
(context, imports, fileInfo)

Source from the content-addressed store, hash-verified

3108//`
3109//
3110var Parser = function Parser(context, imports, fileInfo) {
3111 var parsers,
3112 parserInput = getParserInput();
3113
3114 function error(msg, type) {
3115 throw new LessError(
3116 {
3117 index: parserInput.i,
3118 filename: fileInfo.filename,
3119 type: type || 'Syntax',
3120 message: msg
3121 },
3122 imports
3123 );
3124 }
3125
3126 function expect(arg, msg, index) {
3127 // some older browsers return typeof 'function' for RegExp
3128 var result = (arg instanceof Function) ? arg.call(parsers) : parserInput.$re(arg);
3129 if (result) {
3130 return result;
3131 }
3132 error(msg || (typeof arg === 'string' ? "expected '" + arg + "' got '" + parserInput.currentChar() + "'"
3133 : "unexpected token"));
3134 }
3135
3136 // Specialization of expect()
3137 function expectChar(arg, msg) {
3138 if (parserInput.$char(arg)) {
3139 return arg;
3140 }
3141 error(msg || "expected '" + arg + "' got '" + parserInput.currentChar() + "'");
3142 }
3143
3144 function getDebugInfo(index) {
3145 var filename = fileInfo.filename;
3146
3147 return {
3148 lineNumber: utils.getLocation(index, parserInput.getInput()).line + 1,
3149 fileName: filename
3150 };
3151 }
3152
3153 //
3154 // The Parser
3155 //
3156 return {
3157
3158 //
3159 // Parse an input string into an abstract syntax tree,
3160 // @param str A string containing 'less' markup
3161 // @param callback call `callback` when done.
3162 // @param [additionalData] An optional map which can contains vars - a map (key, value) of variables to apply
3163 //
3164 parse: function (str, callback, additionalData) {
3165 var root, error = null, globalVars, modifyVars, ignored, preText = "";
3166
3167 globalVars = (additionalData && additionalData.globalVars) ? Parser.serializeVars(additionalData.globalVars) + '\n' : '';

Callers

nothing calls this directly

Calls 15

finishFunction · 0.85
expectCharFunction · 0.85
errorFunction · 0.85
expectFunction · 0.85
getDebugInfoFunction · 0.85
orFunction · 0.85
insideConditionFunction · 0.85
andFunction · 0.85
matchFunction · 0.85
startMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected