Elna programming language compiles simple mathematical operations to RISC-V code.
Go to file
2024-11-20 17:38:03 +01:00
lib/Language/Elna Adjust stack size based on local variables 2024-11-20 17:38:03 +01:00
rakelib Add call pseudo instruction 2024-09-15 23:03:25 +02:00
src Check argument list length 2024-10-31 22:19:48 +01:00
tests Adjust stack size based on local variables 2024-11-20 17:38:03 +01:00
tools Implement division 2024-10-06 18:09:08 +02:00
.gitignore Add enum AST types 2024-07-22 09:47:45 +02:00
.ruby-version Add rake task to build a cross toolchain 2024-09-04 22:05:55 +02:00
elna.cabal Abstract the string table into a newtype 2024-10-22 01:21:02 +02:00
LICENSE Initial commit 2024-07-21 16:15:17 +02:00
Rakefile Add rake task to build a cross toolchain 2024-09-04 22:05:55 +02:00
README Initial commit 2024-07-21 16:15:17 +02:00
TODO Map local variables in IR to their original names 2024-11-14 19:55:30 +01:00

# 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.