Skip to content

My dummy programming language that compiles specific syntax arithmetical expressions to JavaScript expressions

License

Notifications You must be signed in to change notification settings

guilopesn/william-dummy-lang

Repository files navigation

William Dummy Lang

My dummy programming language that compiles specific syntax arithmetical expressions to JavaScript expressions. I just did this as compilers training.

Operators

  • sub - Subtract
  • sum - Sum
  • mult - Multiply
  • div - Divide

Syntax

(operator ...args[] | (operator ...args[]))

Example

(sum 2 (sub 4 3 1)) // Equivalent to (4 - 3 - 1 ) + 2

Usage

Install dependencies

npm install

Compiling

Source file

Path: ./examples/simple.dml

Content:

(sum 2 (sub 4 3 1))

Compile command

npm run compile ./examples/simple.dml

Compiled file

Path: ./examples/simple.js

Content:

2 + (4 - 3 - 1);

Executing

Source file

Path: ./examples/simple.dml

Content:

(sum 2 (sub 4 3 1))

Execute command

npm run execute ./examples/simple.dml

Execute command output

2023-08-17T19:44:34.064Z Source file ./examples/simple.dml execution started
2023-08-17T19:44:34.067Z Compilation process started
2023-08-17T19:44:34.067Z Reading source file...
2023-08-17T19:44:34.067Z Source file successfully read. Compiling content...
2023-08-17T19:44:34.067Z Compilation process finished. Took 0.48ms
2023-08-17T19:44:34.068Z Source file execution finished. Took 0.57ms. Result: 2

About

My dummy programming language that compiles specific syntax arithmetical expressions to JavaScript expressions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published