Commit Graph

11 Commits

Author SHA1 Message Date
Aryadev Chavali
83678ad29a Add MULT to lexer and parser for assembler 2023-11-01 18:09:00 +00:00
Aryadev Chavali
93d234cd48 Lexer now returns more descriptive tokens
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-11-01 15:09:47 +00:00
Aryadev Chavali
0f0a1c7699 Allow hex literals for numbers
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-31 22:27:53 +00:00
Aryadev Chavali
75dc36cd19 Lexer now returns errors on failure
Currently only for invalid character literals, but still a possible
problem.
2023-10-31 20:39:26 +00:00
Aryadev Chavali
191fe5c6b8 Ignore comments (using semicolons) in lexer
Easier to do it here than at the parser.
2023-10-28 18:19:33 +01:00
Aryadev Chavali
d2429aa549 Introduced a column and line for each token
Accurate error reporting can be introduced using this.
2023-10-28 18:19:30 +01:00
Aryadev Chavali
dca51106a2 Added support in lexer for negative numbers
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-26 11:17:01 +01:00
Aryadev Chavali
b152365561 Lexer forces uppercase for symbols 2023-10-26 10:22:53 +01:00
Aryadev Chavali
a07b571da2 Auto fill licenses 2023-10-26 08:01:26 +01:00
Aryadev Chavali
7bf6b53230 Unified literal for numbers, main program now tokenises 2023-10-26 07:15:52 +01:00
Aryadev Chavali
94abb9e3d4 Separated lexer from main file in asm 2023-10-25 21:43:13 +01:00