waran
about the project
Waran is a compiled language with it's target being javascript. The waran compiler is implemented in typescript and required node.js to run.
credits
made by kamkow1
special thanks to londek for helping out ;)
example waran program
import @io
import @math
class Program {
method static main() {
hello := "hello"
waran := "waran!"
std_out(hello waran)
for(i := 0 | i <= 10 | i++) {
## skip the 5th iteration
if (i == 5) {
continue
}
std_out(i)
}
while(true) {
if (counter > 10) {
break
}
std_out(counter)
counter++
}
my_array := ["string value" 4738 -21.564 true]
std_out(my_array[2])
}
}
Program.main()
table of contents
Installation
in order to install the waran compiler run:
npm i -g waran
or
yarn add -g waran
Project structure
to initalize an empty waran project, run:
wrn init
this command will create a few folders / files:
- .waran folder
- ast
-
this folder contains the .ast files for the compiler.
in general you don't want to edit any files there.
-
- build
-
this folder contains compiled files (.wr -> .js).
-
- ast
- wrn_proj.json
- describes the behaviour of the compiler.
- project_info - contains general information about the waran project
- dirs - contains paths to directories used by the compiler
- ast_dir
- location of abstract syntax tree (ast) files
- wrn_proj_dir
- location of the .waran directory (contains asts and build)
- src_dir
- location of the working direcotry (contains your source code)
- build
- location of the directory that contains built waran code
- ast_dir
- describes the behaviour of the compiler.
- src folder
- current working directory
- location can be modified in wrn_proj.json configuration file
- current working directory
Compiling code
to compile waran code run:
wrn compile < .wr file location >
this will produce a .js counterpart in the .waran/build directory unless the behaviour was modified in wrn_proj.json
Running code
to run waran code use:
wrn exec < path to .js file >
.js files can be found in the .waran/build directory with the same name as their .wr counterparts