diff --git a/lib/compiler/js.js b/lib/compiler/js.js index 9d1fb71..d0abe0a 100644 --- a/lib/compiler/js.js +++ b/lib/compiler/js.js @@ -34,7 +34,7 @@ const js = { }, - regexpClassEscape( s ) { + regexpEscape( s ) { // Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1. // diff --git a/lib/compiler/passes/generate-js.js b/lib/compiler/passes/generate-js.js index 1a4a278..b82742b 100644 --- a/lib/compiler/passes/generate-js.js +++ b/lib/compiler/passes/generate-js.js @@ -52,13 +52,15 @@ function generateJS( ast, session, options ) { return "/^[" + ( cls.inverted ? "^" : "" ) + cls.value - .map( part => - ( Array.isArray( part ) - ? js.regexpClassEscape( part[ 0 ] ) - + "-" - + js.regexpClassEscape( part[ 1 ] ) - : js.regexpClassEscape( part ) ) - ) + .map( part => ( + + Array.isArray( part ) + ? js.regexpEscape( part[ 0 ] ) + + "-" + + js.regexpEscape( part[ 1 ] ) + : js.regexpEscape( part ) + + ) ) .join( "" ) + "]/" + ( cls.ignoreCase ? "i" : "" ); diff --git a/lib/typings/modules.d.ts b/lib/typings/modules.d.ts index ebd6969..4b1a94b 100644 --- a/lib/typings/modules.d.ts +++ b/lib/typings/modules.d.ts @@ -65,7 +65,8 @@ declare module "pegjs/lib/compiler/js" { namespace js { function stringEscape( s: string ): string; - function regexpClassEscape( s: string ): string; + function regexpEscape( s: string ): string; + const reservedWords: string[]; } export default js;