Jakub Kądziołka
1ffd7cb5bb
Make tests work on NixOS
...
Some distributions, such as NixOS and Guix, only have the /bin/sh and
/usr/bin/env binaries in standard locations.
2021-04-16 16:38:04 +02:00
Jakub Kądziołka
215e26b478
charmap: Store hashmap nodes in charmap stack
...
This helps update all the pointers during reallocation.
2021-04-16 16:00:26 +02:00
Jakub Kądziołka
8885f7bcf6
hash_AddElement: return the new node
2021-04-16 16:00:26 +02:00
Jakub Kądziołka
5334fc334e
Don't report hashmap collisions
...
This doesn't seem to be very useful, and keeping this "feature" is
difficult.
2021-04-16 16:00:26 +02:00
Jakub Kądziołka
f97663aa37
hashmap: add hash_GetNode
2021-04-16 16:00:26 +02:00
Jakub Kądziołka
08bdbd1949
Add an .editorconfig
...
This automatically sets up the formatting settings in a number of
editors, regardless of the user's preferences.
2021-04-16 15:56:57 +02:00
Rangi
5c852c7651
Store the nested expansions starting from the deepest one ( #829 )
...
This shortens the lexer by 100 lines and simplifies
access to expansion contents, since it usually needs the
deepest one, not the top-level one.
Fixes #813
2021-04-16 09:54:13 -04:00
Rangi
6be3584467
LexerState's 'size' and 'offset' for mmapped files are unsigned
...
These were using signed 'off_t' because that is the type of
'st_size' from 'stat()', but neither one can be negative.
2021-04-16 10:23:37 +02:00
Rangi
8c90d9d2d7
Get rid of skip in struct Expansion
...
This was only used to skip the two macro arg characters,
but shiftChar() can skip them before the expansion.
2021-04-16 10:23:37 +02:00
Rangi
f69e666b00
expansionOfs cannot be negative
...
lexerState->expansionOfs is always either set to 0, or updated by
adding a positive quantity:
if (distance > lexerState->expansions->distance) {
lexerState->expansionOfs += distance - lexerState->expansions->distance;
...
}
so it will always be positive or zero.
2021-04-16 10:23:37 +02:00
Rangi
eba06404f0
peek(0) => peek()
...
This does not completely refactor `peek` as #708 suggested,
to make it shift and cache a character itself. However it
does simplify the lexer code.
2021-04-16 10:23:37 +02:00
Rangi
9558ccea1b
shiftChars(1) => shiftChar()
...
Only two sites were for distances greater than 1:
a `shiftChars(2)`, trivial to just do two `shiftChar()`s;
and `shiftChars(size)` in `reportGarbageChar`, which
can be a `for` loop, and should be fixed anyway to
"avoid having to peek further than 0".
2021-04-16 10:23:37 +02:00
Rangi
260d372acd
Lex $ff00+c without needing large peek lookahead
...
This also allows arbitrary amounts of whitespace in `$ff00 + c`,
instead of needing to fit in the 42-byte LEXER_BUF_SIZE
2021-04-16 10:23:37 +02:00
Rangi
4e1b0ce793
Rephrase CONTRIBUTING.rst
...
Fix #729
2021-04-14 21:19:54 -04:00
Rangi
363ee9578c
Document the release process in RELEASE.rst
...
Fix #718
2021-04-14 21:13:37 -04:00
Rangi
8fa5a4255e
Mention alternative mnemonics in gbz80(7)
...
Fixes #819
2021-04-14 16:59:31 -04:00
Rangi
b3312886fb
Use a lookupExpansion, but not as an X macro
...
Instead of defining `LOOKUP_PRE_NEST` and `LOOKUP_POST_NEST`,
pass a variable name and a block to `lookupExpansion`; it
will assign successive looked-up expansions to the variable
and use them in the block.
The technique of using `__VA_ARGS__` to allow commas within a
block passed to a macro is not original, and should be stable.
2021-04-13 17:58:46 +02:00
Rangi
7fc8a65d0a
Refactor the lexer to not use the lookupExpansion X macro
...
This macro was only used twice, in `beginExpansion` and
`lexer_DumpStringExpansions`, with `getExpansionAtDistance`
already containing an inlined and slightly modified version
of `lookupExpansion` (retaining the `LOOKUP_PRE_NEST` and
`LOOKUP_POST_NEST` macros, but with both of them doing nothing).
Not using an X macro here makes the actual control flow in both
places more obvious, and I think the repeated code is acceptable
for the same reasons as the similar-but-distinct implementations
of `readString`, `appendStringLiteral`, `yylex_NORMAL`, and
`yylex_RAW`.
2021-04-13 17:58:46 +02:00
Rangi
c278a361da
Remove the unused calchash djb2 hash function
...
Note that hashmap.c uses its own FNV-1a hash function
2021-04-13 17:41:12 +02:00
Rangi
a2f52867ad
Rename print to printChar
...
This clarifies its usage, for printing a single character
in error messages.
2021-04-13 17:41:12 +02:00
Rangi
ab79e6bede
Change how print(c) formats reported characters
...
Printable ASCII becomes single-quoted, using backslash
escapes if necessary. Unprintable characters use 0xNN
formatting, without quotes.
2021-04-13 17:41:12 +02:00
Rangi
850c78aaf4
Report garbage chars as their bytes; don't try decoding them as UTF-8
...
This decoding required high lookahead, and was not even
consistently useful (the `garbage_char` test case was not
valid UTF-8 and so did not benefit from `reportGarbageChar`).
This limits UTF-8 handling to the `STRLEN` and `STRSUB`
built-in functions, and to charmap conversion.
2021-04-13 17:41:12 +02:00
Rangi
c08cf783c8
Remove 'inline' from functions not in headers
2021-04-13 10:27:08 -04:00
Rangi
25a8518fbf
Remove unused function removeLeadingZeros
2021-04-13 10:12:40 -04:00
Rangi
49174f4486
Define the UTC time components as EQU, not EQUS
...
Fixes #827
2021-04-13 10:11:21 -04:00
Rangi
81327b0d99
Merge branch 'master' of https://github.com/gbdev/rgbds
2021-04-13 09:31:35 -04:00
Rangi
c0859e64f7
fstk_FindFile checks for sprintf failure
2021-04-13 09:31:05 -04:00
Rangi
3e0b7d428f
Fix an unclosed file and unfreed memory in out_BinaryFileSlice
...
Use 'goto cleanup' in both out_BinaryFileSlice and out_BinaryFile
2021-04-13 09:19:59 -04:00
ISSOtm
ba3428314b
Add contact info for potential contributors
...
I'm going on a break, but I'll stay available if anyone wants to contribute.
2021-04-13 00:27:49 +02:00
Rangi
bcb78f5d18
Define __RGBDS_VERSION__ as the output of rgbasm --version (sans "rgbasm")
...
Fixes #824
2021-04-09 19:42:48 +02:00
ISSOtm
de7d1facf3
Add assertion that an expansion's total len doesn't overflow
...
Typically not needed because the recursion depth limit should prevent it,
but it might help debug weird lexer issues.
2021-04-03 18:31:30 +02:00
Rangi
310d34c655
Comment on REG_SP and REG_AF both being 3
...
No instruction needs to distinguish them both
2021-03-31 18:41:42 -04:00
Rangi
39c38f9838
Add a test case for unattainable SECTION UNION alignment
...
This test cases used to fail an assertion in `make develop`
2021-03-31 16:09:52 -04:00
Rangi
576b063519
Fix unattainable alignments to address 0
...
Fixes #818
2021-03-31 16:06:15 -04:00
Rangi
596e17ee61
Factor out a common strlen into beginExpansion
...
This avoids the possibility of `size` not matching `str`
2021-03-31 14:41:38 -04:00
Rangi
363b3d0134
Flush stdout after PRINTLN
...
This allows debug PRINTLN statements to run even if
subsequent rgbasm directives cause a crash.
2021-03-31 11:22:41 -04:00
Rangi
c7ed9a275e
Do not expand empty strings
...
Fixes #813
2021-03-31 10:21:04 -04:00
Rangi
49aac2961d
Warn about backwards FOR loops with -Wbackwards-for (-Wall)
...
Fixes #816
2021-03-31 10:00:21 -04:00
Rangi
3741bd4617
Speed up the div-mod test case
...
Test various explicit cases, not nested `for` loops
over thousands of cases
2021-03-31 09:37:23 -04:00
Jakub Kądziołka
937c9888a4
Robustly disallow overwriting builtin symbols ( #817 )
2021-03-31 09:03:57 -04:00
Rangi
61a9bfd33c
Some tests use the new macro <name> syntax
...
This happens to make quine.asm shorter
2021-03-31 00:00:18 -04:00
Jakub Kądziołka
d08bcc455d
Handle errors when opening source file
...
Before this commit, opening a file for which the user didn't have
permission resulted in a "Bad file descriptor" error.
2021-03-30 23:35:50 +02:00
Rangi
aaa92659ea
Require a plus sign in ld hl, sp + <e8>
...
Fixes #810
2021-03-30 13:05:21 -04:00
Rangi
be877134e5
Remove support for ld bc/de/hl/sp for ld hl, bc/de/hl/sp
...
Fixes #811
2021-03-30 13:01:49 -04:00
Rangi
d05703c692
Release 0.5.0-rc2
v0.5.0-rc2
2021-03-28 17:15:44 -04:00
Rangi
5dbfafcc55
Update man page copyrights to 2021
2021-03-28 16:37:15 -04:00
Rangi
a265b85d9d
Report "1 error", not "1 errors", when assembly is aborted
...
This matches other such pluralized error messages
2021-03-28 15:55:32 -04:00
Rangi
28abf03c0a
Output USED space, not FREE space, in the .map file
...
Fixes #808
2021-03-28 15:49:44 -04:00
Rangi
7e7f92f18c
Assign section locations to all UNIONs/FRAGMENTs
...
Fixes the test case from #800
The `out.gb` output was corrected, since the two "test"
fragments have a different order in ROM than in SRAM.
It is effectively:
; ROM0[$0000], fragments ordered by size
jr Label
dw Label
db 0
; SRAM[$a000], fragments ordered by .o order
ds 1 ; db 0
ds 2 ; jr Label
Label: ; $a003
ds 2 ; dw Label
2021-03-28 15:21:17 -04:00
Eldred Habert
7461170956
Add LOAD FRAGMENT pc test ( #800 )
...
Reproduces a reported problem, fix pending
2021-03-28 15:11:20 -04:00