|
|
|
@ -460,28 +460,34 @@ var Lexer = (function LexerClosure() {
@@ -460,28 +460,34 @@ var Lexer = (function LexerClosure() {
|
|
|
|
|
getHexString: function Lexer_getHexString(ch) { |
|
|
|
|
var str = ''; |
|
|
|
|
var stream = this.stream; |
|
|
|
|
for (;;) { |
|
|
|
|
var isFirstHex = true; |
|
|
|
|
var firstDigit; |
|
|
|
|
var secondDigit; |
|
|
|
|
while (true) { |
|
|
|
|
ch = stream.getChar(); |
|
|
|
|
if (ch == '>') { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (!ch) { |
|
|
|
|
warn('Unterminated hex string'); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (specialChars[ch.charCodeAt(0)] != 1) { |
|
|
|
|
var x, x2; |
|
|
|
|
if ((x = toHexDigit(ch)) == -1) |
|
|
|
|
error('Illegal character in hex string: ' + ch); |
|
|
|
|
|
|
|
|
|
ch = stream.getChar(); |
|
|
|
|
while (specialChars[ch.charCodeAt(0)] == 1) |
|
|
|
|
ch = stream.getChar(); |
|
|
|
|
|
|
|
|
|
if ((x2 = toHexDigit(ch)) == -1) |
|
|
|
|
error('Illegal character in hex string: ' + ch); |
|
|
|
|
|
|
|
|
|
str += String.fromCharCode((x << 4) | x2); |
|
|
|
|
} else if (ch === '>') { |
|
|
|
|
break; |
|
|
|
|
} else if (specialChars[ch.charCodeAt(0)] === 1) { |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
if (isFirstHex) { |
|
|
|
|
firstDigit = toHexDigit(ch); |
|
|
|
|
if (firstDigit === -1) { |
|
|
|
|
warn("Ignoring invalid character '" + ch + "' in hex string"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
secondDigit = toHexDigit(ch); |
|
|
|
|
if (secondDigit === -1) { |
|
|
|
|
warn("Ignoring invalid character '" + ch + "' in hex string"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
str += String.fromCharCode((firstDigit << 4) | secondDigit); |
|
|
|
|
} |
|
|
|
|
isFirstHex = !isFirstHex; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return str; |
|
|
|
|