Commit Graph

2399 Commits

Author SHA1 Message Date
Rangi 075f132d77 Use a smaller unordered_map just for looking up line-leading keywords 2026-05-27 22:01:20 -04:00
Rangi 31e1d2ec87 Do not build up a std::string when skipping leading keywords 2026-05-27 22:01:20 -04:00
Rangi 673c62414f Use std::string_view keys for UpperMap
This avoids constructing temporary `std::string` objects on lookup
2026-05-27 22:01:20 -04:00
Rangi 007672f080 Intern identifier strings only after checking for keywords 2026-05-25 23:55:57 -04:00
Rangi 996469ee28 Ensure CRLF line endings are preserved when necessary
Some test cases need CRLF line endings checked out even on Unix.
Also some source files had inadvertently contained CR bytes.
2026-05-25 22:00:45 -04:00
Rangi 55db252a8f Simplify the lexer by removing BufferedContent and inlining ViewedContent (#1981)
Instead of reading 64 characters at a time into a rolling buffer
as `shiftChar()` is called, we read 8192 characters at a time into
a complete buffer before any `peek()`/`shiftChar()` operations.
2026-05-25 21:05:59 -04:00
Rangi cfa0adf295 Intern strings used as identifiers (for labels, constants, macros, charmaps, etc) (#1980) 2026-05-25 16:22:29 -04:00
Rangi ed19806434 Don't hard-code std::string as the key type for InsertionOrderedMap 2026-05-25 14:21:18 -04:00
Rangi a0d96a0856 Factor out repeated expandedSymName logic 2026-05-25 14:21:18 -04:00
Rangi 4b992bfea5 Use the name of sym_GetPC() instead of hard-coding "@" again 2026-05-25 14:21:14 -04:00
Rangi 141a7fe22b Add assume checks for expected Token types, like RPNValue has for RPNCommands 2026-05-25 14:14:34 -04:00
Rangi 72a410c007 Encapsulate charmap_Init, like sym_Init 2026-05-25 13:54:26 -04:00
Rangi 090768e2c9 Some Expansion references can be const 2026-05-23 13:06:09 -04:00
Rangi 4a173130b9 Optimize skipToLeadingKeyword for the common ViewedContent case (#1968) 2026-05-22 19:06:12 -04:00
Rangi ef2f021892 Simplify sectError handling, without the need for an empty-string sentinel
The `errorNoTrace` case for the empty-string sentinel was unreachable,
so we can just have a `fatalNoTrace` error right away.
2026-05-22 18:17:25 -04:00
Rangi dce14fd4b8 Use C++20 concepts to require constraints on template parameters (#1977) 2026-05-22 17:54:34 -04:00
Rangi 728bed39d5 Do not support GCC 9 (#1978)
This will let us use C++20 features that GCC 9's experimental
C++20 support did not yet cover, such as "concepts".

This reverts some commits:
- 6bcd79b997
- d5ce5329ea
- 728d14879b
2026-05-22 16:46:46 -04:00
Rangi 48fcd9a0ca Use templates to reduce the redundant number-lexing functions (#1963) 2026-05-21 23:13:09 +02:00
Rangi d56dbbb4bf Refactor section creation errors, and simplify output for single errors (#1964) 2026-05-21 13:01:08 -04:00
Rangi c50a849757 Verbose tracing shows lexed and captured values (#1969) 2026-05-09 12:01:29 -04:00
Rangi be2d028ae6 Format getopt errors more like others (sentence case, quoted options) (#1966) 2026-05-09 13:27:34 +02:00
ISSOtm 1af8bdda16 Have CMake put RGBDS executables in our own dir
Not the top-level if we are part of a larger project!
2026-05-06 18:49:19 +02:00
Rangi42 f0161b41c8 Update readHexNumber for consistency with other routines 2026-04-29 12:31:00 +02:00
Rangi42 ca23210f18 Refactor and rename some numeric literal lexing for asm and linkerscript consistency 2026-04-29 12:15:14 +02:00
Rangi42 85e044f5be Use std::move when relevant in Token constructor 2026-04-28 13:32:45 +02:00
Rangi42 60e76b2da4 Avoid UB if new OOMs by removing std:nothrow 2026-04-28 13:28:32 +02:00
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
ISSOtm d5ce5329ea Fix compilation with GCC 9 2026-04-26 23:30:59 +02:00
ISSOtm 6bcd79b997 Revert "Derive operator!= from operator== (#1660)"
This reverts commit 993879a2ed.
2026-04-26 23:30:59 +02:00
Rangi42 0553491107 Replace a FIXME comment with an explanation of why we can't/won't "fix" it 2026-04-20 14:51:38 +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
Rangi42 12186fdccc Keep more non-declaration initialization within the for loop clause 2026-04-19 22:01:56 +02:00
Rangi 71dfab3365 Use charmapEntry to simplify charmap_HasChar 2026-04-17 15:39:30 -04:00
Rangi 20b11039c9 Keep trie edges sorted for O(log N) lookup 2026-04-17 15:39:30 -04:00
Rangi eb9e9c0f33 Replace charmaps' fixed-size 256-value array with a vector of pairs
This should save memory at the cost of O(n) instead of O(1) access,
which should be okay because the `next` vector is generally small.
2026-04-17 15:39:30 -04:00
ISSOtm 81edc27b6e Fix two warnings on MinGW 2026-04-16 00:57:33 +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
Eldred Habert 422e8eec20 Generate Bison output in CMake build tree (#1929)
Again, moving away from in-tree builds
2026-04-10 18:46:57 -04:00
Rangi 49a4da2235 Revert "Generate Bison output in CMake build tree"
This reverts commit 4577ff16bc.
2026-04-10 17:18:40 -04:00
ISSOtm 4577ff16bc Generate Bison output in CMake build tree
Again, moving away from in-tree builds
2026-04-10 22:56:59 +02:00
ISSOtm b430d5a8b8 Note why we are not using a CMake list to pass Bison flags 2026-04-10 22:33:54 +02:00
ISSOtm a5be1d886e Copy DLLs to appropriate dir for install-less Windows testing
Co-authored-by: vulcandth <6394873+vulcandth@users.noreply.github.com>
2026-04-10 18:01:16 +02:00
vulcandth c3b47abcc8 Use CPack for Windows packaging 2026-04-10 18:01:16 +02:00
Rangi 6e13779b8b Use C++-sryle static_cast, not C-style explicit cast
`uint32_t(param)` is actually functional notation of explicit casting,
not a direct constructor call. `uint32_t{param}` would be uniform
initialization syntax for a constructor call, but would not allow
narrowing from `uint64_t`. See issue #1904 for discussion.
2026-04-08 20:05:36 -04:00
Rangi 9b4b4a581b Check for overflow in fixed-point precision suffix (#1918)
Fixes #1917
2026-04-07 17:06:54 -04:00