commit 7ee06e567c452383d5e800cc75356d2b7c3472b3
parent 7426e5a549da3a65ca64b99e0e128ef5ea1bad1b
Author: thing1 <thing1@seacrossedlovers.xyz>
Date: Wed, 29 Oct 2025 15:15:42 +0000
added spec
Diffstat:
| M | Makefile | | | 5 | ++++- |
| A | spec.md | | | 116 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 120 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -17,5 +17,8 @@ parse.c: parse.y
graph: fela
dot y.gv -Tpdf | ${PDFREADER} -
+spec: spec.md
+ smu $< > spec.html
+
clean:
- rm -rf fela lex.c parse.c y.tab.h *.gv *.pdf
+ rm -rf fela lex.c parse.c y.tab.h *.gv *.pdf *.html
diff --git a/spec.md b/spec.md
@@ -0,0 +1,116 @@
+Fela 0.1 spec
+=============
+
+The fela language is a statically typed compiled language, akin to C
+
+It's name is derived from the
+[alef](https://doc.cat-v.org/plan_9/2nd_edition/papers/alef/ref),
+but backwards
+
+Spec
+----
+
+Types
+-----
+
+The language should define the following types:
+
+- `long` as 64 bits
+- `int` as 32 bits
+- `short` as 16 bits
+- `byte` as 8 bits
+
+The language should also support composite types, via structs
+like so:
+
+```
+struct { int a, long b };
+```
+
+The language should allow for user defined types via a `type`
+keyword, it should work similar to `typedef` in c. An example
+of this would be:
+
+```
+type pos = struct {
+ int x;
+ int y;
+};
+```
+
+Now the word pos can be used instead of the struct definition.
+
+Functions should be treated as values, meaning they should have a type.
+Their type definition should look like this:
+
+`func(int, int) -> long`
+
+So a variable which has this type would look like so:
+
+`func(int, int) -> long foo`
+
+This has defined the stub of function foo, that takes
+in 2 int's and returns a long.
+
+To give the function a body, use curly brackets like so:
+
+```
+func(int, int) -> int foo = (int a, int b) -> int {
+ return a * b;
+};
+```
+
+This is obviously quite long, to help this, a short hand
+operator should be implemented like so:
+
+```
+foo := (int a, int b) -> int {
+ return a * b;
+};
+```
+
+This code is functionally equal to the previous, the type is
+automatically decided at compile time.
+
+This technique can also be used for regular variables:
+
+`bar := 20`
+
+This will automatically use a long in this case to store the
+value.
+
+The default types are as follows:
+
+- string literals -> `unsigned byte *`
+- integer literals -> `long`
+- ...
+
+Structure
+---------
+
+The language expects programs to have functions defined in the
+global scope like so:
+
+```
+foo := (int a) -> int {
+ return a + 1;
+};
+
+bar := (int a) -> int {
+ return a - 4;
+};
+
+main := () -> int {
+ int a = 20;
+ int b = 30;
+
+ return foo(a) + bar(b);
+};
+```
+
+Functions should be defined before use, the program should contain a
+main function if it is to be executed. If a function intends to
+define its own variables, it must be done before any expressions
+are encountered, much like C89.
+
+