Introduction

This page is a demonstration of Cedalion's first steps in the Javascript world.

As part of the effort to allow web programming in Cedalion, we created a transformation of Cedalion code into Javascript. This allows Javascript code running on the browser to consult the Cedalion program, without connecting to a server.

Calculator Demo

Below are two text boxes. One contains an expression. Try editing the expression and you'll see the result below. The other text-box will show you how long it took it to parse the input, calculate the result and update the display.

This is a unit calculator, that performs calculations on physical units. Try the expressions below, or build your own expression. The result will be given in SI units, or in the units of your choice when asking for them, using "in".

This calculator can also make currency conversions, or perform computations based on currencies. In this demo we use fake values, just to demonstrate the technology, so don't rely on these results for anything useful...

Please enter an expression here:

Below are a few examples accepted by this calculator:

Implementation

Unlike other online calculators, such as the Google Calculator, which parse the expression and calculate the value on the server, this calculator works entirely on the client side, apart for AJAX calls to retrieve currency rates.

The logic of this calculator is implemented in Cedalion, and translated to Javascript. It is implemented in a DSL for parsing (based on BNF notation), combined with a DSL for AJAX expressions (expressions which need AJAX calls to as part of their evaluation). For your reference, we added a part of the implementation below.

Number Format

Physical Measure Syntax

Arithmetic Operations