From 8d3dc109ede63e379470d544004f03306c6c5dab Mon Sep 17 00:00:00 2001 From: Futago-za Ryuu Date: Mon, 2 Apr 2018 21:17:35 +0100 Subject: [PATCH] Rename js.regexpClassEscape to js.regexpEscape --- lib/compiler/js.js | 2 +- lib/compiler/passes/generate-js.js | 16 +++++++++------- lib/typings/modules.d.ts | 3 ++- 3 files changed, 12 insertions(+), 9 deletions(-) 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;