Rename js.regexpClassEscape to js.regexpEscape

master
Futago-za Ryuu 6 years ago
parent 878421ab75
commit 8d3dc109ed

@ -34,7 +34,7 @@ const js = {
},
regexpClassEscape( s ) {
regexpEscape( s ) {
// Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1.
//

@ -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" : "" );

@ -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;

Loading…
Cancel
Save