From 039aa7e9f96ed2c3d101b54ddd63db99e4079945 Mon Sep 17 00:00:00 2001 From: zongor Date: Sat, 6 Sep 2025 11:31:59 -0700 Subject: [PATCH] =?UTF-8?q?'Undar'=20ist=20Undars=C4=8Bieppan!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LANG.md | 1 - README.org | 66 +- docs/LANG.txt | 1 + docs/MACHINE.org | 128 --- docs/SPECIFICATION.org | 185 ++--- .../{client.zrl => client.ul} | 2 +- .../{common.zrl => common.ul} | 44 +- .../{server.zrl => server.ul} | 2 +- docs/undarsċieppan-w.svg | 732 ++++++++++++++++++ docs/undarsċieppan.svg | 732 ++++++++++++++++++ test/add.asm | 17 - test/add.lisp | 20 +- test/{add.zrl => add.ul} | 0 test/fib.asm | 29 - test/fib.lisp | 36 +- test/{fib.zrl => fib.ul} | 0 test/{hello.zrl => hello.ul} | 0 test/loop.asm | 22 - test/loop.lisp | 31 +- test/{loop.zrl => loop.ul} | 0 test/{simple.asm => simple.lisp} | 0 test/{simple.zrl => simple.ul} | 0 22 files changed, 1684 insertions(+), 364 deletions(-) delete mode 100644 LANG.md create mode 100644 docs/LANG.txt delete mode 100644 docs/MACHINE.org rename docs/project-syntax-example/{client.zrl => client.ul} (95%) rename docs/project-syntax-example/{common.zrl => common.ul} (55%) rename docs/project-syntax-example/{server.zrl => server.ul} (89%) create mode 100644 docs/undarsċieppan-w.svg create mode 100644 docs/undarsċieppan.svg delete mode 100644 test/add.asm rename test/{add.zrl => add.ul} (100%) delete mode 100644 test/fib.asm rename test/{fib.zrl => fib.ul} (100%) rename test/{hello.zrl => hello.ul} (100%) delete mode 100644 test/loop.asm rename test/{loop.zrl => loop.ul} (100%) rename test/{simple.asm => simple.lisp} (100%) rename test/{simple.zrl => simple.ul} (100%) diff --git a/LANG.md b/LANG.md deleted file mode 100644 index c546ec2..0000000 --- a/LANG.md +++ /dev/null @@ -1 +0,0 @@ - "Unammed Language" is a programming language for the purpose of creating three dimensional video games and graphical user interfaces that work on constrained systems, microcontrollers, retro consoles, and the using emscripten. it conforms to permacomputing principles. 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. it is written in c eighty nine, has a cisc like instruction format of one byte opcode and three byte operand. thirty two general purpose registers, one stack for function calls, one stack for return values. zero initialized plexs are always valid. memory is managed via frame based arenas function scopes defines a memory frame. heap allocations push pointers within this frame. when a frame exits, the pointer is reset like stack based gc. values passed to functions must be explicitly returned to propagate. heap values are copy on write, so if a value is modified in a child function it will copy the parents value and append it to its own frame with the modification. it has a type system of nat, int, str, real. it also has a plex based on a generalized technique for symbol manipulation and numerical calculation by douglas ross, allows for efficient symbolic manipulation of data, works like a struct but syntactically looks like a class. versioning and shadowing when you redefine a plex, the old version is shadowed but preserved unless explicitly removed. the language is statically typed and similar to c but with some array semantic ideas from fortran like row major, fortran style replaces need for vec or mat. arrays are first class values, the compiler generates array multiplication code. also the idea of having a ref type to pass by reference similar to a pointer in c. it has a coroutine system that uses the yield keyword so it can do async operations. it has a abstraction layer for devices that work as system calls that can open, read, write, close, and use ioclt for extra system calls that are beyond ops. it has a abstraction called a tunnel that is inspired by plan nine. it allows files, web requests, sockets, etc. to be viewed through a simple unified interface attach open communication. clunk close communication. flush cancels long operation and dumps whatever is in buffer. open opens a tunnel for doing operations on. create creates the plex from the database graph file from file structure. read reads from a tunnel. write writes to a tunnel. remove removes the plex from the database graph file from file structure. stat returns the status of the file resource. version returns the version code for the connected tunnel. walk moves around the filesystem or through the graph. it has a built in three dimensional graphics engine based on and inspired by the werkkzeug3_kkrieger project. finally, it has a immidiate mode gui style ui system. goals are run on most things and preserve digital art and games forever. mit zero license or public domain with an ethical understanding this software should not be used to accelerate obsolescence, exploit users, or harm ecosystems. \ No newline at end of file diff --git a/README.org b/README.org index 90361a8..dc92a80 100644 --- a/README.org +++ b/README.org @@ -1,7 +1,7 @@ #+TITLE: A Language for Enduring Realities #+SUBTITLE: "Shape realities that outlast their makers." #+AUTHOR: Zongor -#+EMAIL: archive@zirul-lang.org +#+EMAIL: archive@undar-lang.org #+DATE: [2025-04-05] #+LANGUAGE: en #+OPTIONS: H:4 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t @@ -10,10 +10,10 @@ #+PROPERTY: header-args :tangle-mode (identity #o0644) #+BEGIN_SRC -[ᛉ · · · +[ᚢ · · · · ᚱ · · - · · ᛇ · - · · · ᛚ] + · · ᛋ · + · · · ᚾ] #+END_SRC * The Reality Engine @@ -45,8 +45,7 @@ This ensures: - Perfect reproducibility - Safe failure modes - - is a permacomputing oriented, statically-typed language with **first-class arrays**, **immediate-mode semantics**, and **symbolic clarity** +Undar is a permacomputing oriented, statically-typed language with **first-class arrays**, **immediate-mode semantics**, and **symbolic clarity** - =Constrained systems=: microcontrollers, retro consoles (PS1, N64, Mac Classic) - =Portable environments=: Web (Emscripten), embedded, CLI - =Permacomputing=: long-term survivability, sustainability, minimalism @@ -55,6 +54,8 @@ This ensures: It runs on the =Reality Engine=, a minimal C89 VM inspired by Uxn, Plan 9, and Forth - but built for =spatial software=, =deterministic execution=, and =software that lasts=. +Sċieppan is a bytecode assembler that is inspired by Webassemblys WAT format. +You can view some examples in the =.lisp= files in =/test= **Core Types** @@ -65,13 +66,13 @@ It runs on the =Reality Engine=, a minimal C89 VM inspired by Uxn, Plan 9, and F | =real= | Q16.16 fixed-point real number | | =str= | 4-byte packed string or fat pointer | | =bool= | Compile-time flag | -| =ref= | Reference type for passing by reference | +| =ref= | Reference type for passing by reference | **Array Semantics (Fortran-Style)** Arrays are **first-class values**: -#+BEGIN_SRC zrl +#+BEGIN_SRC ul real[3] pos = [1.0, 2.0, 3.0]; real[3][3] mat = identity(3); real[3] result = mat * pos; ! compiler generates matrix-vector multiply @@ -86,7 +87,7 @@ real[3] result = mat * pos; ! compiler generates matrix-vector multiply Flags are compiled into **parallel arrays** (like =MultiArrayList=): -#+BEGIN_SRC zrl +#+BEGIN_SRC ul bool[] player_alive; real[3][] player_pos; str[] player_name; @@ -101,7 +102,7 @@ This enables: A =plex= is a **Platonic form** - a structured definition of a kind of being in your program. -#+BEGIN_SRC zrl +#+BEGIN_SRC ul plex Player { version 1; str name; @@ -127,7 +128,7 @@ plex Player { When you redefine a =plex=, the old version is **shadowed but preserved** - unless explicitly discarded. -#+BEGIN_SRC zrl +#+BEGIN_SRC ul plex Counter { version 1; nat value; inc() { value += 1; } } plex Counter { version 2; nat value; inc() { value += 2; } } ! shadows v1 @@ -186,7 +187,7 @@ A =Tunnel= unifies: - Devices - Databases -#+BEGIN_SRC zrl +#+BEGIN_SRC ul Tunnel server = Tunnel("tcp://localhost:25565"); if (server.attach(auth)) { Player[] players = server.read("players"); @@ -197,16 +198,17 @@ if (server.attach(auth)) { **Tunnel Operations** -| Op | Meaning | -|------------|--------------------------------------| -| =.attach()= | Authenticate and open | -| =.open()= / =.create()= | Access/create resource | -| =.read()= / =.write()= | Transfer data | -| =.walk()= | Navigate hierarchy | -| =.flush()= | Cancel long operation | -| =.clunk()= | Close connection | -| =.stat()= | Get metadata | -| =.version()=| Get protocol version | +| Op | Meaning | +|------------|-------------------------| +| =.attach()= | Authenticate and open | +| =.open()= | Open resource | +| =.read()= |Transfer data | +| =.write()= | Transfer data | +| =.walk()= | Navigate hierarchy | +| =.flush()= | Cancel long operation | +| =.clunk()= | Close connection | +| =.stat()= | Get metadata | +| =.version()=| Get protocol version | Tunnels make I/O **uniform, composable, and archival**. @@ -236,12 +238,12 @@ Tunnels make I/O **uniform, composable, and archival**. git clone https://git.alfrescocavern.com/zongor/reality-engine.git cd reality-engine make -./zre client.zrl +./zre client.ul #+END_SRC -**Sample Program: =hello.zrl=** +**Sample Program: =hello.ul=** -#+BEGIN_SRC zrl +#+BEGIN_SRC ul function main(int argc, str[] argv) { str name = argc > 1 ? argv[1] : "World"; print("Hello, {name}!"); @@ -252,14 +254,14 @@ function main(int argc, str[] argv) { Run it: #+BEGIN_SRC sh -./zre hello.zrl Alice +./zre hello.ul Alice # Output: Hello, Alice! #+END_SRC -* Example: 3D Client (=client.zrl=) +* Example: 3D Client (=client.ul=) -#+BEGIN_SRC zrl -use "common.zrl"; +#+BEGIN_SRC ul +use "common.ul"; function main(int argc, str[] argv) { nat w = 800, h = 450; @@ -306,7 +308,7 @@ function main(int argc, str[] argv) { - Versioned plexes: forward/backward compatibility - Self-documenting syntax: just enough magic - Open standard: no vendor lock-in -- Archive formats: =.zrl=, =.zbin=, =.zatom= +- Archive formats: =.ul=, =.zbin=, =.zatom= * License @@ -343,6 +345,6 @@ The Reality Engine is a community project. We welcome: * Contact - - Website: https://zirul-lang.org - - Email: archive@zirul-lang.org + - Website: https://undar-lang.org + - Email: archive@undar-lang.org - Repository: https://git.alfrescocavern.com/zongor/reality-engine.git diff --git a/docs/LANG.txt b/docs/LANG.txt new file mode 100644 index 0000000..b0e79c9 --- /dev/null +++ b/docs/LANG.txt @@ -0,0 +1 @@ +undar is a programming language for the purpose of creating three dimensional video games and graphical user interfaces that work on constrained systems, microcontrollers, retro consoles, and the using emscripten. it conforms to permacomputing principles. 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. it is written in c eighty nine, has a cisc like instruction format of one byte opcode and three byte operand. thirty two general purpose registers, one stack for function calls, one stack for return values. zero initialized plexs are always valid. memory is managed via frame based arenas function scopes defines a memory frame. heap allocations push pointers within this frame. when a frame exits, the pointer is reset like stack based gc. values passed to functions must be explicitly returned to propagate. heap values are copy on write, so if a value is modified in a child function it will copy the parents value and append it to its own frame with the modification. it has a type system of nat, int, str, real. it also has a plex based on a generalized technique for symbol manipulation and numerical calculation by douglas ross, allows for efficient symbolic manipulation of data, works like a struct but syntactically looks like a class. versioning and shadowing when you redefine a plex, the old version is shadowed but preserved unless explicitly removed. the language is statically typed and similar to c but with some array semantic ideas from fortran like row major, fortran style replaces need for vec or mat. arrays are first class values, the compiler generates array multiplication code. also the idea of having a ref type to pass by reference similar to a pointer in c. it has a coroutine system that uses the yield keyword so it can do async operations. it has a abstraction layer for devices that work as system calls that can open, read, write, close, and use ioclt for extra system calls that are beyond ops. it has a abstraction called a tunnel that is inspired by plan nine. it allows files, web requests, sockets, etc. to be viewed through a simple unified interface attach open communication. clunk close communication. flush cancels long operation and dumps whatever is in buffer. open opens a tunnel for doing operations on. create creates the plex from the database graph file from file structure. read reads from a tunnel. write writes to a tunnel. remove removes the plex from the database graph file from file structure. stat returns the status of the file resource. version returns the version code for the connected tunnel. walk moves around the filesystem or through the graph. goals are run on most things and preserve digital art and games forever. mit zero license or public domain with an ethical understanding this software should not be used to accelerate obsolescence, exploit users, or harm ecosystems. \ No newline at end of file diff --git a/docs/MACHINE.org b/docs/MACHINE.org deleted file mode 100644 index 56b429e..0000000 --- a/docs/MACHINE.org +++ /dev/null @@ -1,128 +0,0 @@ -* machine -:PROPERTIES: -:CUSTOM-ID: machine -:END: - -** memory -:PROPERTIES: -:CUSTOM-ID: memory -:END: - -one large uint32 array - -** types -:PROPERTIES: -:CUSTOM-ID: types -:END: -real (floating point number) f32 -int (integer) i32 -nat (unsigned integer) u32 - - 3-3-2 bit rgb -:PROPERTIES: -:CUSTOM-ID: bit-rgb -:END: -rrrg ggbb xxxx yyyy - -triangles - -textures - - devices -:PROPERTIES: -:CUSTOM-ID: devices -:END: -** screen -:PROPERTIES: -:CUSTOM-ID: screen -:END: -default screen is a single 2 triangle square face with a single dynamic -texture that can be drawn on it - -** keyboard -:PROPERTIES: -:CUSTOM-ID: keyboard -:END: -ASCIIUTF8 encoded values - -** mousejoystick -:PROPERTIES: -:CUSTOM-ID: mousejoystick -:END: -Theoretically a modern controller could be mapped into 3 mousejoystick -devices - -A nes controller could be mapped onto 1 mousejoystick device - -x axis -> J1 -> J2 -> Dpad leftright y axis -> J1 -> J2 -> Dpad updown -button 1 -> A -> t1 -> select button 2 -> B -> t2 -> start button 3 -> X --> b2 -> "meta button like controller start" button 4 -> Y -> b2 -> -unused - -xxxx yyyy 1234 - -x (4 bits) y (4 bits) 1 is button 1 pressed? 2 is button 2 pressed? 3 is -button 3 pressed? 4 is button 4 pressed? - -** soundmusic -:PROPERTIES: -:CUSTOM-ID: soundmusic -:END: -This one is going to be the hardest most likely| but its prolly going to -be something like the backend dac for ORCA. - -** networkfilesystem -:PROPERTIES: -:CUSTOM-ID: networkfilesystem -:END: -9p filesystemnetwork by default. - -Have an easy way to network. - -** opcodes - -|----------------+------------------------------------------------------| -| opcode | description | -|----------------+------------------------------------------------------| -| HALT | terminate execution | -| ADD-INT | dest = src1 + src2 | -| SUB-INT | dest = src1 - src2 | -| MUL-INT | dest = src1 src2 | -| DIV-INT | dest = src1 src2 | -| JEQ-INT | jump to address dest if src1 as int == src2 as int | -| JGT-INT | jump to address dest if src1 as int > src2 as int | -| JLT-INT | jump to address dest if src1 as int < src2 as int | -| JLE-INT | jump to address dest if src1 as int <= src2 as int | -| JGE-INT | jump to address dest if src1 as int >= src2 as int | -| INT-TO-REAL | dest = src1 as f32 | -| ADD-UINT | dest = src1 + src2 | -| SUB-UINT | dest = src1 - src2 | -| MUL-UINT | dest = src1 src2 | -| DIV-UINT | dest = src1 src2 | -| JEQ-UINT | jump to address dest if src1 as int == src2 as uint | -| JGT-UINT | jump to address dest if src1 as int > src2 as uint | -| JLT-UINT | jump to address dest if src1 as int < src2 as uint | -| JLE-UINT | jump to address dest if src1 as int <= src2 as uint | -| JGE-UINT | jump to address dest if src1 as int >= src2 as uint | -| UINT-TO-REAL | dest = src1 as f32 | -| ADD-REAL | dest = src1 + src2 | -| SUB-REAL | dest = src1 - src2 | -| MUL-REAL | dest = src1 src2 | -| DIV-REAL | dest = src1 src2 | -| JEQ-REAL | jump to address dest if src1 as real == src2 as real | -| JGE-REAL | jump to address dest if src1 as real >= src2 as real | -| JGT-REAL | jump to address dest if src1 as real > src2 as real | -| JLT-REAL | jump to address dest if src1 as real < src2 as real | -| JLE-REAL | jump to address dest if src1 as real <= src2 as real | -| REAL-TO-INT | dest = src1 as int | -| REAL-TO-UINT | dest = src1 as int | -| MOV | dest = src1 | -| JMP | jump to address src1 unconditionally | -| INT-TO-STRING | dest = src1 as str | -| UINT-TO-STRING | dest = src1 as str | -| REAL-TO-STRING | dest = src1 as str | -| READ-STRING | dest = read as str | -| PRINT-STRING | write src1 to stdout | -| CMP-STRING | dest = src1 as str == src2 as str | -| | | -|----------------+------------------------------------------------------| diff --git a/docs/SPECIFICATION.org b/docs/SPECIFICATION.org index 61115a5..00770f1 100644 --- a/docs/SPECIFICATION.org +++ b/docs/SPECIFICATION.org @@ -1,51 +1,54 @@ -* /ZRL/ (Reality Engine Language) Design parameters +* /Undar/ (Reality Engine Language) Design parameters :PROPERTIES: -:CUSTOM_ID: zrl-zongors-reality-engine-language-design-parameters +:CUSTOM_ID: Undar-zongors-reality-engine-language-design-parameters :END: -** What is /zrl/? +** What is /Undar/? :PROPERTIES: -:CUSTOM_ID: what-is-zrl +:CUSTOM_ID: what-is-undar :END: -/zrl/ is an domain specific language for 3D games with C/Lua style syntax. +/Undar/ is an permacomputing oriented programming language for 3D games with C style syntax. The compiler is written in C which should make it easy to port to other systems. -* /ZRL/ Grammar and Specification -:PROPERTIES: -:CUSTOM_ID: zrl-grammar-and-specification -:END: -** Types -:PROPERTIES: -:CUSTOM_ID: types -:END: -- there are also a list of "substantial types" which come with the - language which are the building blocks for more complex types. If you - are coming from object oriented languages you can think of self as - "primitive types" +It is short for "Undarsċieppan" The name comes from the Proto-West-Germanic word [[https://en.wiktionary.org/wiki/Reconstruction:Proto-Germanic/under][Undar]], which means "under" and [[https://en.wiktionary.org/wiki/scieppan][Sċieppan]] meaning "to create". It inspired by the idea of "Sub-creation" from Tolkien and C.S. Lewis, that the developer is sub-creating a reality for their users, whether it be a video game, office software, a website, or a embedded driver. -- Note that these look like classes but act like structs - the methods actually have a implied struct as their first argument +* /Undar/ Grammar and Specification +:PROPERTIES: +:CUSTOM_ID: undar-grammar-and-specification +:END: +** Plexs +:PROPERTIES: +:CUSTOM_ID: plexs +:END: +- A =plex= is a **Platonic form** - a structured definition of a kind of being in your program. +- Not a class: no inheritance, no vtables +- Methods are functions with implicit =this= argument +- Instances are **atoms** - persistent, versioned, serializable +- Stored in the internal graph +- "A plex defines what a thing is. An atom is its instance in that reality." +- there are also a list of "substantial plexs" which come with the + language which are the building blocks for more complex types called "Plexes". If you are coming from object oriented languages you can think of self as "primitive types" -#+begin_src zrl -type «token» { +#+begin_src ul +plex «token» { init() { // values } } ! example -type Vec3 { +plex Vec3 { init(x real, y real, z real) { this.x = x; this.y = z; this.y = z; } } -#+end_src zrl +#+end_src ul -* Basic Types +* Substantial Plexs :PROPERTIES: -:CUSTOM_ID: substantial-types +:CUSTOM_ID: substantial-plexs :END: ** numeric :PROPERTIES: @@ -97,11 +100,11 @@ string interpolation :CUSTOM_ID: array :END: -Array of a specific type +Array of a specific plex -#+begin_src zrl -«type»[«length»] «variable» = [val1, val2, ...]; -#+end_src zrl +#+begin_src ul +«plex»[«length»] «variable» = [val1, val2, ...]; +#+end_src ul *** Tunnel :PROPERTIES: @@ -191,56 +194,56 @@ The following is a list of global operators and their effect: let operator -#+begin_src zrl +#+begin_src ul let «token» = true; -#+end_src zrl +#+end_src ul =is= -checks if a object is of that type +checks if a atom is of that plex -#+begin_src zrl +#+begin_src ul if («token» is real) { print("hello yes self is a real?"); } -#+end_src zrl +#+end_src ul also used for letting constants =as= -coerces a type as another type if possible +coerces a plex as another plex if possible -#+begin_src zrl +#+begin_src ul let «token» = 0; ! default is int some_functon(«token» as real); ! needs a real -#+end_src zrl +#+end_src ul =in= -checks if a object's type, or a type implements a contract +checks if a atom's plex, or a plex implements a contract -#+begin_src zrl +#+begin_src ul if («token» in Tunnel, Drawable) { print("im tunnel-able and draw-able"); } -#+end_src zrl +#+end_src ul also used inside of the for loops -#+begin_src zrl +#+begin_src ul for («token» in «collection») { «body» } -#+end_src zrl +#+end_src ul -** Object +** Atom :PROPERTIES: -:CUSTOM_ID: object +:CUSTOM_ID: atom :END: -An object is an invoked type. +An atom is an invoked plex. -#+begin_src zrl -let «variable» = «type»(«fields», …); -#+end_src zrl +#+begin_src ul +let «variable» = «plex»(«fields», …); +#+end_src ul ** Tunnel :PROPERTIES: @@ -252,49 +255,49 @@ a socket, etc.) Tunnels are inspired by translators in gnu/hurd, plan9 9p protocol, and unix sockets -tunnels are invoked like objects, but have scope like control flow end +tunnels are invoked like atoms, but have scope like control flow end scope closes the tunnel -note the type must always be of a type which is "tunnel-able" +note the plex must always be of a plex which is "tunnel-able" i.e. Files, sockets, etc Tunnels have almost the same interface as 9p since they are closely based on 9p. -*** transtypes for tunnels +*** transplexs for tunnels :PROPERTIES: -:CUSTOM_ID: transtypes-for-tunnels +:CUSTOM_ID: transplexs-for-tunnels :END: -=tunnel? : attach(tunnel_object)= -> open communication +=tunnel? : attach(tunnel_atom)= -> open communication -=success? : tunnel_object.clunk()= -> close communication +=success? : tunnel_atom.clunk()= -> close communication -=success? : tunnel_object.flush()= -> cancels long operation and dumps +=success? : tunnel_atom.flush()= -> cancels long operation and dumps whatever is in buffer -=success? : tunnel_object.open(resource, mode)= -> opens a tunnel for +=success? : tunnel_atom.open(resource, mode)= -> opens a tunnel for doing operations on -=success? : tunnel_object.create(resource)= -> creates the object from +=success? : tunnel_atom.create(resource)= -> creates the atom from the database graph/file from file structure -=data? : tunnel_object.read(resource)= -> reads from a tunnel +=data? : tunnel_atom.read(resource)= -> reads from a tunnel -=success? : tunnel_object.write(resource, data)= -> writes to a tunnel +=success? : tunnel_atom.write(resource, data)= -> writes to a tunnel -=success? : tunnel_object.remove(resource)= -> removes the object from +=success? : tunnel_atom.remove(resource)= -> removes the atom from the database graph/file from file structure -=stat_data? : tunnel_object.stat(resource)= -> returns the status of the +=stat_data? : tunnel_atom.stat(resource)= -> returns the status of the file/resource -=version? : tunnel_object.version()= -> returns the version code for the +=version? : tunnel_atom.version()= -> returns the version code for the connected tunnel -=success? : tunnel_object.walk(path_or_endpoint)= -> moves around the +=success? : tunnel_atom.walk(path_or_endpoint)= -> moves around the filesystem or through the graph -#+begin_src zrl +#+begin_src ul ! client let endpoint = Client("tcp://path/to/source"); let tunnel = endpoint.attach(user, auth); @@ -309,24 +312,24 @@ s.bind("/some/resource", fn () str { return "hello world"; }) server.start(); -#+end_src zrl +#+end_src ul ** Functions :PROPERTIES: :CUSTOM_ID: functions :END: Functions are all typechecked statically at compile time. Since we -always have a "default type" for all constant values or a developer can +always have a "default plex" for all constant values or a developer can use the =as= keyword we do not have to define all values like in C, -while keeping the same type safety as a more strongly typed language. +while keeping the same plex safety as a more strongly typed language. -#+begin_src zrl -fn «token» («parameter» «type», ...) «return_type» { +#+begin_src ul +fn «token» («parameter» «plex», ...) «return_plex» { «body» } -#+end_src zrl +#+end_src ul -- Built in transtypes +- Built in transplexs - sort - filter - trig functions @@ -341,21 +344,21 @@ fn «token» («parameter» «type», ...) «return_type» { :PROPERTIES: :CUSTOM_ID: loops :END: -#+begin_src zrl +#+begin_src ul for («variable» in «collection») { «body» } -#+end_src zrl +#+end_src ul -iterates through each object in the collection setting it to variable +iterates through each atom in the collection setting it to variable -#+begin_src zrl +#+begin_src ul while («boolean expression») { «body» } -#+end_src zrl +#+end_src ul loops until the expression is false -#+begin_src zrl +#+begin_src ul do («variable» = initial_value, end_value, increment) { «body» } -#+end_src zrl +#+end_src ul loops from initial value to end value by increment value (like a for loop in other languages) @@ -363,7 +366,7 @@ loops from initial value to end value by increment value (like a for loop in oth :PROPERTIES: :CUSTOM_ID: branching :END: -#+begin_src zrl +#+begin_src ul if («boolean expression») { } else if («boolean expression») { @@ -371,16 +374,16 @@ if («boolean expression») { } else { } -#+end_src zrl +#+end_src ul -#+begin_src zrl +#+begin_src ul switch (value) { case A: case B: case C: default: } -#+end_src zrl +#+end_src ul ** Error handling :PROPERTIES: @@ -389,7 +392,7 @@ switch (value) { Error handling is much like in C/C++ where a try catch can be used. -#+begin_src zrl +#+begin_src ul let rr = nil; let var = rr ?? 0; ! value is 0 try { @@ -398,7 +401,7 @@ try { } catch (e) { print("Caught error ${e}"); } -#+end_src zrl +#+end_src ul ** Localization :PROPERTIES: @@ -406,9 +409,9 @@ try { :END: will look up the text of «token» in the linked localization.json file -#+begin_src zrl +#+begin_src ul #«token» -#+end_src zrl +#+end_src ul #+begin_src json { @@ -429,9 +432,9 @@ will look up the text of «token» in the linked localization.json file In most languages the include or use statements get libraries which link to other files and so on. -#+begin_src zrl -use "./some_local_file.zrl" -#+end_src zrl +#+begin_src ul +use "./some_local_file.Undar" +#+end_src ul ** Testing :PROPERTIES: @@ -441,9 +444,9 @@ use "./some_local_file.zrl" :PROPERTIES: :CUSTOM_ID: assertion :END: -#+begin_src zrl +#+begin_src ul assert(«expression», «expected output») ! returns «error or none» -#+end_src zrl +#+end_src ul ** Measurements :PROPERTIES: diff --git a/docs/project-syntax-example/client.zrl b/docs/project-syntax-example/client.ul similarity index 95% rename from docs/project-syntax-example/client.zrl rename to docs/project-syntax-example/client.ul index 0c7550c..2b3de0d 100644 --- a/docs/project-syntax-example/client.zrl +++ b/docs/project-syntax-example/client.ul @@ -1,6 +1,6 @@ use "common.ztl"; -function main(argc int, argv str[]) { +function main(int argc, str[] argv) { nat screen_width = 800; nat screen_height = 450; diff --git a/docs/project-syntax-example/common.zrl b/docs/project-syntax-example/common.ul similarity index 55% rename from docs/project-syntax-example/common.zrl rename to docs/project-syntax-example/common.ul index c58778a..cfed377 100644 --- a/docs/project-syntax-example/common.zrl +++ b/docs/project-syntax-example/common.ul @@ -1,11 +1,11 @@ -! -! Note that these look like classes but act like structs -! the methods actually have a implied struct as their first argument -! +/** + * Note that these look like classes but act like structs + * the methods actually have a implied struct as their first argument + */ -! -! Camera . -! +/** + * Camera. + */ plex Camera { init(real[3] pos, real[3] look) { this.setting = "CAMERA_PERSPECTIVE"; @@ -16,12 +16,12 @@ plex Camera { } } -! -! Player . -! +/** + * Player. + */ plex Player { init(str username, real[3] pos, Color color) { - this.server = Client("tcp://localhost:25565"); + this.client = Client("tcp://localhost:25565"); this.username = username; this.pos = pos; this.color = color; @@ -30,35 +30,35 @@ plex Player { } login(str password) Player[] { ! looks like a method but really it just has an implied "Player this" as the first argument - this.server.attach(this.username, password); - this.players = server.open("players"); + this.client.attach(this.username, password); + this.players = client.open("players"); return players.read(); } logout() { this.players.flush(); - this.server.clunk(); + this.client.clunk(); } update() { if (key_down("right")) { - this.pos.x = this.pos.x + 0.2; - this.server.write(Command(this.username, KEY_RIGHT)) + this.pos.x += 0.2; + this.client.write(Command(this.username, KEY_RIGHT)) } if (key_down("left")) { - this.pos.x = this.pos.x - 0.2; - this.server.write(Command(this.username, KEY_LEFT)) + this.pos.x -= 0.2; + this.client.write(Command(this.username, KEY_LEFT)) } if (key_down("down")) { - this.pos.z = this.pos.z + 0.2; - this.server.write(Command(this.username, KEY_DOWN)) + this.pos.z += 0.2; + this.client.write(Command(this.username, KEY_DOWN)) } if (key_down("up")) { - this.pos.z = this.pos.z - 0.2; - this.server.write(Command(this.username, KEY_UP)) + this.pos.z -= 0.2; + this.client.write(Command(this.username, KEY_UP)) } this.camera.sync(); } diff --git a/docs/project-syntax-example/server.zrl b/docs/project-syntax-example/server.ul similarity index 89% rename from docs/project-syntax-example/server.zrl rename to docs/project-syntax-example/server.ul index 9acc9ed..7b24a72 100644 --- a/docs/project-syntax-example/server.zrl +++ b/docs/project-syntax-example/server.ul @@ -3,7 +3,7 @@ use "common.ztl"; function main(int argc, str[] argv) { Server s("tcp://0.0.0.0:25565"); bool running = true; - Player[] players = [Player("user", [0., 0., 0.], RED)]; + Player[] players = [Player("user", [0.0, 0.0, 0.0], RED)]; while (running) { if (Client client = s.accept("players")) { if (Message message = client.get()) { diff --git a/docs/undarsċieppan-w.svg b/docs/undarsċieppan-w.svg new file mode 100644 index 0000000..fe6eda8 --- /dev/null +++ b/docs/undarsċieppan-w.svg @@ -0,0 +1,732 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/undarsċieppan.svg b/docs/undarsċieppan.svg new file mode 100644 index 0000000..a472393 --- /dev/null +++ b/docs/undarsċieppan.svg @@ -0,0 +1,732 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/add.asm b/test/add.asm deleted file mode 100644 index 195b158..0000000 --- a/test/add.asm +++ /dev/null @@ -1,17 +0,0 @@ -main: - lodi $0 1 ;load 1 into r0 - pshi $0 ;push onto stack - lodi $0 1 ;1 - pshi $0 - call &add ; call memory location for tag "add" - popi $0 ;get value from function call "add" - itos $1 $0 ;convert int to string - puts $1 ;print string to stdout - halt - -add: - popi $0 ; int a - popi $1 ; int b - addi $2 $1 $0 ; a + b - pshi $2 - retn ; actually do the return diff --git a/test/add.lisp b/test/add.lisp index 9c35da9..195b158 100644 --- a/test/add.lisp +++ b/test/add.lisp @@ -1,5 +1,17 @@ -(defun add (int a int b) - (return (+ a b))) +main: + lodi $0 1 ;load 1 into r0 + pshi $0 ;push onto stack + lodi $0 1 ;1 + pshi $0 + call &add ; call memory location for tag "add" + popi $0 ;get value from function call "add" + itos $1 $0 ;convert int to string + puts $1 ;print string to stdout + halt -(let ((sum (add 1 1))) - (print (itos sum))) +add: + popi $0 ; int a + popi $1 ; int b + addi $2 $1 $0 ; a + b + pshi $2 + retn ; actually do the return diff --git a/test/add.zrl b/test/add.ul similarity index 100% rename from test/add.zrl rename to test/add.ul diff --git a/test/fib.asm b/test/fib.asm deleted file mode 100644 index 14810c7..0000000 --- a/test/fib.asm +++ /dev/null @@ -1,29 +0,0 @@ -main: - lodi $0 35 - pshi $0 - call &fib - popi $0 - itos $1 $0 - puts $1 - halt -fib: - popi $0 - lodi $1 2 - lodi $2 &base_case - jlti $2 $0 $1 - lodi $2 2 - subi $4 $0 $3 - pshi $4 - call &fib - lodi $2 1 - subi $4 $0 $3 - pshi $4 - call &fib - popi $4 - popi $5 - addi $6 $5 $4 - pshi $6 - retn -base_case: - pshi $0 - retn diff --git a/test/fib.lisp b/test/fib.lisp index 123a13e..14810c7 100644 --- a/test/fib.lisp +++ b/test/fib.lisp @@ -1,7 +1,29 @@ -(defun fib (int n) - (if (n < 2) - (return n) - (return (+ (fib (- n 2)) - (fib (- n 1)))))) - -(puts (itos (fib 35))) +main: + lodi $0 35 + pshi $0 + call &fib + popi $0 + itos $1 $0 + puts $1 + halt +fib: + popi $0 + lodi $1 2 + lodi $2 &base_case + jlti $2 $0 $1 + lodi $2 2 + subi $4 $0 $3 + pshi $4 + call &fib + lodi $2 1 + subi $4 $0 $3 + pshi $4 + call &fib + popi $4 + popi $5 + addi $6 $5 $4 + pshi $6 + retn +base_case: + pshi $0 + retn diff --git a/test/fib.zrl b/test/fib.ul similarity index 100% rename from test/fib.zrl rename to test/fib.ul diff --git a/test/hello.zrl b/test/hello.ul similarity index 100% rename from test/hello.zrl rename to test/hello.ul diff --git a/test/loop.asm b/test/loop.asm deleted file mode 100644 index f76753a..0000000 --- a/test/loop.asm +++ /dev/null @@ -1,22 +0,0 @@ -main: - lodr $0 5.0 - lodi $1 50000 - lodi $2 0 - lodi $3 -1 -loop_body: - lodr $5 5.0 - addr $0 $0 $5 - addi $1 $1 $3 - lodu $4 &loop_body - jgei $4 $1 $2 - rtou $1 $0 - strs "Enter a string:" - ladu $5 0 - puts $5 - gets $2 - utos $3 $1 - puts $3 - rtos $3 $0 - puts $3 - puts $2 - halt diff --git a/test/loop.lisp b/test/loop.lisp index 0ffd116..f76753a 100644 --- a/test/loop.lisp +++ b/test/loop.lisp @@ -1,9 +1,22 @@ -(let ((a 5.0)) - (do (i (5000 0 -1)) - (set a (+ a 5.0))) - (let ((b (itou a))) - (puts "Enter a string:") - (let ((user-string (gets))) - (puts (rtos a)) - (puts (utos b)) - (puts user-string)))) +main: + lodr $0 5.0 + lodi $1 50000 + lodi $2 0 + lodi $3 -1 +loop_body: + lodr $5 5.0 + addr $0 $0 $5 + addi $1 $1 $3 + lodu $4 &loop_body + jgei $4 $1 $2 + rtou $1 $0 + strs "Enter a string:" + ladu $5 0 + puts $5 + gets $2 + utos $3 $1 + puts $3 + rtos $3 $0 + puts $3 + puts $2 + halt diff --git a/test/loop.zrl b/test/loop.ul similarity index 100% rename from test/loop.zrl rename to test/loop.ul diff --git a/test/simple.asm b/test/simple.lisp similarity index 100% rename from test/simple.asm rename to test/simple.lisp diff --git a/test/simple.zrl b/test/simple.ul similarity index 100% rename from test/simple.zrl rename to test/simple.ul