Commit Graph

6 Commits

Author SHA1 Message Date
Aryadev Chavali
a422c7d1dc A reworked preprocesser with focus on stopping recursive errors
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.
2024-07-06 17:38:02 +01:00
Aryadev Chavali
42dbf515f0 Deleted preprocesser
Will be reworking it later
2024-07-03 16:55:19 +01:00
Aryadev Chavali
7e9af309e3 lerr_t and lerr_type_t -> Lexer::Err and Lexer::Err::Type 2024-06-01 13:40:17 +01:00
Aryadev Chavali
4b85f90a52 Namespace the lexer module
Future proofing any name collisions.
2024-06-01 01:52:17 +01:00
Aryadev Chavali
f5d8777b7a token_t -> Token
Use C++'s implicit typedef
2024-06-01 01:48:11 +01:00
Aryadev Chavali
f060a856d3 Fixed Makefile so it tracks dependencies better
It now tracks main.cpp's dependencies and rebuilds them as needed.
2024-04-16 20:42:51 +06:30