Ola
Ola copied to clipboard
Toy object-oriented programming language with LLVM backend
Ola
Ola is a toy object-oriented programming language with LLVM backend.
Dependencies
- LLVM 17.0.1 for compiler backend.
- spdlog for logging.
- CLI11 for command line parsing.
Features
- classes
- access modifiers:
public,private - constructors
- single inheritance:
: - polymorphism using vtables:
virtual,pure,final thisandsuperkeywords
- access modifiers:
- reference type:
ref - automatic type deduction:
auto - operators:
- additive:
+,-,+=,-=,++,-- - multiplicative:
*,/,%,*=,/=,%= - relation:
==,!=,>,>=,<,<= - shift:
>>,<<,>>=,<<= - bitwise:
&,|,^,~,&=,|=,^= - logic:
&&,||,!
- additive:
- control statements:
ifelse,switch,goto,?: - loop statements:
for,foreach,while,dowhile,break,continue - enums
- functions
- overloading
- attributes:
inline,noinline,nomangling(equivalent to C++'sextern "C")
- arrays
sizeof,lengthoperatorsalias- strings
- floats
- implicit casts
- scopes
- import statement
- standard library
Todo
- Custom backend
- windows x86-64 (wip)
Structure
Ola consists of three parts:
- Ola library - standard library for Ola language implemented in C and built as static library to be used by the compiler. Currently it contains 5 files: olaio.h, olamath.h, olaassert.h, olastring.h, olamemory.h.
- Ola compiler - consists of the following parts:
- Lexer - turns source file into a sequence of tokens
- Import Processor - receives tokens from previous phase and processes import statements.
- Parser - recursive descent parser that receives processed tokens and constructs Abstract Syntax Tree (AST) of a translation unit.
- Sema - does semantic analysis of a translation unit.
- LLVM Visitor - traverses AST and emits LLVM IR.
- LLVM Optimizer - applies optimizations to the generated LLVM IR produced by LLVM Visitor based on the optimization level used.
- Ola tests
- UnitTest framework for testing existing Ola features. Uses GoogleTest.
Usage
Command line options
- -h,--help: Print this help message and exit
- --astdump: Dump AST to output/log
- --testdebug: Print debug information during tests
- --test : used for running g-tests
- --Od : No optimizations
- --O0 : Same as --Od
- --O1 : Optimize
- --O2 : Optimize more
- --O3 : Optimize even more
- -i ... : Input files
- -o : Output file
- --directory : Directory of project files
- --simple : input code in the form of a string
Samples
Currently to see the samples you can check the test folder: OlaTests/Tests/.