MCPcopy Index your code
hub / github.com/RubyLouvre/anu / parseQuantifier

Function parseQuantifier

test/babel.js:58262–58309  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58260 }
58261
58262 function parseQuantifier() {
58263 // Quantifier ::
58264 // QuantifierPrefix
58265 // QuantifierPrefix ?
58266 //
58267 // QuantifierPrefix ::
58268 // *
58269 // +
58270 // ?
58271 // { DecimalDigits }
58272 // { DecimalDigits , }
58273 // { DecimalDigits , DecimalDigits }
58274
58275 var res,
58276 from = pos;
58277 var quantifier;
58278 var min, max;
58279
58280 if (match('*')) {
58281 quantifier = createQuantifier(0);
58282 } else if (match('+')) {
58283 quantifier = createQuantifier(1);
58284 } else if (match('?')) {
58285 quantifier = createQuantifier(0, 1);
58286 } else if (res = matchReg(/^\{([0-9]+)\}/)) {
58287 min = parseInt(res[1], 10);
58288 quantifier = createQuantifier(min, min, res.range[0], res.range[1]);
58289 } else if (res = matchReg(/^\{([0-9]+),\}/)) {
58290 min = parseInt(res[1], 10);
58291 quantifier = createQuantifier(min, undefined, res.range[0], res.range[1]);
58292 } else if (res = matchReg(/^\{([0-9]+),([0-9]+)\}/)) {
58293 min = parseInt(res[1], 10);
58294 max = parseInt(res[2], 10);
58295 if (min > max) {
58296 bail('numbers out of order in {} quantifier', '', from, pos);
58297 }
58298 quantifier = createQuantifier(min, max, res.range[0], res.range[1]);
58299 }
58300
58301 if (quantifier) {
58302 if (match('?')) {
58303 quantifier.greedy = false;
58304 quantifier.range[1] += 1;
58305 }
58306 }
58307
58308 return quantifier;
58309 }
58310
58311 function parseAtom() {
58312 // Atom ::

Callers 1

parseTermFunction · 0.85

Calls 4

createQuantifierFunction · 0.85
matchRegFunction · 0.85
bailFunction · 0.85
matchFunction · 0.70

Tested by

no test coverage detected