aboutsummaryrefslogtreecommitdiff
path: root/src/lexer.c
Commit message (Collapse)AuthorAgeFilesLines
* [C]: Add `here` keyword that evaluates to a string with it's locationMustafa Quraish2022-02-061-0/+9
| | | | | | | | | It's not really a keyword like the other ones, but just handled completely at the lexer level since it already knows the location of the token, so it injects a string literal instead. We also use this in the self-hosted compiler now for better error reporting for where the error happened internally.
* Some very minor fixes (look at message)Mustafa Quraish2022-02-051-0/+1
| | | | | (1) Add support for escaped single quotes (2) Fix `putu_buffer` in `std/common.cup`
* Add support for some more binary ops: |, &, ^Mustafa Quraish2022-02-051-0/+1
|
* Minor fixes, rearranging, whitespace trimming. No functional changes.Mustafa Quraish2022-02-041-5/+5
|
* Add support for basic structsMustafa Quraish2022-02-031-0/+1
| | | | | | | | Structs for now (and probably for the near future) are not allowed to be passed by value, and instead you just pass a pointer to it. Nested structs can also be defined, and they can be either anonymous, or named (in which case only the members can access the type).
* Add support for `char` type + string/char literalsMustafa Quraish2022-02-021-0/+27
| | | | | | | | | | | This commit does a few things in one go: - Add support for a `char` type + some changes to support the new size - Add support for character literals. We need some escaping here to be able to use `\n` and `\0`, etc. - Add support for string literals. These are all stored in the `.data` section. Fortunately NASM already handles the escape characters. - Fix some bugs with code generation, specifically using `movsx` to sign extend the smaller types into 64-bit registers.
* Add initial support for arrays (also no testing)Mustafa Quraish2022-02-021-0/+2
| | | | | | Usual disclaimer at this point: Quick&Dirty implementation, hasn't been tested other than basic sanity checks. Arrays are automatically decayed into pointers when the identifier is accessed.
* Add ability to import other filesMustafa Quraish2022-01-311-1/+20
| | | | | | This still requires a lot of work to avoid duplicate imports, and handle cyclic imports, but it is a good enough for small examples which just want to include some common definitions from std/
* Make `Lexer_new` return a pointer instead of the object.Mustafa Quraish2022-01-311-5/+5
|
* Put tokens in their own macro to allow looping over themMustafa Quraish2022-01-301-14/+5
|
* Rename `cup` directory to `src`Mustafa Quraish2022-01-301-0/+238