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
7817b5acc9
Use standardised signed version of word type from base.h
2023-10-31 21:24:50 +00:00
Aryadev Chavali
5d800d4366
Moved inst module to lib
...
As it has no dependencies on vm specifically, and it's more necessary
for any vendors who wish to target the virtual machine, it makes more
sense for inst to be a lib module rather than a vm module.
2023-10-31 21:14:14 +00:00
Aryadev Chavali
7ca8f2c644
asm/main logs are now indented and look prettier
2023-10-31 20:39:49 +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
fa640f13e8
parse_word deals with characters now
...
Just takes the character literally as a number.
2023-10-31 20:38:03 +00:00
Aryadev Chavali
228f548bd9
Changed asm/parser instruction push-reg->push.reg
2023-10-31 20:37:11 +00:00
Aryadev Chavali
157c79d53c
Added a "usage" message and colours for assembler
...
Prints useful and pretty messages when verbose being at least 1.
2023-10-29 16:59:31 +00:00
Aryadev Chavali
1c0bd20cba
Introduce error reporting in asm/main
...
Pretty simple implementation, I've stopped printing the tokens cos I
think the lexer is done.
2023-10-28 18:22:18 +01:00
Aryadev Chavali
eac8cbf1da
asm/parser supports all opcodes, introduced parse errors
...
Introduced some functions to parse differing types of opcodes. Use
the same style of a.b.c... for namespacing or type specification for
certain opcodes. Bit hacky and not tested, but does work.
Parse errors can be reported with an exact location using the token
column, line.
2023-10-28 18:21:09 +01: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
fc81cda96b
Plugged in asm/parser to asm/main
...
Just prints instructions so far.
2023-10-26 11:18:07 +01:00
Aryadev Chavali
2fe2af22a9
Implemented a rudimentary parser with support for 4 instruction types
2023-10-26 11:17:55 +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
c70a9d9879
asm/main now uses TOKEN_STREAM_AT
2023-10-26 10:23:00 +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
131d70a9a3
Started working on a parser
...
No implementations yet
2023-10-25 21:43:51 +01:00
Aryadev Chavali
94abb9e3d4
Separated lexer from main file in asm
2023-10-25 21:43:13 +01:00
Aryadev Chavali
dbbfac1236
Wrote lexer for assembly
...
Pretty simple tokeniser, doesn't do a lot and needs to error check better.
2023-10-24 18:20:59 +01:00
Aryadev Chavali
92855ebb3e
Starting development on assembly language
2023-10-23 16:53:50 +01:00