- Shell 100%
| compiler | Nested procedures. | |
| doc | Nested procedures. | |
| examples | Nested procedures. | |
| local | Introducing SAY. | |
| modules | Initial commit. Edits and additions. | |
| repl | Item and Base revisited. | |
| run | Initial commit. Edits and additions. | |
| snapshot | Nested procedures. | |
| LICENSE.txt | Initial commit. Edits and additions. | |
| now | Item and Base revisited. | |
| oberon.txt | Nested procedures. | |
| README.md | Item and Base revisited. | |
Kiran Oberon Compiler.
Kiran is (not yet / would like to be) a compiler for the Oberon-7 programming language.
Kiran generates a Linux ELF x86_64 executabe, that can be directly executed without further processing.
It does not need any other compiler or linker.
At the current state Kiran looks like Oberon
and to me it feels like Oberon,
but it is not:
ALGOL-60 style heap allocation,
Pascal style type checks,
Modula-2 style modules and
Oberon style type extensions
are not implemented, yet.
In other words, current compiler stage is thereabout FORTRAN-59.
Goal
Oberon-7
Small fast simple.
True ELF compiler.
Inspired by hO: Build your own customized Oberon compiler, that fits your needs.
-
Stay close to Oberon-7.
-
Be cautious with introducing new features.
What it can already do.
Self-hosting.
Compile to a Linux-ELF-binary.
See examples and the compiler itself.
What needs to be done and differences to Oberon-7.
See doc/kiran-oberon-compiler-report.txt.
Not intended or out of scope.
-
Separate compilation.
-
Garbage collection actually is on our wishlist, but not now.
-
Windows support.
System requirements.
Linux
Intel/AMD x86_64.
Usage.
cd kiran
compiler/kiran-dev <source> <dest>
Does it work?
Kirans bootstrap compiler was written in Oberon for vishaps/voc. Along the way the bootstrap compiler lost track of the current compiler: it is no longer able to compile the Kiran compiler.
As such, in order to get Kiran going at the current stage of development,
the prebuilt binary kiran-dev is needed to compile kiran-dev.obn
to a new kiran-dev-1.
./now # Print usage info for bash script 'now'.
./now test # Compile and test compiler.
./now hello # Compile and run hallo-program.
./now test-dev # Compile and test compiler and example programs.
Licence.
;=============================================================================
; Kiran Oberon Compiler
; GNU GENERAL PUBLIC LICENSE, Version 3.0, http://www.gnu.org/licenses/
; https://codeberg.org/sts-q/kiran
; Copyright (C) 2023 sts-q
; https://sts-q.codeberg.page
;=============================================================================
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;=============================================================================
Links.
-
Wirth
-
hO
-
fasm agner linux-syscalls intel-instr linux-errno-messages
-
Nils M Holm
-
SmithForth
-
radare2
Acknowledgments.
dsar norayr et.al.
Summary and Conclusion.
It's fun.
It's pain.
It's a lot a better feeling to head for a well designed and time tested system instead of creating you own language: own langage creating is fun, too, but you are stuck with your own mess from then on.
Generating code for x86-64 is less complicated than expected. We are already quite fast, although the generated code uses a very simple model and needs a lot more work or a maybe a complete rewrite.
Fast compilation is always a plus.
Using Linux syscalls directly is simple and super straight forward in comparision to the interfacing C trouble. Of cause, for the time being, we are limited to what Linux provides at assembly level syscalls.
Although Kiran is by far not a complete Oberon-7 it is quite powerfull. On a multi-GB-system we can get far without pointers and dynamic mem allocation.
Although there is literaly no type checking at all, Kiran does a surprisingly lot of helpfull code checks already.
All in all it is a very interesting experience.
2023-November
After a four month break I am impressed that this thing works at all and even more that it works so good.
This revision focused on the compilers first chapters, everything before the real compiler core.
Next time we should no longer cricle around the difficult parts but go ahead with type checks and more.
For some serious hobbists work, implementation of modules is essential.
Contact.
Ping sts-q at libera.chat #oberon.
This repository was created at 2023-June-04.