Skip to content

Commit

Permalink
fix(lexer): fix wrong error when using regex flag s together with m or y
Browse files Browse the repository at this point in the history
closes #202
  • Loading branch information
3cp committed Mar 18, 2022
1 parent 6a386a2 commit d757c6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lexer/regexp.ts
Expand Up @@ -59,13 +59,13 @@ export function scanRegularExpression(parser: ParserState, context: Context): To
const bodyEnd = parser.index - 1;

const enum RegexFlags {
Empty = 0b00000,
IgnoreCase = 0b00001,
Global = 0b00010,
Multiline = 0b00100,
Unicode = 0b10000,
Sticky = 0b01000,
DotAll = 0b1100
Empty = 0b000000,
IgnoreCase = 0b000001,
Global = 0b000010,
Multiline = 0b000100,
Unicode = 0b010000,
Sticky = 0b001000,
DotAll = 0b100000
}

let mask = RegexFlags.Empty;
Expand Down
7 changes: 7 additions & 0 deletions test/lexer/regexp.ts
Expand Up @@ -133,6 +133,13 @@ describe('Lexer - Regular expressions', () => {
[Context.AllowRegExp, '/a(?!b(?!c)d)e/', 'a(?!b(?!c)d)e', ''],
[Context.AllowRegExp, '/[^a-z]{4}/', '[^a-z]{4}', ''],
[Context.AllowRegExp, '/1?1/mig', '1?1', 'mig'],
[Context.AllowRegExp, '/.*/sm', '.*', 'sm'],
[Context.AllowRegExp, '/.*/ms', '.*', 'ms'],
[Context.AllowRegExp, '/.*/sy', '.*', 'sy'],
[Context.AllowRegExp, '/.*/ys', '.*', 'ys'],
[Context.AllowRegExp, '/.*/s', '.*', 's'],
[Context.AllowRegExp, '/.*/m', '.*', 'm'],
[Context.AllowRegExp, '/.*/y', '.*', 'y'],
[Context.AllowRegExp, '/\\%([0-9]*)\\[(\\^)?(\\]?[^\\]]*)\\]/', '\\%([0-9]*)\\[(\\^)?(\\]?[^\\]]*)\\]', '']
];

Expand Down

0 comments on commit d757c6b

Please sign in to comment.