Netuno is a imperative, modular, functional, object-oriented, statically-typed, object-oriented programming language. It has a BASIC-like syntax, is memory-safe by default and can be easily embedded.
import console
def fibonacci(n: uint): uint
if n == 0u => return 0u
if n == 1u => return 1u
return fibonacci(n - 1u) + fibonacci(n - 2u)
end
def main()
var input: string
while (input = console.readline()) != "exit"
; this is a line comment
var n = uint(input)
n = fibonacci(n)
console.write("Result: " + n + "\n")
next
return 0 ; ok
end
The repository is divided by the compiler(ntc) and the runtime(ntr).
Natch(ntc) is the Netuno Compiler, currently supports Notable Bytecode generation.
- Lexer
- Parser
- Semantic Analysis
- Optimization
- C codegen
- Notable Bytecode Codegen
- Conditional
- Loops
- Break
- Continue
- Import
- Variable
- Module
- Assignment
- Expressions
- Functions and subroutines
- String
- Reference
- Array
- Custom type declaration
- Object methods
Nitro(ntr) is the Netuno Runtime, it has a stack virtual machine that can runs Notable Bytecode.
Debug trace will be enable and will print Abstract Syntax Tree in parser stage and enable VM stack debug trace.
$ cmake -DCMAKE_BUILD_TYPE=Debug .
$ cmake --build .
$ ./bin/ntc sample.nt
Debug tracing is disabled and all optimizations in the C compiler are enabled.
$ cmake -DCMAKE_BUILD_TYPE=Release .
$ cmake --build .
$ ./bin/ntc sample.nt