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

digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";

integer = digit { digit };
boolean = "true" | "false";

program = [ "type" type_definitions ";" ]
    [ "const" ident "=" integer { "," ident "=" integer } ";"]
    { procedure_definition }
    [ "var" variable_declarations ";" ]
    compound_statement ".";

procedure_definition = "procedure" ident formal_parameter_list ";" block ";";

block = [ "const" ident "=" integer { "," ident "=" integer } ";" ]
    [ "var" variable_declarations ";" ]
    statement;

statement = [ ident ":=" expression
            | ident actual_parameter_list
            | compound_statement
            | "if" condition "then" statement 
            | "while" condition "do" statement ];

compound_statement = "begin" statement {";" statement } "end" ;

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

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

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

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

formal_parameter_list = "(" [ variable_declarations ] ")";

actual_parameter_list = "(" [ expressions ] ")";

expressions = expression { "," expression };

variable_declarations = variable_declaration { ";" variable_declaration };

variable_declaration = ident ":" type_expression;

type_expression = "array" integer "of" type_expression
                | "^" type_expression
                | "record" field_list "end"
                | ident;

field_list = field_declaration { ";" field_declaration };

field_declaration = ident ":" type_expression;
Description
Elna programming language compiles simple mathematical operations to RISC-V code.
Readme 2.7 MiB
Languages
C++ 82.1%
Ruby 10.7%
LLVM 6.1%
CMake 1%
C 0.1%