GithubHelp home page GithubHelp logo

arith-dsl's Introduction

Arithmetic DSL

Compiling/Running

In order to compile and run the code, you need to install 'sbt'.

You can run the main file using the following command:

sbt run

Step 1

At this step, we implement the AST and parser for a simple arithmetic DSL with the following constructs:

  1. addition, 2) substraction, and 3) a constant value.

Step 2

At this step, we define an interpreter for the DSL we have defined in the previous step.

Step 3

At this step, we extend the DSL with the following constructs: 4) multiplication, and 5) division.

Note how the AST, the parser, and the interpreter are modified to reflect the changes to the DSL.

Step 4

At this step, the DSL supports the definition of a (constant) variable. To define a variable we use the following syntax:

let x = e1 in e2

in which we initialize the variable named x with the expression e1. This variable can be used in the expression e2.

As an example, in the following program:

let x = 2 * 3 in x * 4

the variable x is initialized with the expression 2 * 3. This variable is then used in the expression x * 4. This program is evaluated to 24 in the run time.

Step 5

Finally, we add a C code generator for this DSL.

arith-dsl's People

Contributors

amirsh avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.