Elna programming language compiles simple mathematical operations to RISC-V code.
Go to file
Eugen Wissner 86d579e8d5
Grow stack automatically
2024-02-18 11:26:57 +01:00
source Grow stack automatically 2024-02-18 11:26:57 +01:00
tests Grow stack automatically 2024-02-18 11:26:57 +01:00
.gitignore Initial commit 2022-06-05 15:16:04 +02:00
CMakeLists.txt Grow stack automatically 2024-02-18 11:26:57 +01:00
README Grow stack automatically 2024-02-18 11:26:57 +01:00
Rakefile Grow stack automatically 2024-02-18 11:26:57 +01:00
TODO Grow stack automatically 2024-02-18 11:26:57 +01:00
dub.json Update the toolchain 2024-02-15 15:13:47 +01:00

README

# Elna programming language

Elna compiles simple mathematical operations to machine code.
The compiled program returns the result of the operation.

## File extension

.elna

## Grammar PL/0

program = block "." ;

block = [ "const" ident "=" number {"," ident "=" number} ";"]
        [ "var" ident {"," ident} ";"]
        { "procedure" ident ";" block ";" } statement ;

statement = [ ident ":=" expression | "call" ident 
              | "?" ident | "!" expression 
              | "begin" statement {";" statement } "end" 
              | "if" condition "then" statement 
              | "while" condition "do" statement ];

condition = "odd" expression |
            expression ("="|"#"|"<"|"<="|">"|">=") expression ;

expression = [ "+"|"-"] term { ("+"|"-") term};

term = factor {("*"|"/") factor};

factor = ident | number | "(" expression ")";

## Operations

"!" - Write a line.
"?" - Read user input.
"odd" - The only function, returns whether a number is odd.

# Build and test

```sh
cmake -B build
make -C build 
./build/bin/tester
```