Rangi
27f38770d4
Parentheses in macro args prevent commas from starting new arguments
...
This is similar to C's behavior, and convenient for passing
function calls as single values, like `MUL(3.0, 4.0)` or
`STRSUB("str", 2, 1)`.
Fixes #704
2021-04-23 14:28:10 +02:00
Rangi
4d21588eb2
Make invalid UTF-8 characters in strings non-fatal
...
STRLEN and STRSUB report the erroneous bytes
Fixes #848
2021-04-22 09:59:02 +02:00
Rangi
e596dbfc80
Make failed macro arg expansions non-fatal
...
Expanding empty strings is valid but pointless;
macro args already skipped doing so, now other
`beginExpansion` calls do too.
This also fixes failed interpolations (which were
already non-fatal) to continue reading characters,
not evaluate to their initial '{' character.
2021-04-22 09:59:02 +02:00
Rangi
1aeaca2af6
Add test case sort-algorithms.asm
...
This combines 0.5.0 and post-0.5.0 features:
print and println, strfmt, for loops,
def assignments, redef equs, {interpolation},
new macro syntax, and \<bracketed macro args>
2021-04-20 22:36:56 -04:00
Rangi
fe3521c7a4
Switch from parentheses to angle brackets
...
`\(` is more likely to be a valid escape sequence in the
future (as is `\[`) and `\{` is already taken.
2021-04-20 17:14:21 +02:00
Rangi
b0f8d75d1d
Shorten quine.asm with \(parenthesized) macro args
2021-04-20 17:14:21 +02:00
Rangi
7a314e7aff
Support numeric symbol names in \(parentheses)
...
For example, \(_NARG) will get the last argument
2021-04-20 17:14:21 +02:00
Rangi
637bbbdf43
Support multi-digit macro arguments in parentheses
...
This allows access to arguments past \9 without using 'shift'
2021-04-20 17:14:21 +02:00
Rangi
7ac8bd6e24
Return a marker token at the end of any buffer
...
Removes the lexer hack mentioned in #778
2021-04-20 17:10:08 +02:00
Rangi
be2572edca
Track nested interpolation depth even outside string literals
...
Fixes #837
2021-04-20 09:37:29 -04:00
Rangi
cf2bbe6435
Position -1 is the last character of a string
...
Position 0 is invalid, which matches with STRIN/STRRIN
returning 0 on failure.
2021-04-20 14:27:59 +02:00
Rangi
dc5b7802c8
Make the len parameter optional in STRSUB(str, pos, len)
...
An unspecified length will continue to the end of the string.
2021-04-20 14:27:59 +02:00
Rangi
b1e6c73197
STRSUB and CHARSUB allow zero or negative positions
...
These are offsets from the end of the string, as if the
STRLEN or CHARLEN respectively were added to the position.
Fixes #812
2021-04-20 14:27:59 +02:00
Rangi
52797b6f68
Implement SIZEOF("Section") and STARTOF("Section") ( #766 )
...
Updates the object file revision to 8
Fixes #765
2021-04-17 18:36:26 -04:00
Rangi
2005ed1df9
Implement CHARLEN and CHARSUB
...
Fixes #786
2021-04-17 18:18:34 -04:00
Rangi
d43408f4f3
Allow OPT to modify -W
...
Warning flags are processed individually;
PUSHO and POPO (re)store all the warning states.
2021-04-18 00:11:18 +02:00
Rangi
2c30ab8731
Allow OPT to modify -L
...
-L is a Boolean flag option, so you specify 'OPT L' or 'OPT !L'.
2021-04-18 00:11:18 +02:00
Rangi
9923fa3eee
Fix expansions that start from the end of another expansion ( #839 )
...
Do not free an expansion until its offset is *past* its size.
This means potentially freeing a nested stack of expansions
all at once.
Fixes #696
2021-04-17 13:14:40 -04:00
Rangi
ee5da4468d
Fix interpolation/STRFMT overflow issues ( #838 )
...
Widths and fractional widths greater than 255 would overflow a
uint8_t and wrap around to smaller values.
Total formatted lengths greater than the avilable buffer size
would overflow it and potentially corrupt memory.
Fixes #830
Closes #831
2021-04-17 00:52:55 -04:00
Rangi
503c3b5364
Revert "Fix interpolation/STRFMT overflow issues"
...
This reverts commit 992be3fd9b .
2021-04-16 22:19:37 -04:00
Rangi
992be3fd9b
Fix interpolation/STRFMT overflow issues
...
Widths and fractional widths greater than 255 would overflow a
uint8_t and wrap around to smaller values.
Total formatted lengths greater than the avilable buffer size
would overflow it and potentially corrupt memory.
Fixes #830
Closes #831
2021-04-16 22:00:17 -04:00
Rangi
c755fa3469
readIdentifier does not process characters that get truncated
...
Previously a '.' could be past the truncation limit but still
cause the identifier to be marked as local, violating an
assertion in `sym_AddLocalLabel`.
Fixes #832
2021-04-16 21:15:01 -04:00
Rangi
e78a1d5bfd
readInterpolation is limited by nMaxRecursionDepth
...
Fixes #837
2021-04-16 16:10:46 -04:00
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
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
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
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
49174f4486
Define the UTC time components as EQU, not EQUS
...
Fixes #827
2021-04-13 10:11:21 -04:00
Rangi
bcb78f5d18
Define __RGBDS_VERSION__ as the output of rgbasm --version (sans "rgbasm")
...
Fixes #824
2021-04-09 19:42:48 +02: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
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
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
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
Rangi
aa99ed056c
Do not evaluate an untaken ELIF's condition
...
Fixes #764
2021-03-23 16:20:24 +01:00
Rangi
7e127a4e52
Don't expand string symbols in MACRO and FOR symbol names
...
Explicit {interpolation} can still achieve this, but
to match DEF, REDEF, and PURGE, these new directives that
define symbols do not expand string EQUS.
2021-03-19 01:48:36 +01:00
Rangi
b8093847dc
New definition syntax with leading DEF keyword
...
This will enable fixing #457 later once the old
definition syntax is removed.
2021-03-19 01:48:36 +01:00
Rangi
8d1b56bcf5
rgblink identifies patches' PC sections after reading all sections
...
Fixes #794
2021-03-18 23:53:54 +01:00
ISSOtm
714d39c86f
Make some INCBIN errors non-fatal
2021-03-10 01:02:45 +01:00
ISSOtm
f11241c2ae
Add INCBIN tests
2021-03-10 01:02:45 +01:00
ISSOtm
028e7af7d1
Prepare release candidates
...
We'll use "-rcX" instead of "-pre" to allow multiple ones, jic
Additionally, they will be able to be detected using __RGBDS_RC__
Finally, adapt everything version-related to this new system
2021-03-10 00:06:32 +01:00
ISSOtm
611bd46e0b
Ignore CRLF vs LF for syntax error test check
2021-03-09 22:58:32 +01:00
ISSOtm
e67254093e
Delete version test if stale
2021-03-09 22:58:00 +01:00
ISSOtm
3ce3d2f662
Explicitly force tested projects to use tested bins
2021-03-09 22:56:59 +01:00