/Grace_compiler

A Compiler for the Grace Programming Language (mad in NTUA)

Primary LanguageC++

A Compiler for the Grace Progamming Lanuage ๐Ÿ“ˆ

Compiler Features ๐Ÿ‘€

  • optimising ๐Ÿ’€
  • llvm backend ๐Ÿ”จ
  • the integer type is implemented in 64-bits only (its 2024)
  • strings can contain unicode characters ๐Ÿ˜‚๐Ÿ‘Œ

About the Grace Language ๐Ÿฅต

  • it's like pascal and C
  • it has nested functions and call by reference
  • it has interesting comments
  • it supports strings and has some built in functions to manage them (included in the runtime library)
  • look at the spec to find out more ๐Ÿ––
  • look bellow for example programs to get the idea of the language (or to use the compiler ๐Ÿคญ๐Ÿ˜ณ)

Repositories Containing Programs Written in Grace ๐Ÿ”ข

More Resources for Grace ๐Ÿค“

  • a plug in for vscode which includes syntax highlighting among other resources can be found here

About the Runtime Library ๐Ÿš€

  • it is contained in libgrc ๐Ÿ“
  • it was based on this ๐ŸงŽโ€โ™€๏ธ
  • im not sure its makefile works correctly ๐Ÿค”
  • it relies on C's library
  • it uses C's string functions directly

Installation ๐Ÿ”ฅ

make -j3

then

make clean

removes all files produced but not need to run the executable (i.e. object files etc.) ๐Ÿงด

LLVM Configuration Informtion ๐Ÿ“‹

The compiler has been tested to work under the following configuration, which may be required for the compiler to compile and/or run โš ๏ธ

$ llvm-config --version
16.0.6
$ llvm-config --cxxflags
-I/usr/include -std=c++17   -fno-exceptions -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
$ llvm-config --ldflags
-L/usr/lib
$ llvm-config --system-libs

$ llvm-config --libs all
-lLLVM-16

To uninstall ๐Ÿฅบ

make distclean

Usage ๐Ÿคฏ

./grc.py [flags] program.grc

produces the executable program (files are not required to end in .grc ๐Ÿ“„)

โ— if flags -i or -f are not set, then two more files are produced:

  • program.ll - contains llvm ir
  • program.s - contains assembly

Flags ๐Ÿ˜

  • -O optimise ๐Ÿ’€
  • -f final code ๐Ÿค– - read prorgam from stdin and put final code in stdout
  • -i intermediate code ๐Ÿ‘ฝ - read prorgam from stdin and put intermediate code in stdout