Rangi42
3c7488c131
Some refactoring, renaming, and debug assertions for clarity and safety
...
- Add more `assume()` checks in the lexer
- Replace double negative "`disable* = false`" with "`enable* = true`"
- Naming convention of "`std::deque<> *Stack`" when relying on
`.push_front()` and `.pop_back()`
2026-04-27 18:47:06 +02:00
Rangi42
9fd0c0297f
Fix invalid character in bracketed macro argument
...
The invalid character should not be consumed by `shiftChar()`.
2026-04-27 17:11:20 +02:00
Rangi42
c1c7e64249
Add two assume calls to verify lexer arguments
2026-04-27 15:35:10 +02:00
Rangi42
a18b2f1049
Consistently lex local labels after keywords, even when skipping/capturing
2026-04-27 15:28:30 +02:00
Rangi42
eeb3a73210
Small optimization to skipToLeadingKeyword
2026-04-27 14:26:47 +02:00
Rangi
cfec017fed
Consolidate, refactor, and bugfix the lexer's handling of captures and skips ( #1957 )
...
- Do not error about local labels following keywords in skips or captures (fixes #1955 )
- Do not incompletely attempt to handle line continuations in skips (fixes #1956 )
- Rename `skipToLeadingIdentifier` to `skipToLeadingKeyword`, refactor to merge
`skipToEOL` into it, and use it for both skips and captures
2026-04-20 13:04:20 +02:00
ISSOtm
6b994b1737
Fix some warnings raised by MSVC
2026-04-16 00:57:33 +02:00
Rangi
df0b557638
Don't allow invalid interpolations to occur ( #1925 )
...
Fixes #1921
2026-04-11 18:16:07 +02:00
Rangi
9b4b4a581b
Check for overflow in fixed-point precision suffix ( #1918 )
...
Fixes #1917
2026-04-07 17:06:54 -04:00
Rangi
11f6278d95
Refactor lexing of fixed-point numbers ( #1915 )
...
This incidentally fixes a bug with too-long fixed-point literals
that have precision suffixes.
2026-04-06 21:45:34 -04:00
Rangi
ede9405daf
Fix some fixed-point literal lexing issues ( #1914 )
...
- No fractional digits are necessary after the decimal point,
e.g. `42.` is valid instead of `42.0`
- Error messages refer to "fixed-point" not "integer" constants
- Test more carefully for lexing unrelated to underscores
2026-04-04 13:41:45 -04:00
Rangi
66e521e9e5
Factor out common error-handling functions for lexing numbers of different bases ( #1888 )
2026-03-19 15:32:25 -04:00
Rangi42
752e2b3620
Symbol names with more than two '.'s could be defined as constants
...
Dot-only names could also trip an assertion in `make develop`
when used as labels
2025-12-04 15:15:41 -05:00
Rangi42
ad3188f038
Fix garbage characters at EOF causing an infinite loop
2025-12-04 15:15:41 -05:00
Rangi42
df5162edca
Use loops instead of tail calls and musttail
...
gcc 15.2.1 20250813 complains "address of automatic variable can
escape to `musttail` call" from `-Wmaybe-musttail-local-addr`,
and guaranteeing tail-call optimization cross-platform is more
trouble than it's worth.
2025-10-27 12:05:27 -04:00
Rangi
2873e0b8c8
Use musttail attribute to guarantee tail recursion ( #1849 )
2025-10-20 15:56:22 -04:00
Rangi
23b9039716
Give clearer names to template parameters
2025-10-08 14:55:43 -04:00
Rangi
089fc11e31
A local label starting with a keyword (e.g. jr.local) is an error
2025-10-08 12:23:08 -04:00
Rangi
538395b92c
Prevent simple syntax highlighters from breaking on /* in a string
2025-09-29 11:11:40 -04:00
Rangi
634fd853d1
Factor out a single parseNumber utility function ( #1839 )
2025-09-22 15:15:24 -04:00
Rangi42
d8aff148bb
Factor out RRANGE macro like RANGE
2025-09-19 16:53:44 -04:00
Rangi
e31bcabbaa
Implement === and !== string comparison operators ( #1832 )
2025-09-19 14:06:36 -04:00
Rangi
67741ab428
Trim left space from macro args, even past block comments ( #1831 )
2025-09-19 13:44:18 -04:00
Rangi42
1dfc1d3231
Factor out isBinDigit and parseHexDigit utility functions
2025-09-04 13:23:10 -04:00
Rangi42
cc96b4d517
Two small improvements
...
- Check whether `.read()` completed
- `.reserve()` expected space ahead of time
2025-09-01 11:46:41 -04:00
Rangi42
0ccdbf509a
Simplify format specs to not use a per-character state machine
2025-08-30 12:23:01 -04:00
Rangi
531278961f
Require underscores to actually be digit separators ( #1812 )
...
Multiple, trailing, or next to decimal point are errors
2025-08-30 10:44:20 -04:00
Rangi42
fcfc931867
Shorten lexing of simple tokens
2025-08-20 22:37:03 -04:00
Rangi
3d155d5695
Some refactoring and cleanup ( #1806 )
...
* Use clang-tidy `misc-include-cleaner` for IWYU `#include` cleanup
* Use `std::optional<size_t>` instead of `ssize_t`
* Rename some functions in linkdefs.hpp
* Fix header order
2025-08-20 16:09:04 -04:00
Rangi42
386fb5f398
Add more character utility functions
2025-08-19 19:17:40 -04:00
Rangi42
94e9ef5213
Factor shared code out of lexer_CaptureRept and lexer_CaptureMacro
2025-08-19 18:11:50 -04:00
Rangi
b7e0783ae7
Implement ? suffix to "quiet" a context and exclude it from backtraces ( #1800 )
2025-08-18 21:34:58 -04:00
Rangi
272019beb0
Fix line numbers from nested expansions ( #1802 )
2025-08-14 11:13:50 -04:00
Rangi
db6793f444
Don't count single quote ' as garbage ( #1801 )
...
Also copy the "blank space" (space or tab) vs "whitespace" (space,
tab, or newline) convention from `<ctype.h>`
2025-08-14 10:10:59 -04:00
Rangi
7b405513d9
Make quote marks consistent in error/warning messages ( #1791 )
...
- "Double quotes" for strings (filenames, section names, CLI option arguments, etc)
- 'Single quotes' for characters and CLI option flags
- `Backticks` for keywords and identifiers (symbol names, charmap names, etc)
CLI option flags also have their leading dashes
2025-08-12 15:24:21 -04:00
Rangi
5f8b7474b4
Add -B/--backtrace option to RGBASM and RGBLINK ( #1787 )
2025-08-11 14:30:14 -04:00
Rangi42
2130a5ba1f
Error messages refer to "undefined" symbols and sections
2025-08-08 19:47:42 -04:00
Rangi
e41ce49698
Only print one warning for too-large integer constants, not one per digit ( #1781 )
...
This also makes all too-large integer constants evaluate to 0.
2025-08-08 18:58:38 -04:00
Rangi
39f0f9edc0
Remove previously deprecated features ( #1777 )
...
- Treating multi-unit strings as numbers
- `rgbasm -Wnumeric-string`
- `ldio [c], a` and `ldio a, [c]` (use `ldh`)
- `ld [c], a` and `ld a, [c]` (use `ldh`)
- `ldh [$xx], a` and `ldh a, [$xx]` (use `$FFxx`)
2025-08-05 16:24:10 -04:00
Rangi42
504a45a4ed
Reuse isWhitespace and isNewline, also refactoring readAtFile
2025-08-05 13:46:53 -04:00
Rangi42
f1fd3abcff
Don't bother searching the keywordDict for local labels
2025-08-05 10:49:09 -04:00
Rangi42
2cae47a5a2
Color verbose output as magenta
...
Output RGBASM's lexed tokens at level 5 (TRACE)
2025-08-05 00:00:57 -04:00
Rangi42
ac75a085fa
Refactor lexer_CaptureRept and lexer_CaptureMacro
2025-08-04 23:26:29 -04:00
Rangi42
0c1b422c36
Refactor some redundant lexer code
2025-08-04 22:43:34 -04:00
Rangi
23ce888d65
Use colored/styled text output for diagnostics and usage info ( #1775 )
2025-08-04 17:02:24 -04:00
Rangi42
543b7fa6c2
Use std::nothrow for the only new expression
...
Ideally we'd use `std::make_shared`, but it has insufficient compiler
support for array types
2025-08-02 22:52:20 -04:00
Rangi
752b273aec
Extend RGBASM and RGBLINK verbosity flags to have multiple levels like RGBGFX ( #1772 )
2025-08-02 17:10:10 -04:00
Rangi42
b51056f743
Fix "while expanding symbol" error message
...
Fixes #1771
2025-08-01 16:25:44 -04:00
Rangi42
db2cda790c
Factor out a single consumeChar function
...
This and `peek` are the only functions that should call the low-level
`peekChar` and `peekCharAhead` methods.
2025-08-01 12:12:22 -04:00
Rangi42
86b43ea14f
Fix interpolation after empty string literal
2025-07-31 15:17:11 -04:00