aboutsummaryrefslogtreecommitdiff
path: root/asm
AgeCommit message (Collapse)Author
2024-04-16lerr_type_t::UNKNOWN_CHAR -> UNKNOWN_LEXEMEAryadev Chavali
2024-04-16Clean up error message from preprocesserAryadev Chavali
2024-04-16Fix bug where CONST table didn't actually store symbol namesAryadev Chavali
Pretty simple fix, stupid error in hindsight.
2024-04-16Clear vector after deleting all tokensAryadev Chavali
Ensures that iteration over vec_out by caller doesn't occur (such as in a loop to free the memory).
2024-04-16Fixed examples for changes in lexerAryadev Chavali
Name assigned to %CONST is the next symbol in stream, not the symbol attached to it.
2024-04-15Changed %const format in preprocesser nowAryadev Chavali
Instead of %const(<name>) ... %end it will now be %const <name> ... %end i.e. the first symbol after %const will be considered the name of the constant similar to %use.
2024-04-15preprocesser publicly exposes only preprocesser functionAryadev Chavali
The preprocess_* functions are now privately contained within the implementation file to help the preprocesser outer function. Furthermore I've simplified the API of the preprocess_* functions by making them only return pp_err_t and store their results in a vector parameter taken by reference.
2024-04-15Added some VERBOSE checked messages into asm/mainAryadev Chavali
2024-04-15Propagate changes to lerr_t into preprocesserAryadev Chavali
2024-04-15preprocesser function now only returns a pp_err_tAryadev Chavali
We leave the parameter tokens alone, considering it constant, while the parameter vec_out is used to hold the new stream of tokens. This allows the caller to have a before and after view on the token stream and reduces the worry of double frees.
2024-04-15Changed output schema for printing tokensAryadev Chavali
2024-04-15Fix error where lexer would loop infinitely if unknown character foundAryadev Chavali
2024-04-15Changed hex format from x<digits> -> 0x<digits>Aryadev Chavali
2024-04-15Lexical error on char literal being too big or too smallAryadev Chavali
This is actually an improvement on the older lexer.
2024-04-15lerr_t is now a struct with constructorsAryadev Chavali
Similar principle to pp_err_t in that a structure provides the opportunity for more information about the error such as location.
2024-04-15constexpr -> const in lexer.cppAryadev Chavali
Not much of an actual performance change, more semantic meaning for me.
2024-04-15~extern "C"~ when including lib/inst.hAryadev Chavali
2024-04-15Auto filled copyrightn otice in asm/baseAryadev Chavali
2024-04-15main.cpp now preprocesses tokens and prints the outputAryadev Chavali
2024-04-15Fix some off by one errorsAryadev Chavali
2024-04-15Fix issue with use_blocks not being preprocessedAryadev Chavali
2024-04-15fix memory leak through vec.clearAryadev Chavali
vec.clear() doesn't delete pointers (unless they're smart) so I need to do it myself.
2024-04-15Implemented preprocesser function.Aryadev Chavali
2024-04-15Default constructor for pp_err_tAryadev Chavali
2024-04-15preprocess_* now uses const references to tokensAryadev Chavali
They copy and construct new token vectors and just read the token inputs.
2024-04-15Updated main.cpp for changes to lexerAryadev Chavali
2024-04-15Implemented preprocess_const_blocksAryadev Chavali
Once again quite similar to preprocess_macro_blocks but shorter, easier to use and easier to read. (76 vs 109)
2024-04-15Implement printing of pp_err_tAryadev Chavali
Another great thing for C++: the ability to tell it how to print structures the way I want. In C it's either: 1) Write a function to print the structure out (preferably to a file pointer) 2) Write a function to return a string (allocated on the heap) which represents it Both are not fun to write, whereas it's much easier to write this.
2024-04-15Implement constructors for pp_err_tAryadev Chavali
2024-04-15Implement preprocess_use_blocksAryadev Chavali
While being very similar in style to the C version, it takes 27 lines of code less to implement it due to the niceties of C++ (41 lines vs 68).
2024-04-15Moved read_file to a general base libraryAryadev Chavali
2024-04-15Fix some off by one errors in lexerAryadev Chavali
2024-04-15lexer now produces a vector of heap allocated tokensAryadev Chavali
This removes the problem of possibly expensive copies occurring due to working with tokens produced from the lexer (that C++ just... does): now we hold pointers where the copy operator is a lot easier to use. I want expensive stuff to be done by me and for a reason: I want to be holding the shotgun.
2024-04-15Rewrote preprocesser APIAryadev Chavali
This C++ rewrite allows me to rewrite the actual API of the system. In particular, I'm no longer restricting myself to just using enums then figuring out a way to get proper error logging later down the line (through tracking tokens in the buffer internally, for example). Instead I can now design error structures which hold references to the token they occurred on as well as possible lexical errors (if they're a FILE_LEXICAL_ERROR which occurs due to the ~%USE~ macro). This means it's a lot easier to write error logging now at the top level.
2024-04-14parser -> preprocesser + parserAryadev Chavali
I've decided to split the module parsing into two modules, one for the preprocessing stage which only deals with tokens and the parsing stage which generates bytecode.
2024-04-14enum -> enum class in lexerAryadev Chavali
This makes enum elements scoped which is actually quite useful as I prefer the namespacing that enum's give in C++.
2024-04-14Added static assert to lexer in case of opcode changesAryadev Chavali
2024-04-14asm/main now tokenises and prints the tokens of a given fileAryadev Chavali
With error checking!
2024-04-14Implemented a function to read a file in fullAryadev Chavali
Uses std::optional in case file doesn't exist.
2024-04-14asm/main now prints usageAryadev Chavali
2024-04-14Implemented cstr functions.Aryadev Chavali
2024-04-14Implemented overload for ostream and token as well as constructors for tokenAryadev Chavali
2024-04-14Implemented tokenise_bufferAryadev Chavali
Note that this is basically the same as the previous version, excluding the fact that it uses C++ idioms more and does a bit better in error checking.
2024-04-14Implemented tokenise_literal_stringAryadev Chavali
One thing I've realised is that even methods such as this require error tracking. I won't implement it in the tokenise method as it's not related to consuming the string per se but instead in the main method.
2024-04-14Implemented tokenise_literal_char (tokenise_char_literal)Aryadev Chavali
I made the escape sequence parsing occur here instead of leaving it to the main tokenise_buffer function as I think it's better suited here.
2024-04-14Implemented tokenise_literal_hexAryadev Chavali
Note the overall size of this function in comparison to the C version, as well as its clarity. Of course, it is doing allocations in the background through std::string which requires more profiling if I want to make this super efficientâ„¢ but honestly the assembler just needs to work, whereas the runtime needs to be fast.
2024-04-14Implemented tokenise_literal_number (tokenise_number)Aryadev Chavali
2024-04-14Started implementing lexer in lexer.cppAryadev Chavali
The implementation for tokenise_symbol is already a lot nicer to look at and add to due to string/string_view operator overloading of ==. Furthermore, error handling through pair<> instead of making some custom structure which essentially does the same thing is already making me happy for this rewrite.
2024-04-14Wrote a new lexer API in C++Aryadev Chavali
Essentially a refactor of the C formed lexer into C++ style. I can already see some benefits from doing this, in particular speed of prototyping.
2024-04-14Start writing assembler in C++Aryadev Chavali
Best language to use as it's already compatible with the headers I'm using and can pretty neatly enter the build system while also using the functions I've built for converting to and from bytecode!