binary-parser
binary-parser copied to clipboard
Support for names with non-alphanumeric characters?
I noticed in the API documentation that "name should consist only of alphanumeric characters and start with an alphabet." It looks like this is because the compiled code uses dot notation to access properties:
Context.prototype.generateVariable = function(name) {
var arr = [];
Array.prototype.push.apply(arr, this.scopes[this.scopes.length - 1]);
if (name) {
arr.push(name);
}
return arr.join('.');
};
Would there be any harm in using array bracket notation instead, so that any valid property name can be used as a name? It's not very elegant, but something like:
Context.prototype.generateVariable = function(name) {
var arr = [];
Array.prototype.push.apply(arr, this.scopes[this.scopes.length - 1]);
if (name) {
arr.push(name);
}
return arr[0] + arr.slice(1).map(function(x) { return '["' + x + '"]'; }).join('');
};