@@ -37,11 +37,12 @@ const wildcard = P.string('.').map(
3737 ( ) => RE . literal ( CharSet . wildcard ( { dotAll : false } ) )
3838)
3939
40- const unescapedChar = P . satisfy ( Range . neverMustBeEscaped )
41-
4240const alphaNumChar = P . satisfy ( char => / ^ [ a - z A - Z 0 - 9 ] $ / . test ( char ) )
4341
44- const unescapedCharInsideBrackets = P . satisfy ( Range . mustBeEscapedOrInBrackets )
42+ const unescapedCharInsideBrackets = P . satisfy ( char => ! Range . mustBeEscapedInsideBrackets ( char ) )
43+ . map ( CharSet . singleton )
44+
45+ const unescapedCharOutsideBrackets = P . satisfy ( char => ! Range . mustBeEscapedOutsideBrackets ( char ) )
4546 . map ( CharSet . singleton )
4647
4748export class UnsupportedSyntaxError extends Error { }
@@ -96,15 +97,14 @@ const alphaNumRange: P.Parser<CharSet.CharSet> = alphaNumChar.andThen(start =>
9697
9798const charSet = P . choice ( [
9899 P . between (
99- // QUESTION: can brackets be nested?
100+ // square brackets cant't be nested
100101 P . string ( '[' ) ,
101102 P . string ( ']' ) ,
102103 P . optional ( P . string ( '^' ) ) . andThen ( negated =>
103104 P . many ( P . choice ( [
104105 escapeSequence , // e.g. "\$", "\]"
105106 alphaNumRange , // e.g. "a-z", "0-9" (will also match just "a", "3")
106107 unescapedCharInsideBrackets , // e.g. "$", "."
107- unescapedChar . map ( CharSet . singleton ) , // e.g. "#", "%"
108108 ] ) ) . map (
109109 sets => {
110110 if ( negated === undefined )
@@ -115,7 +115,7 @@ const charSet = P.choice([
115115 )
116116 )
117117 ) ,
118- unescapedChar . map ( CharSet . singleton ) ,
118+ unescapedCharOutsideBrackets ,
119119] )
120120
121121const group = P . between (
0 commit comments