Example grammars: Improve |parseInt| invocations

Instead of |parseInt("0x" + digits)| do |parseInt(digits, 16)|, which is
a bit cleaner.
redux
David Majda 11 years ago
parent 68c6452d8a
commit da9a32a5f3

@ -298,7 +298,7 @@ nonascii
unicode
= "\\" digits:$(h h? h? h? h? h?) ("\r\n" / [ \t\r\n\f])? {
return String.fromCharCode(parseInt("0x" + digits));
return String.fromCharCode(parseInt(digits, 16));
}
escape

@ -231,7 +231,7 @@ SignedInteger
= [-+]? DecimalDigits
HexIntegerLiteral
= "0" [xX] digits:$HexDigit+ { return parseInt("0x" + digits); }
= "0" [xX] digits:$HexDigit+ { return parseInt(digits, 16); }
HexDigit
= [0-9a-fA-F]
@ -292,12 +292,12 @@ EscapeCharacter
HexEscapeSequence
= "x" digits:$(HexDigit HexDigit) {
return String.fromCharCode(parseInt("0x" + digits));
return String.fromCharCode(parseInt(digits, 16));
}
UnicodeEscapeSequence
= "u" digits:$(HexDigit HexDigit HexDigit HexDigit) {
return String.fromCharCode(parseInt("0x" + digits));
return String.fromCharCode(parseInt(digits, 16));
}
RegularExpressionLiteral "regular expression"

@ -65,7 +65,7 @@ char
/ "\\r" { return "\r"; }
/ "\\t" { return "\t"; }
/ "\\u" digits:$(hexDigit hexDigit hexDigit hexDigit) {
return String.fromCharCode(parseInt("0x" + digits));
return String.fromCharCode(parseInt(digits, 16));
}
number "number"

Loading…
Cancel
Save