diff --git a/spec/parser/javascript/subexp_spec.js b/spec/parser/javascript/subexp_spec.js index cd55938..3ae6194 100644 --- a/spec/parser/javascript/subexp_spec.js +++ b/spec/parser/javascript/subexp_spec.js @@ -13,12 +13,21 @@ describe('parser/javascript/subexp.js', function() { '(test)': { regexp: jasmine.objectContaining({ textValue: 'test' }) }, + '(?test)': { + regexp: jasmine.objectContaining({ textValue: 'test' }) + }, '(?=test)': { regexp: jasmine.objectContaining({ textValue: 'test' }) }, '(?!test)': { regexp: jasmine.objectContaining({ textValue: 'test' }) }, + '(?<=test)': { + regexp: jasmine.objectContaining({ textValue: 'test' }) + }, + '(?test)': { + label: 'group \'name\'', + groupCounter: 1 + }, '(?=test)': { label: 'positive lookahead', groupCounter: 1 @@ -103,6 +116,14 @@ describe('parser/javascript/subexp.js', function() { label: 'negative lookahead', groupCounter: 1 }, + '(?<=test)': { + label: 'positive lookbehind', + groupCounter: 1 + }, + '(? - subexp <- "(" capture:( "?:" / "?=" / "?!" )? regexp ")" + subexp <- "(" capture:( "?<" groupname:name ">" / "?:" / "?=" / "?!" / "?<=" / "? + name <- alpha (alpha / numeric)* + alpha <- [a-zA-Z] + numeric <- [0-9] charset <- "[" invert:"^"? parts:( charset_range / charset_terminal )* "]" charset_range <- first:charset_range_terminal "-" last:charset_range_terminal charset_terminal <- charset_escape diff --git a/src/js/parser/javascript/subexp.js b/src/js/parser/javascript/subexp.js index 9f97811..b91f857 100644 --- a/src/js/parser/javascript/subexp.js +++ b/src/js/parser/javascript/subexp.js @@ -26,7 +26,9 @@ export default { labelMap: { '?:': '', '?=': 'positive lookahead', - '?!': 'negative lookahead' + '?!': 'negative lookahead', + '?<=': 'positive lookbehind', + '?