Add inital documentation, starter code.

This commit is contained in:
zongor 2025-12-21 11:11:29 -08:00
parent a51ce9a55e
commit a587cb68e3
16 changed files with 245 additions and 3 deletions

View File

@ -1,3 +0,0 @@
# undar-lang
A statically-typed permacomputing-oriented language for the purpose of creating 3D programs that work on constrained systems, retro consoles, and the web.

58
README.org Normal file
View File

@ -0,0 +1,58 @@
#+TITLE: Undâr Programming Language
#+BEGIN_SRC
[ᚢ ᛫ ᛫ ᛫
᛫ ᚾ ᛫ ᛫
᛫ ᛫ ᛞ ᛫
᛫ ᛫ ᛫ ᚱ]
#+END_SRC
* Philosophy
Undâr conforms to permacomputing principles.
Permacomputing as defined by the [[https://wiki.xxiivv.com/site/permacomputing.html][xxiivv wiki]]: "permacomputing encourages the maximization of hardware lifespan, minimization of energy usage and focuses on the use of already available computational resources.
it values maintenance and refactoring of systems to keep them efficient, instead of planned obsolescence, permacomputing practices planned longevity.
it is about using computation only when it has a strengthening effect on ecosystems."
Undâr is designed to ensure that programs will last indefinitly, but it is likely they will only last 'a very long time'.
The VM specification is the core of the language. It should be able to fit on a napkin and be able to be implemented in a weekend.
This implementation of the VM is written in freestanding C89 to maximize the chance that obscure C compilers will be able to compile it.
Once the VM is implemented it can be integrated into a architecutre specific code.
Undâr is intended to run on anything with a C compiler. From constrained systems like: retro consoles, microcontrollers to the web using emscripten.
* Getting Started
**
** Build (linux version)
#+BEGIN_SRC sh
git clone https://git.alfrescocavern.com/zongor/undar-lang.git
cd undar-lang && ./build
#+END_SRC
* Roadmap
[[./ROADMAP.org][Compiler, Plex, Immidate mode GUI, Constructive solid geometry, Tunnels, Actor model]]
* License
[[./LICENSE][GPLv3]]
* Inspirations
- [[https://plan9.io/][Plan 9]] : 9P, Unified I/O, Tunnels.
- [[https://en.wikipedia.org/wiki/Lisp_(programming_language)][Lisp]] : REPL, introspection.
- [[https://fortran-lang.org/][Fortran]] : Array semantics.
- [[https://en.wikipedia.org/wiki/C_(programming_language)][C]] / [[https://ziglang.org/][Zig]] : Efficentcy, simplicity.
- [[https://lua.org][Lua]] - Friendly syntax, portable, and minimalism.
- [[https://www.craftinginterpreters.com/the-lox-language.html][Lox]] - The start of my programming language creation journey.
- [[https://wiki.xxiivv.com/site/uxn.html][Uxn]] - Major inspiration, espeically around the design for devices.
- [[http://duskos.org/][Dusk OS]] - A much better system for doing permacomputing.
- [[https://doc.cat-v.org/inferno/4th_edition/dis_VM_specification][Dis VM]] - Ideas on VM structure
- Retro Systems - N64, PS1, Mac Classic, Windows 95, Especially Classic MacOS UI esthetics

2
ROADMAP.org Normal file
View File

@ -0,0 +1,2 @@
#+TITLE Project Roadmap

1
SPECIFICATION.org Normal file
View File

@ -0,0 +1 @@
#+TITLE Project Specification

0
arch/linux/gui/main.c Normal file
View File

0
arch/linux/tui/main.c Normal file
View File

0
arch/web/main.c Normal file
View File

2
build Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh

3
imgs/convert.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
magick -background none -density 384 undar.svg -define icon:auto-resize favicon.ico
magick -background none -density 100 undar.svg -define icon:auto-resize undar.png

BIN
imgs/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 298 KiB

BIN
imgs/undar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

56
imgs/undar.svg Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="32mm"
height="32mm"
viewBox="0 0 32 32"
version="1.1"
id="svg1"
inkscape:version="1.4.2 (ebf0e940d0, 2025-05-08)"
sodipodi:docname="undar.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showguides="false"
inkscape:zoom="5.252469"
inkscape:cx="31.413798"
inkscape:cy="77.392175"
inkscape:window-width="1939"
inkscape:window-height="932"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#000000;stroke:#ffffff;stroke-width:0.259677;stroke-opacity:0.80000001"
d="M 9.8701612,2.1298382 H 2.1298382 V 29.870162 h 7.740323 V 27.874455 H 3.9914349 V 4.0257595 h 5.8787263 z"
id="path1" />
<path
style="fill:#000000;stroke:#ffffff;stroke-width:0.259677;stroke-opacity:0.80000001"
d="m 22.129839,2.1298386 h 7.740323 V 29.870161 h -7.740323 v -1.995707 h 5.878726 V 4.02576 h -5.878726 z"
id="path1-3" />
<path
d="m 9.9966523,7.2192166 c 0.00192,1.1921857 0,17.6324454 0,17.6324454 H 11.947933 V 10.838 c 0,0 6.10676,1.037363 7.80512,3.238279 0.180102,0.233395 0,10.775383 0,10.775383 h 1.951281 L 21.704,13.017 C 21.719643,11.169234 18.492009,9.5084126 16.302239,8.6458806 13.47112,7.5307272 9.9947373,6.0270309 9.9966523,7.2192166 Z"
style="stroke:#ffffff;stroke-width:0.292319;stroke-opacity:0.80000001"
id="path3"
sodipodi:nodetypes="zcccscccsz" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

68
libc.c Normal file
View File

@ -0,0 +1,68 @@
#include "libc.h"
void mcpy(u8 *to, const u8 *from, u32 length) {
u32 i;
if (to == nil || from == nil) return;
for (i = 0; i < length; i++) {
to[i] = from[i];
}
return;
}
i32 scpy(char *to, const char *from, u32 length) {
u32 i;
if (to == nil || from == nil) return -1;
if (length == 0) {return 0;}
for (i = 0; i < length - 1 && from[i] != '\0'; i++) {
to[i] = from[i];
}
to[i] = '\0';
return 0;
}
bool seq(const char *s1, const char *s2) {
if (s1 == nil && s2 == nil) return true;
if (s1 == nil || s2 == nil) return false;
while (*s1 && *s2) {
if (*s1 != *s2) return false;
s1++;
s2++;
}
return (*s1 == '\0' && *s2 == '\0');
}
bool sleq(const char *s1, const char *s2, u32 length) {
u32 i;
if (s1 == nil && s2 == nil) return true;
if (s1 == nil || s2 == nil) return false;
i = 0;
while (i < length && *s1 && *s2) {
if (*s1 != *s2) return false;
s1++;
s2++;
i++;
}
if (i == length) return true;
return (*s1 == '\0' && *s2 == '\0');
}
u32 slen(const char *str) {
u32 i;
if (str == nil) {return 0;}
for (i = 0; str[i] != '\0'; i++) {
;
}
return i;
}
u32 snlen(const char *str, u32 max_len) {
u32 i;
if (str == nil) {return 0;}
for (i = 0; i < max_len && str[i] != '\0'; i++) {
;
}
return i;
}

33
libc.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef UNDAR_LIBC_H
#define UNDAR_LIBC_H
#include <stddef.h>
#include <stdint.h>
typedef uint8_t u8;
typedef int8_t i8;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint32_t u32;
typedef int32_t i32;
typedef float f32;
#define true 1
#define false 0
#define bool u8
#define nil NULL
#define USED(x) ((void)(x))
#define AS_INT(v) ((i32)(v))
#define AS_NAT(v) ((u32)(v))
void mcpy(u8 *dest, const u8 *src, u32 n);
i32 scpy(char* to, const char *from, u32 length);
bool seq(const char *s1, const char *s2);
bool sleq(const char *s1, const char *s2, u32 length);
u32 slen(const char *str);
u32 snlen(const char *str, u32 max_len);
#endif

0
vm.c Normal file
View File

22
vm.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef UNDAR_VM_H
#define UNDAR_VM_H
#include "libc.h"
typedef enum {
NOOP,
} Opcode;
typedef struct vm_s VM;
#define MEM_SIZE 65536
struct vm_s {
u32 pc;
u8 mem[MEM_SIZE];
};
bool init_vm(VM *vm);
bool step_vm(VM *vm);
#endif