aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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-15Dependencies stricter and prerequisites for directories in MakefileAryadev Chavali
Don't need to make a directory every time I compile some code.
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-14Added C++ dir localsAryadev Chavali
2024-04-14Created custom functions to convert (h)words to and from bytecode formatAryadev Chavali
Instead of using endian.h that is not portable AND doesn't work with C++, I'll just write my own using a forced union based type punning trick. I've decided to use little endian for the format as well: it seems to be used by most desktop computers so it should make these functions faster to run for most CPUs.
2024-04-14Merge branch 'master' into asm-rewrite-cppAryadev Chavali
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!
2024-04-14Documented lib/darr.hAryadev Chavali
2024-04-14Moved struct definitions lib/inst.h -> lib/prog.hAryadev Chavali
This means if I write the new assembler in another language I only need to FFI this header rather than all the functions as well which may not be as useful.
2024-04-14Documented lib/darr.hAryadev Chavali
2024-04-14Moved struct definitions lib/inst.h -> lib/prog.hAryadev Chavali
This means if I write the new assembler in another language I only need to FFI this header rather than all the functions as well which may not be as useful.
2024-04-14Added todo to rewrite assembler in a different languageAryadev Chavali
2024-04-14Finished todo on importing another fileAryadev Chavali
2024-04-14fix! loops in preprocess_use_blocks iterate to the wrong bound0.0.1Aryadev Chavali
A token_stream being constructed on the spot has different used/available properties to a fully constructed one: a fully constructed token stream uses available to hold the total number of tokens and used as an internal iterator, while one that is still being constructed uses the semantics of a standard darr. Furthermore, some loops didn't divide by ~sizeof(token_t)~ which lead to iteration over bound errors.
2024-04-12Fix problems with running programs due to mismatched endianAryadev Chavali
Basically ensure we're converting to big endian when writing bytecode and converting from big endian when reading bytecode.