Rangi42
d54619a453
Remove colNo column tracking from lexer
...
This was added as part of 71f88717 just for debug and fstack trace
output, but we no longer output it anyway.
2025-01-28 01:12:18 -05:00
Rangi42
b8b60207f5
Use // line comments not /* block comments
2025-01-27 20:12:12 -05:00
Rangi42
4e2464a69d
Replace some #define with constexpr
2025-01-04 03:53:59 -05:00
ISSOtm
610f04beeb
Fix condition for assuming at EOF
...
Part of that condition's purpose is to ensure that we read the correct
lexer state; but it's possible now for the fstack to be non-empty
*before* the lexer state is registered, i.e. if there is an error
in the function that registers it.
This causes a NULL pointer deref.
2024-09-05 17:48:52 +02:00
Sylvie
57c3d74b9e
Use a custom generic tagged union Either instead of std::variant for efficiency ( #1476 )
...
* Implement custom generic tagged union `Either`
This should be more efficient than `std::variant`, while still
keeping runtime safety as it `assert`s when `get`ting values.
* Use `Either` for RPN expressions
* Use `Either` for file stack node data
* Use `Either` for `File` buffer
* Use `Either` for `STRFMT` args
* Use `Either` for RGBLINK symbol values
* Support an equivalent of `std::monostate` for `Either`
* Use `Either` for lexer tokens
* Use `Either` for symbol values
* Use `Either` for lexer mmap/buffer state
2024-08-20 21:19:11 +02:00
Rangi42
39e9315e8a
Use a smaller size for the lexer buffer
...
Large sizes are more efficient when it's actually buffered,
but most of the time `mmap` is used instead, and the extra size
just slows down allocation of lexer states.
2024-05-17 20:59:42 -04:00
Sylvie
e2633d5b66
Use the standard stream buffer size for the lexer buffer ( #1396 )
2024-05-17 11:02:36 +02:00
Rangi42
b8387427a6
Use consistent RGBDS_<PROG>_<NAME>_HPP header guard convention
2024-04-14 21:50:05 -04:00
Rangi42
106e516962
Split the .peek() method into its next-char and lookahead cases
2024-03-28 15:37:25 -04:00
Rangi42
6f74e4fb9c
Remove the suboptimal .canPeek() and .peek() methods
2024-03-28 14:49:36 -04:00
Rangi42
83c0634f15
Refactor peekInternal to be a LexerState method
2024-03-28 13:21:28 -04:00
Rangi42
4172d330b9
Refactor BufferedContent and Expansion to have methods
...
Use a buffer size that is a power of two for fast modulus
2024-03-28 12:57:23 -04:00
Rangi42
b6039870e5
Remove now-redundant MmappedContent struct
2024-03-27 11:27:34 -04:00
Rangi42
78801e324c
Group pointer and size as a ContentSpan struct
2024-03-27 11:27:34 -04:00
Rangi42
bf0cabb3ea
Use std::shared_ptr for lexer capture buffers
2024-03-27 11:27:34 -04:00
Rangi42
32db0a0f18
Rename CaptureBody to Capture, and refactor its methods
2024-03-26 12:29:59 -04:00
Rangi42
a167d23d01
Use content-specific destructors for lexer state
...
Also rename `LexerState` content structs from `*LexerState` to `*Content`
2024-03-26 12:29:59 -04:00
Rangi42
2b44672873
Rename a few variables
2024-03-25 14:22:38 -04:00
Rangi42
d9e5e57e27
Make CaptureBufs be parser values instead of a single static global
2024-03-23 19:44:54 -04:00
Rangi42
e9e8915725
Refactor to keep lexerState and lexerStateEOL static
...
Also run `clang-format` on everything
2024-03-23 19:14:46 -04:00
Rangi42
6a5518e0c5
Use RAII to unmap or close the lexer states' files automatically
2024-03-22 14:25:36 -04:00
ISSOtm
e255af9e10
Do not limit strings to 255 characters
2024-03-22 14:25:36 -04:00
ISSOtm
9f239f6dcc
Use std::shared_ptr<std::string> for lexed/parsed strings
2024-03-22 14:25:36 -04:00
Sylvie
0300971a17
Fix some header #includes with clangd LSP ( #1370 )
...
Co-authored-by: ISSOtm <eldredhabert0@gmail.com >
2024-03-21 15:13:10 -04:00
Rangi42
40db9d5cef
Use std::string for lexer state paths
2024-03-18 14:42:05 -04:00
Sylvie
53537cf9af
Remove now-unnecessary enum keyword ( #1338 )
...
C++ does not need it
2024-03-08 19:40:41 -05:00
Rangi42
097b7c3baf
Use std::string for symbol names
2024-03-07 12:40:33 -05:00
Rangi42
bf45ebb178
Run clang-format to fix some inconsistent style
2024-03-07 11:52:53 -05:00
Sylvie
292adb27a3
Adapt the RGBASM parser to C++ ( #1333 )
...
This uses variants instead of a `%union`, and "complete symbols"
that can call complex constructors.
2024-03-06 20:40:36 -05:00
Sylvie
e74073e480
Run clang-format on everything ( #1332 )
2024-03-04 14:22:49 -05:00
Sylvie
8cf446b14c
Use std::variant for lexer mmap/buffer state ( #1328 )
2024-03-03 18:45:50 -05:00
Rangi42
277ea9be28
Replace RGBASM non-null pointers with references
2024-03-03 00:57:03 -05:00
Rangi42
19bb12754b
Use new allocation for expanding \#
2024-03-02 08:04:59 -05:00
Rangi42
dbcb82799e
Use std::vector for capture buffer
2024-03-02 06:46:11 -05:00
Sylvie
a71e4086a2
Use std::string_view for macro bodies ( #1326 )
...
This removes the last use of `strdup`
This required making a lot of related pointers be `const`.
That in turn conflicted with the need to `munmap()` a pointer
eventually, which was similar to the need to eventually `free()`
an `Expansion`'s contents, so I used the same solution of a
`union`. That lets us normally use the `const` pointer for
`const` correctness, and the non-`const` one for the not-really-
mutating destruction cases.
2024-03-02 13:21:28 -05:00
Rangi42
b488d3a90f
Use std::optional<std::string> for lexer expansion names
2024-03-02 04:34:42 -05:00
Rangi42
e14ba664ea
Remove redundant (void) parameter declarations
2024-03-01 10:41:47 -05:00
Rangi42
91d22f180e
Reorganize the asm parser to be more like the linker script parser
...
Split the declarations into those required for the `%union` and
those only required for the `code`.
Only declare functions on top; define them at the bottom.
2024-02-29 16:23:53 -05:00
Sylvie
043db49676
Replace NULL with nullptr ( #1321 )
2024-02-29 15:06:33 -05:00
Sylvie
eff8c324c8
Remove now-unnecessary struct keyword ( #1320 )
...
C++ acts like structs are `typedef`ed by default
We do have to keep `struct stat`, since there's ambiguity
with the function also called `stat`.
2024-02-29 14:41:58 -05:00
Rangi42
d1fa5ccd4d
Rename lexer_DeleteState to lexer_CleanupState
2024-02-29 13:44:08 -05:00
Rangi42
af055ecd27
Use automatic allocation for IF stacks and expansions
...
Switch to using `std::deque` for IF stacks (supports `.clear()`)
2024-02-29 13:44:08 -05:00
Rangi42
31836967fa
Use automatic allocation for lexer states
...
Lexer states are now owned by fstack contexts
2024-02-29 13:44:08 -05:00
Rangi42
843f3394c8
Use automatic allocation for DS args
2024-02-29 13:44:08 -05:00
Rangi42
b1aa98b43d
Use automatic allocation for PURGE args
2024-02-29 13:44:08 -05:00
Sylvie
595c066c2a
Remove #include <stdbool.h> ( #1317 )
2024-02-24 10:51:46 -05:00
Sylvie
54d6a22d19
Build with pedantically standard C++ ( #1309 )
...
* Remove array designators (not standard C++)
* Build with pedantically standard C++
2024-02-23 16:46:53 -05:00
Rangi
756f2866bb
Refactor alignment spec parsing ( #1253 )
2023-11-25 00:06:05 +01:00
Rangi
46e29de66f
Implement ds align[alignment, offset] ( #1181 )
2023-11-21 23:57:47 +01:00
Rangi
1e70e703a7
Build everything as C++ ( #1176 )
2023-11-07 21:45:56 +01:00