mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-11 15:32:09 +01:00
20 lines
575 B
JavaScript
20 lines
575 B
JavaScript
(function(bitwise) {
|
|
var twoOperandsRegex = /^(\d+)(<<|>>|\||\&|\^)(\d+)$/;
|
|
|
|
app.service('expression', {
|
|
parse: function(string) {
|
|
var matches = twoOperandsRegex.exec(string);
|
|
console.log(matches);
|
|
return {
|
|
string:matches[0],
|
|
operand1: parseInt(matches[1], 10),
|
|
sign: matches[2],
|
|
operand2: parseInt(matches[3], 10),
|
|
result: function() {
|
|
return eval(string);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
})(window.app); |