A transpiler that converts calculator expressions (supporting complex numbers, min/max operators, variables, and print statements) into executable JavaScript code. Built on jison and extended from a basic arithmetic calculator, version 1.0.0 adds scope analysis to enforce variable declaration before use, reference semantics for complex objects, and comma-separated expression sequences. Key differentiators: full complex arithmetic transpilation, meticulous error reporting with line/column, and avoidance of primitive method calls via explicit Complex() wrapping.
npm install arith2js-calculatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Transpile a complex expression with variables and print, then evaluate the generated JS.
Use dynamic import() or set "type": "module" in package.json.
Upgrade to >=1.0.0 to avoid primitive method call errors.
Use explicit cloning (e.g., Complex($a).add(0)) if copy semantics are needed.
Declare variables without $ in the input; the transpiler adds the prefix automatically.
Ensure all variables are declared with an assignment before use.
Add semicolons: e.g., 'a=1; b=2;' instead of 'a=1 b=2;'.
Assign a value to the variable before use: e.g., '$x = 5; print($x);'.
Upgrade to arith2js-calculator@1.0.0 or later.
Declare the variable before its first use: e.g., 'y=1; print(y);'.