Compiler

Installing

Download or clone the standalone compiler github repository from here

Libc and SQLite are required to be installed.

To install the compiler, presently, it requires compiling then running make install.

A header file tos.HH contains all of the prototypes for the functions and classes avalible. A static library is created when compiling which is subsequently linked against to have all of the library functions.

If you are wanting to install TempleOS please see here


Steps

  • clone the repo
  • run make, this will compile the compiler.
  • run make install on linux you will have to do sudo make install, this is because the compiler installs itself at /usr/local/bin/hcc
  • You can now compile HolyC files like hcc ./file.HC.
git clone git@github.com:Jamesbarford/holyc-lang.git
cd ./holyc-lang
make
make install

The steps


Compiler commands

Compile code

Compile code with the following, it will create an a.out.

hcc ./file.HC

The following are the flags that can be passed:
  • -ast prints an ast of the current code to stdout
  • -tokens prints all of the tokens.
  • -S output assembly only writing it to <filename>.s where <filename> is extracted from the <filename>.HC source file.
  • -lib will emit a static and dynamic library of the code you are compiling.
  • -clibs c libraries that you want to link e.g: hcc ./file.HC -clibs='-lcrypto -lSDL2 -lSDL2Main'
  • -o emit an object file
  • --help prints how to use the compiler flags to stdout.

Incompatabilities & Limitations

  • Varadic arguments in this compiler are all passed on the stack, this means that it breaks the x86_64 calling conventions and thus varadic functions cannot be used in c code trying to interpolate with holyc.
  • This is not a 100% complete language port from TempleOS and thus some features are missing which are detailed separately.
  • printf is currently being used for

The compilers firstly creates an AST of the code and then directly translates the tree into x86_64 AT&T style assembly. Thus this is non optimising; the created code is not as fast as c/c++ or rust. The compiler can link in c librarys and compile code to an object file. This is achieved by firstly compiling the x86_64 to a file in /tmp and then using gcc or clang internally to link and assemble the code.


Missing Features

  • No bound switch, switch presently is implemented as if/else
  • #exe for excuting code at compile time
  • Negative class displacements
  • Mixing assembly with HolyC without using an ASM block
  • Printing a floating point number.
  • Cannot define global variables with ,.
  • I'm sure there are more.
HolyC 2024
HolyC Compiler
TempleOS