Adding lookbehind assertion

This commit is contained in:
LiHS 2019-08-15 14:02:53 +08:00
parent ac8d90e65a
commit c092b5fa3a
3 changed files with 18 additions and 2 deletions

View File

@ -22,6 +22,12 @@ 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' }),
proxy: jasmine.objectContaining({ textValue: 'test' })
@ -110,6 +116,14 @@ describe('parser/javascript/subexp.js', function() {
label: 'negative lookahead',
groupCounter: 1
},
'(?<=test)': {
label: 'positive lookbehind',
groupCounter: 1
},
'(?<!test)': {
label: 'negative lookbehind',
groupCounter: 1
},
'(?:test)': {
label: '',
groupCounter: 1

View File

@ -11,7 +11,7 @@ grammar JavascriptRegexp
repeat_spec <- ( "{" min:[0-9]+ "," max:[0-9]+ "}"
/ "{" min:[0-9]+ ",}"
/ "{" exact:[0-9]+ "}" ) <RepeatSpec>
subexp <- "(" capture:( "?<" groupname:name ">" / "?:" / "?=" / "?!" )? regexp ")" <Subexp>
subexp <- "(" capture:( "?<" groupname:name ">" / "?:" / "?=" / "?!" / "?<=" / "?<!" )? regexp ")" <Subexp>
name <- alpha (alpha / numeric)*
alpha <- [a-zA-Z]
numeric <- [0-9]

View File

@ -26,7 +26,9 @@ export default {
labelMap: {
'?:': '',
'?=': 'positive lookahead',
'?!': 'negative lookahead'
'?!': 'negative lookahead',
'?<=': 'positive lookbehind',
'?<!': 'negative lookbehind'
},
// Renders the subexp into the currently set container.