A hobby compiler build by nearley.
- Lexer
- Parser
- AST Tree as JSON format
- Generate JS as intermediate code
- While loop
- Variable
- Operator
+ - * / >= <= > < = :=
$ node parser.js examples/hello-world.mylang
$ node examples/hello-world.js
$ node parser.js examples/hello-world.mylang
$ node examples/hello-world.js
print 10
$ node parser.js examples/loop.mylang
$ node examples/loop.js
n := 1
while n < 10 {
n := n + 1
print n
}
$ node parser.js examples/fib.mylang
$ node examples/fib.js
i := 1
n := 10
fi := 1
fii := 1
while i <= n {
print fi
temp := fi + fii
fi := fii
fii := temp
i := i +1
}
- For
- Function
- Array value
- String value
- Boolean value
© Copyright Max Base 2021
Thanks from Toby Ho and Nearley (https://nearley.js.org/)