My favorites | Sign in
Project Home Wiki Issues Source
Project Information
Members
Links

About Calculate

Calculate is a Mac OS X widget for evaluating math expressions. It uses JavaScript with some modifications (like ^ for pow and ! for factorial). Users can define their own variables and functions. Variables and functions are persistently stored.

Visit the Calculate home page

How it works

Calculate has a custom ANTLR grammar similar to JavaScript, but with the following changes:

  • ^ and ** are power operators.
  • >< is the xor operator.
  • ! is factorial.
  • Binary literals: 0b101010.
  • Octal literals: 0o52.
  • Numbers with leading zeros are treated as decimal literals.

After parsing the input to a grammar tree, ECMAScript3ExtEmitter.js converts the tree to standard JavaScript source code, and Calc.js executes it using eval().

Powered by Google Project Hosting