https://github.com/stenbror/activeoberon
Native 64bits ActiveOberon compiler for ARM v8 and x86-64 with inline assembler.
https://github.com/stenbror/activeoberon
Last synced: 9 months ago
JSON representation
Native 64bits ActiveOberon compiler for ARM v8 and x86-64 with inline assembler.
- Host: GitHub
- URL: https://github.com/stenbror/activeoberon
- Owner: stenbror
- License: gpl-3.0
- Created: 2023-11-12T16:25:44.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-21T00:06:24.000Z (over 2 years ago)
- Last Synced: 2025-04-09T14:22:30.149Z (about 1 year ago)
- Language: Rust
- Size: 372 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ActiveOberon
Native 64-bit ActiveOberon compiler for ARM v8 and x86-64 with inline assembler under Linux, Mac OS, and Windows.
I am starting to write the compiler front end. That is a scanner and parser with a symbol table handler and driver for taking commands from the command line.
In addition, it will be UnitTests for all scanners and parser and symbol tables before I move on to build the backend for ARM and X86-64 and also the inline
assembler will be added later.
I am just starting this project, so you will have very little to do with the compiler for quite some time. The compiler is expected to run only under Linux at this time.
I first started this product in C++ but will use Rust instead for ease of testing and building the project. C++ does not have any good build system and testing frameworks.
Rust also has enum types that replace a lot of C++ classes in Symbols and Nodes.
## Building the bootstrap compiler in Rust
I also write a bootstrap compiler in Rust that can bootstrap the final compiler written in ActiveOberon later in a three-step build of the final compiler.
To build it and execute its unit tests follow the below instructions:
Install a rust build system, if you don't already have one on your computer. Easy install by executing the following command under Linux and Mac OS 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh' ,
on Windows search internet for 'rustup'. About every 6 weeks, the build system is updated and you just run 'rustup update' to get the latest version.
cd active_oberon_compiler
cargo build
cargo test
cargo run
For now, you can create a small Active Oberon program and check its syntax with the command 'active_oberon_compiler compile test.mod' , you need to write the test.mod file and place it in the same directory as the executable.
Even if the final compiler will be written in ActiveOberon language, it will need to be compiled the first time by the bootstrap compiler written in Rust and also maybe
a version written in C++. This Rust-based bootstrap compiler will be fully functional and contain all the functions of the final one. You can choose to use the bootstrap
compiler instead of the final product if you like.
### To build an optimized release version ( Simply an early version only! )
cargo build --release
strip ./target/release/active_oberon_compiler
just execute the resulting file:
ls -la target/release
target/release/active_oberon_compiler ( Executes the compiler as is at the moment, not producing anything! )
## What is Active Oberon
Active Oberon is the latest member of the Algol family of languages. Derived directly from the language Oberon (-2) and languages such as Modula, Pascal, etc.
I will first write a complete compiler/linker/build system with an inline assembler for ARM v8 and X86-64 instruction sets. With it, a minimum of support
libraries as source code will be compiled and optimized each time you create your own programs. The design goal is to remove waste and bloated executables
that most languages and systems are used to now.
Code will be native and optimized with only the library functions you need to be packed into a single executable file in ELF format.
If we get enough interest for the project, I am thinking about writing the compiler/linker / build tool in Active Oberon later, and using the Rust version as
a bootstrap for the real compiler and system. Regardless will the Rust version be as complete as the final product? It will be up to you which you will use and
all libraries will be available without changes for both.
Active Oberon is a highly typed and garbage-collected language for system programming.
## Bootstrapping the system in the future
* You will first compile the Rust version of the Active Oberon compiler/linker / build tool.
* Then you will build the Active Oberon-based compiler with the help of the Rust bootstrap compiler.
* Finally you will use the finished Active Oberon-based compiler to build itself and you have the final product.
## Language overview
This is not a full description of the language, but a good start for understanding what the language Active Oberon is all about.
### Reserved keywords
ASYNC BEGIN BY CONST CASE
CELL CELLNET CODE DO DIV
END ENUM ELSE ELSIF EXIT
EXTERN FALSE FOR FINALLY IF
IGNORE IMAG IN IS IMPORT
LOOP MODULE MOD NIL OF
OR OUT OPERATOR PROCEDURE PORT
REPEAT RETURN SELF NEW RESULT
THEN TRUE TO TYPE UNTIL
VAR WHILE WITH
ARRAY OBJECT POINTER RECORD ADDRESS SIZE ALIAS
All reserved keywords must be in upper case. Code editors should support you in writing lowercase keywords and then make them uppercase automatically in your code,
or else you will need to be friends with the caps lock on your keyboard.
### Operators and delimiters
( ) [ ] { } | " ' , `
. .. : ; & ~ ^ ? # .# .=
< .< <= .<= > .> >= .>= + +* -
* ** / ./ \ =
### Additional reserved keywords for built-in procedures and types
These can not be used for variable names etc. Just for the intended use of types and procedures provided by the system.
ABS ADDRESS ADDRESSOF ALL ANY ASH
ASSERT BOOLEAN CAP CAS CHAR CHR
COMPLEX COMPLEX32 COMPLEX64 COPY DEC DECMUL
DIM ENTER ENTIERH EXCL FIRST FLOAT32
FLOAT64 FLOOR HALT IM INC INCL
INCMUL INCR INTEGER INTEGERSET LAST LEN
LONG LONGINTEGER LSH MAX MIN OBJECT
ODD RANGE RE REAL RESHAPE ROL
ROR ROT SET SET8 SET16 SET32
SET64 SHL SHORT SHR SIGNED8 SIGNED16
SIGNED32 SIGNED64 SIZE SIZEOF STEP SUM
UNSIGNED8 UNSIGNED16 UNSIGNED32 UNSIGNED64
### The system module is built in and contains the following procedures
SYSTEM.BYTE SYSTEM.GET SYSTEM.PUT
SYSTEM.PUT8 SYSTEM.PUT16 SYSTEM.PUT32
SYSTEM.PUT64 SYSTEM.SET SYSTEM.GET8
SYSTEM.GET16 SYSTEM.GET32 SYSTEM.GET64
SYSTEM.VAL SYSTEM.MOVE SYSTEM.REF
SYSTEM.NEW SYSTEM.TYPECODE SYSTEM.HALT
SYSTEM.SIZE SYSTEM.ADR SYSTEM.MSK
SYSTEM.BIT SYSTEM.Time SYSTEM.Date
SYSTEM.GetStackPointer SYSTEM.SetStackPointer SYSTEM.GetFRameBuffer
SYSTEM.SetFramePointer SYSTEM.GetActivity SYSTEM.SetActivity
### Fundamental types
Below we describe the fundamental types available to the programmer that are directly mapped to the hardware it runs on.
Typename Size Valid values
BOOLEAN 1 byte TRUE, FALSE
CHAR 4 bytes UNICODE UTF32
SIGNED8 1 byte -2^7 .. 2^7 - 1
SIGNED16 2 bytes -2^15 .. 2^15 - 1
SIGNED32 4 bytes -2^31 .. 2^31 - 1
SIGNED32 8 bytes -2^63 .. 2^63 - 1
UNSIGNED8 1 byte 0 .. 2^8 -1
UNSIGNED16 2 bytes 0 .. 2^16 -1
UNSIGNED32 4 bytes 0 .. 2^32 -1
UNSIGNED64 8 bytes 0 .. 2^64 -1
FLOAT32 4 bytes -3.4028^38 .. +3.4028^38
FLOAT64 8 bytes -1.7976^308 .. +1.7976^308
SET8 1 byte Flags between 0 and 7
SET16 2 bytes Flags between 0 and 15
SET32 4 bytes Flags between 0 and 31
SET64 8 bytes Flags between 0 and 63
REAL Default floating point type. double in C
INTEGER Machine word signed integer in machine word size
ADDRESS Address width unsigned integer in address range
SIZE Address width signed inteher in address range
SET Address width Set with address width
#### Literal name
All literal names must be in the form: Letter { Letter | Digit | '_' } Example: 'Build_Compiler12'
#### Numbers
Numbers are either integers or real numbers. Numbers can be decimal or hexadecimal.
* 7FF0 is a 16-bit number ( Like 0x7ff0 in C++ )
* Real numbers in the format like 0.45D-11 ( FLOAT32 )
* Real numbers in the format like 7.11E+8 ( FLOAT64 )
#### Character
All characters are internally handled as UTF-32 characters, so a char is between 0 and FFFFFFFF , but only valid character codes in Unicode. Also in the format of 'x' etc.
#### Strings
All strings are arrays of UTF-32 characters. Defined as " Text goes here! "
#### Simplest program to parse possible
MODULE test;
END test.
More to come later!