Versatile is a compiled programming language that I built my senior year of high school for a science competition.
It is a direct compilation from the .vst file to NASM (a generic assembly language for x86) which is then
assembled and linked to create an executable that is portable across all x86 platforms. It features a simple syntax and implements
functions, variables, conditionals, scopes, and a variety of other operators that are defined in the grammar below.
Overall, the project was my first introduction to compiler design and assembly language. Also, it was my first
experience working with modern C++ (using templates, arena allocators, smart pointers) and Linux development environments.
Broken into 3 parts, the project consists of a tokenizer, a parser (that builds an AST depending on the grammar),
and then a code generator that traverses the AST and emits NASM assembly code. The generator is the most interesting part of the project
since it deals with
Future Work
The project is currently in a state where it can compile simple programs that use the features described in the grammar, but there are a lot of features that I would like to add in the future
if I have the time.
In general, I would love to add more data types than just positive integers. The worst part of implementing this is that the code generator currently only
allows for 8 bytes of data (using the rax register and stack blocks of width 8) and doesn't have any memory management implemented (everything works on the stack). Thus implementing
memory management and a garbage collector would be the biggest hurdle.
Also adding better error handling could be nice to make the language more user friendly. For example, giving line numbers where the parser was expecting a token
and such would be a nice addition.
Note that most of the code is not documented and not currently maintained at all so its purely used for
educational purposes! May rework the project at some point but no plans in the near future.