Commit Graph

481 Commits

Author SHA1 Message Date
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
cb59119881 Use automatically-allocated std::string_view for macros 2024-03-25 11:33:17 -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
Rangi42
507439bc25 Refactor macro args to be owned collectively by their fstack contexts 2024-03-22 14:25:36 -04:00
Rangi42
b85c5cde8f Use std::shared_ptr for MacroArgs 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
ISSOtm
412073774c Refactor string-formatting routines to append to an existing string 2024-03-22 14:25:36 -04:00
ISSOtm
52e8e1f9fc Simplify \@ handling by using std::shared_ptr<std::string>
This has been relocated from macro.cpp to fstack.cpp, since both
MACRO and REPT/FOR nodes have their own unique `\@` values.
2024-03-22 14:25:36 -04:00
Sylvie
04405fb444 Use std::shared_ptr for fstack nodes (#1371) 2024-03-22 13:27:21 -04:00
Sylvie
dd43723e20 Use methods for RPN Expression (#1372) 2024-03-22 04:41:04 -04:00
Sylvie
f792580816 Only restore parent context's \@ value if it had one defined (#1366)
This way, if a child context initializes `\@`, the parent won't
reset it. And if the child context did not initialize `\@`,
then resetting it would be redundant.
2024-03-21 19:53:49 -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
Sylvie
fec2266dd8 Use std::string for string-formatted values (#1360)
* Use `std::string` for string-formatted values

* Make `formatString` and `formatNumber` be `const`
2024-03-19 07:43:18 +01:00
Rangi42
40db9d5cef Use std::string for lexer state paths 2024-03-18 14:42:05 -04:00
Rangi42
05d79d87f6 Pass std::string references to RPN functions 2024-03-18 14:42:05 -04:00
Rangi42
e96675be03 Pass std::string references to fstack functions 2024-03-18 14:42:05 -04:00
Rangi42
472d1bde06 Pass std::string references to symbol functions 2024-03-18 14:42:05 -04:00
Rangi42
6cabb8c9af Pass std::string references to output functions 2024-03-18 14:42:05 -04:00
Rangi42
7b11c528ef Pass std::string references to section functions 2024-03-18 14:42:05 -04:00
Rangi42
91164ac1b0 Pass std::string references to charmap functions 2024-03-18 14:42:05 -04:00
Sylvie
eb99fc8681 Use a std::unordered_map for looking up sections by name (#1357) 2024-03-13 19:45:52 -04:00
Rangi42
846a9411b9 Refactor FileStackNode::dump to not need a helper function 2024-03-10 14:14:34 -04:00
Sylvie
820f6b5b3c Consistently format type qualifiers like const on the right (#1347) 2024-03-10 12:21:52 -04:00
Rangi42
569b940b82 No need to manually do the Expression destructor's job 2024-03-09 19:33:53 -05:00
Sylvie
5681be1fd8 Use automatic allocation and std::move for RPN bytes (#1336) 2024-03-09 11:12:34 -05:00
Sylvie
53537cf9af Remove now-unnecessary enum keyword (#1338)
C++ does not need it
2024-03-08 19:40:41 -05:00
Rangi42
75cc12bb3d Use std::optional for fstack paths 2024-03-07 21:41:02 -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
Rangi42
84bedc7bbe Use automatic allocation for RPN reasons 2024-03-07 09:58:45 -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
Rangi42
053aa80951 Improve some const correctness in RGBASM 2024-03-06 13:53:03 -05:00
Rangi42
bd88787cb3 Use FileStackNode constructor to avoid std::monostate possibility 2024-03-05 14:22:29 -05:00
Sylvie
e74073e480 Run clang-format on everything (#1332) 2024-03-04 14:22:49 -05:00
Sylvie
b004648a13 Use std::variant for symbol values (#1331) 2024-03-04 08:55:33 -05:00
Rangi42
13904dc536 Remove EQUS callbacks for symbols
They're no longer used since `__FILE__` was removed
2024-03-03 21:26:44 -05:00
Sylvie
f8dab23e8f Use uncommented sizes for pointer-to-array arguments (#1329)
This is syntactically valid despite not being enforced, and
is a feature we already use elsewhere.
2024-03-03 19:43:08 -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
2e1b0b6421 Remove commented-out C-only macro features 2024-03-02 20:17:22 -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
2069a95e0f Use std::string for macro args 2024-03-02 05:23:15 -05:00
Rangi42
ba00cf5684 Use std::string for section names 2024-03-02 04:47:02 -05:00
Rangi42
b488d3a90f Use std::optional<std::string> for lexer expansion names 2024-03-02 04:34:42 -05:00