2025-01-10 23:17:18 +01:00
2025-01-03 10:30:13 +01:00
2024-12-23 09:20:33 +01:00
2024-12-27 10:51:46 +01:00
2025-01-10 23:17:18 +01:00
2025-01-04 02:02:19 +01:00

# Elna programming language

Elna is a simple, imperative, low-level programming language.

It is intendet to accompany other languages in the areas, where a high-level
language doesn't fit well. It is also supposed to be an intermediate
representation for a such high-level hypothetical programming language.

## File extension

.elna

## Current implementation

This repository contains a GCC frontend for Elna. After finishing the frontend
I'm planning to rewrite the compiler in Elna itself with its own backend and
a hand-written parser. So GCC gives a way to have a simple bootstrap compiler
and a possbility to compile Elna programs for different platforms.

## Grammar PL/0

program = [ "type" type_definitions ";" ]
    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 ")";

type_expression = "array" number "of" type_expression
                | "^" type_expression
                | "record" field_list "end"
                | ident

field_list = ident ":" type_expression { ";" field_list }

## Operations

"!" - Write a line.
"?" - Read user input.
"odd" - The only function, returns whether a number is odd.
Description
Elna programming language compiles simple mathematical operations to RISC-V code.
Readme MPL-2.0 5.3 MiB
Languages
C++ 86.5%
LLVM 5.2%
C 3.9%
Makefile 2.2%
Ruby 2.2%