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. // Based on ECMA-262, 5th ed., 7.8.5 & 15.10.1.
// //

@ -52,13 +52,15 @@ function generateJS( ast, session, options ) {
return "/^[" return "/^["
+ ( cls.inverted ? "^" : "" ) + ( cls.inverted ? "^" : "" )
+ cls.value + cls.value
.map( part => .map( part => (
( Array.isArray( part )
? js.regexpClassEscape( part[ 0 ] ) Array.isArray( part )
+ "-" ? js.regexpEscape( part[ 0 ] )
+ js.regexpClassEscape( part[ 1 ] ) + "-"
: js.regexpClassEscape( part ) ) + js.regexpEscape( part[ 1 ] )
) : js.regexpEscape( part )
) )
.join( "" ) .join( "" )
+ "]/" + "]/"
+ ( cls.ignoreCase ? "i" : "" ); + ( cls.ignoreCase ? "i" : "" );

@ -65,7 +65,8 @@ declare module "pegjs/lib/compiler/js" {
namespace js { namespace js {
function stringEscape( s: string ): string; function stringEscape( s: string ): string;
function regexpClassEscape( s: string ): string; function regexpEscape( s: string ): string;
const reservedWords: string[];
} }
export default js; export default js;

Loading…
Cancel
Save