-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle characters in the parser. #45
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,20 +340,26 @@ angular.module('rdmApp', []) | |
var token = tokens[j]; | ||
var hex_suffix_match = token.match(/^([\da-fA-F]{1,2})h$/); | ||
if (hex_suffix_match) { | ||
binary_data.push(parseInt(hex_suffix_match[0], 16)); | ||
binary_data.push(parseInt(hex_suffix_match[1], 16)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we have a comment at the top of this block reminding people of the broken way capture groups work in JS (it gets even messier if it's a global match with groups! |
||
continue; | ||
} | ||
|
||
var hex_prefix_match = token.match(/^0x([\da-fA-F]{1,2})$/); | ||
if (hex_prefix_match) { | ||
binary_data.push(parseInt(hex_prefix_match[0], 16)); | ||
binary_data.push(parseInt(hex_prefix_match[1], 16)); | ||
continue; | ||
} | ||
|
||
var char_match = token.match(/^'(.)'$/); | ||
if (char_match) { | ||
binary_data.push(char_match[1].charCodeAt()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this be binary_data.push(char_match[1].charCodeAt(0)); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently 0 is the default. I think I'm going to re-write the parser anyway. |
||
continue; | ||
} | ||
|
||
if (as_hex) { | ||
var hex_match = token.match(/^([\da-fA-F]{1,2})$/); | ||
if (hex_match) { | ||
binary_data.push(parseInt(hex_match[0], 16)); | ||
binary_data.push(parseInt(hex_match[1], 16)); | ||
continue; | ||
} else { | ||
error = 'Invalid byte: ' + token; | ||
|
@@ -362,8 +368,8 @@ angular.module('rdmApp', []) | |
} else { | ||
var decimal_match = token.match(/^(\d{1,3})$/); | ||
if (decimal_match) { | ||
if (decimal_match[0] <= 255) { | ||
binary_data.push(parseInt(decimal_match[0], 10)); | ||
if (decimal_match[1] <= 255) { | ||
binary_data.push(parseInt(decimal_match[1], 10)); | ||
continue; | ||
} else { | ||
error = 'Invalid byte: ' + token; | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this