64 lines
2.1 KiB
Markdown
64 lines
2.1 KiB
Markdown
# 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
|
|
|
|
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 ")";
|
|
|
|
## Build
|
|
|
|
The frontend requires GCC 14.2.0 (not tested with other versions).
|
|
|
|
Download the GCC source. Copy the contents of this repository into `gcc/elna`
|
|
inside GCC. Finally build GCC enabling the frontend with
|
|
`--enable-languages=c,c++,elna`. After the installation the compiler can be
|
|
invoked with `$prefix/bin/gelna`.
|
|
|
|
There is also a `Rakefile` that downloads, builds and installs GCC into the
|
|
`./build/` subdirectory. The `Rakefile` assumes that ruby and rake, as well as
|
|
all GCC dependencies are already available in the system. It works under Linux
|
|
and Mac OS. In the latter case GCC is patched with the patches used by Homebrew
|
|
(official GCC doesn't support Apple silicon targets). Invoke with
|
|
|
|
```sh
|
|
rake boot
|
|
```
|
|
|
|
See `rake -T` for more tasks. The GCC source is under `build/tools`. The
|
|
installation path is `build/host/install`.
|