regjsparser
Advanced tools
Comparing version
{ | ||
"name": "regjsparser", | ||
"version": "0.9.1", | ||
"version": "0.10.0", | ||
"author": "'Julian Viereck' <julian.viereck@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "BSD-2-Clause", |
@@ -23,2 +23,3 @@ // regjsparser | ||
// Anchor | ||
// Anchor Quantifier (see https://github.com/jviereck/regjsparser/issues/130) | ||
// Atom | ||
@@ -563,2 +564,3 @@ // Atom Quantifier | ||
// Anchor | ||
// Anchor Quantifier (see https://github.com/jviereck/regjsparser/issues/130) | ||
// Atom | ||
@@ -571,38 +573,39 @@ // Atom Quantifier | ||
var anchor = parseAnchor(); | ||
var anchorOrAtom = parseAnchor(); | ||
if (anchor) { | ||
return anchor; | ||
} | ||
// If there is no Anchor, try to parse an atom. | ||
if (!anchorOrAtom) { | ||
var atom = parseAtomAndExtendedAtom(); | ||
var quantifier; | ||
if (!atom) { | ||
// Check if a quantifier is following. A quantifier without an atom | ||
// is an error. | ||
var pos_backup = pos | ||
quantifier = parseQuantifier() || false; | ||
if (quantifier) { | ||
pos = pos_backup | ||
bail('Expected atom'); | ||
} | ||
var atom = parseAtomAndExtendedAtom(); | ||
var quantifier; | ||
if (!atom) { | ||
// Check if a quantifier is following. A quantifier without an atom | ||
// is an error. | ||
var pos_backup = pos | ||
quantifier = parseQuantifier() || false; | ||
if (quantifier) { | ||
pos = pos_backup | ||
bail('Expected atom'); | ||
// If no unicode flag, then try to parse ExtendedAtom -> ExtendedPatternCharacter. | ||
// ExtendedPatternCharacter | ||
var res; | ||
if (!isUnicodeMode && (res = matchReg(/^{/))) { | ||
atom = createCharacter(res); | ||
} else { | ||
bail('Expected atom'); | ||
} | ||
} | ||
anchorOrAtom = atom; | ||
} | ||
// If no unicode flag, then try to parse ExtendedAtom -> ExtendedPatternCharacter. | ||
// ExtendedPatternCharacter | ||
var res; | ||
if (!isUnicodeMode && (res = matchReg(/^{/))) { | ||
atom = createCharacter(res); | ||
} else { | ||
bail('Expected atom'); | ||
} | ||
} | ||
quantifier = parseQuantifier() || false; | ||
if (quantifier) { | ||
quantifier.body = flattenBody(atom); | ||
quantifier.body = flattenBody(anchorOrAtom); | ||
// The quantifier contains the atom. Therefore, the beginning of the | ||
// quantifier range is given by the beginning of the atom. | ||
updateRawStart(quantifier, atom.range[0]); | ||
updateRawStart(quantifier, anchorOrAtom.range[0]); | ||
return quantifier; | ||
} | ||
return atom; | ||
return anchorOrAtom; | ||
} | ||
@@ -783,3 +786,3 @@ | ||
} | ||
else if (features.modifiers && str.indexOf("(?") == pos && str[pos+2] != ":") { | ||
else if (features.modifiers && str.indexOf("(?") == pos && str[pos + 2] != ":") { | ||
return parseModifiersGroup(); | ||
@@ -833,5 +836,5 @@ } | ||
modifiersGroup.modifierFlags = { | ||
enabling: enablingFlags, | ||
disabling: disablingFlags | ||
}; | ||
enabling: enablingFlags, | ||
disabling: disablingFlags | ||
}; | ||
@@ -838,0 +841,0 @@ return modifiersGroup; |
65995
0.47%1665
0.18%