This repository has been archived on 2025-11-10 . You can view files and clone it. You cannot open issues or pull requests or push a commit.
a422c7d1dccc2f162d19cc76f439c096f9502ba8
Preprocesser requires one function to use: preprocess. Takes Tokens and gives back Units. A unit is a tree of tokens, where each unit is a node in that tree. A unit has a "root" token (value of node) and an "expansion" (children of node) where the root is some preprocesser token (such as a reference or USE call) and the expansion is the tokens it yields. In the case of a USE call this is the tokens of the file it includes, in the case of a reference it's the tokens of the constant it refers to. This means that the leaves of the tree of units are the completely preprocessed/expanded form of the source code. The function has many working components, which may need to be extracted. In particular, the function ensures we don't include a source twice through a hash map and that constants are not redefined in inner include scopes if they're already defined in outer scopes (i.e. if compiling a.asm which defines constant N, then include b.asm which defines constant N, then N uses the definition of a.asm rather than b.asm). I need to make a spec for this.
Aryadev's Assembly Language (AAL)
A compiler for Aryadev's Assembly Language, an assembly-like programming language, which targets the AVM.
How to build
Requires GNU make and a compliant C++17 compiler. Code base has
been tested against g++ and clang, but given how the project has
been written without use of GNU'isms (that I'm aware of) it shouldn't
be an issue to compile using something like tcc or another compiler
(look at here to change the compiler).
To build everything simply run make. This will build:
- Assembler executable which assembles compliant assembly code to VM bytecode
- Assembly examples which provide some source code examples on common programs one may write. Use this to figure out how to write compliant AAL. Also a good test of both the VM and assembler.
You may also build each component individually through the corresponding recipe:
make asmmake examples
Lines of code
| Files | Lines | Words | Bytes |
|---|---|---|---|
| ./asm/base.hpp | 21 | 68 | 472 |
| ./asm/lexer.cpp | 565 | 1448 | 14067 |
| ./asm/base.cpp | 33 | 89 | 705 |
| ./asm/lexer.hpp | 106 | 204 | 1757 |
| ./asm/preprocesser.cpp | 218 | 574 | 5800 |
| ./asm/preprocesser.hpp | 62 | 147 | 1360 |
| ./asm/main.cpp | 148 | 414 | 3791 |
| total | 1153 | 2944 | 27952 |
Description
Languages
C++
93.8%
Makefile
6.2%