aboutsummaryrefslogtreecommitdiff
path: root/asm/lexer.c
AgeCommit message (Collapse)Author
2023-11-02Made lexer more error prone so parser is lessAryadev Chavali
Lexer now will straight away attempt to eat up any type or later portions of an opcode rather than leaving everything but the root. This means checking for type in the parser is a direct check against the name rather than prefixed with a dot. Checks are a bit more strong to cause more tokens to go straight to symbol rather than getting checked after one routine in at on the parser side.
2023-11-02Made separate tokens for JUMP_ABS and JUMP_STACKAryadev Chavali
Makes more sense, don't need to fiddle around with strings as much in the parser due to this!
2023-11-02Removed instruction OP_JUMP_REGISTERAryadev Chavali
Not necessary when you can just push the relevant word onto the stack then just do OP_JUMP_STACK.
2023-11-02Started work on preprocessing jump addressesAryadev Chavali
2023-11-01Implemented MALLOC_STACK and SUB in the assemblerAryadev Chavali
2023-11-01Implemented stack versions of MGET and MSET in assemblerAryadev Chavali
2023-11-01Implemented OP_MSIZE into lexer/parser of ASMAryadev Chavali
2023-11-01Implemented lexer and parser for new memory management instructionsAryadev Chavali
2023-11-01Add MULT to lexer and parser for assemblerAryadev Chavali
2023-11-01Lexer now returns more descriptive tokensAryadev Chavali
More useful tokens, in particular for each opcode possible. This makes parsing a simpler task to reason as now we're just checking against an enum rather than doing a string check in linear time. It makes more sense to do this at the tokeniser as the local data from the buffer will be in the cache most likely as the buffer is contiguously allocated. While it will always be slow to do linear time checks on strings, when doing it at the parser we're having to check strings that may be allocated in a variety of different places. This means caching becomes a harder task, but with this approach we're less likely to have cache misses as long as the buffer stays there.
2023-10-31Allow hex literals for numbersAryadev Chavali
As strto(ul|ll) allow the parsing of hex literals of the form `0x`, we allow lexing of hex literals which start with `x`. They're lexed into C hex literals which work for strtol.
2023-10-31Lexer now returns errors on failureAryadev Chavali
Currently only for invalid character literals, but still a possible problem.
2023-10-28Ignore comments (using semicolons) in lexerAryadev Chavali
Easier to do it here than at the parser.
2023-10-28Introduced a column and line for each tokenAryadev Chavali
Accurate error reporting can be introduced using this.
2023-10-26Added support in lexer for negative numbersAryadev Chavali
Though we deal with unsigned numbers internally, it should be possible to read and manipulate negative numbers through 2s complement. Later on we'll add support for signed operations via 2s complement, so this should be allowed.
2023-10-26Lexer forces uppercase for symbolsAryadev Chavali
2023-10-26Auto fill licensesAryadev Chavali
2023-10-26Unified literal for numbers, main program now tokenisesAryadev Chavali
2023-10-25Separated lexer from main file in asmAryadev Chavali