Commit Graph

191 Commits

Author SHA1 Message Date
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
0af1e512c2 Use std::get_if instead of std::visit (#1367)
`std::visit` is (arguably) cleaner code, but older versions of gcc
and clang (not very old; the ones packaged with Ubuntu 22.04 LTS)
compile them as tables of function pointers, instead of efficient
jump tables.
2024-03-20 22:37:54 -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
472d1bde06 Pass std::string references to symbol functions 2024-03-18 14:42:05 -04:00
Rangi42
ba104baf3e Refactor mapFile for Windows 2024-03-09 19:22:06 -05:00
Sylvie
17444e825a Reduce the header declarations (#1342)
- Since we have style rules to include foo.hpp at the top of its
  corresponding foo.cpp, this takes any headers included by foo.hpp
  as being also guaranteed for foo.cpp.

- Use C-style <foo.h> instead of <cfoo>, since the latter only
  guarantees putting symbols in the `std` namespace, which we are
  not using for C functions (e.g. `printf` not `std::printf`).

- Remove now-unused `__PRETTY_FUNCTION__` reporting
2024-03-09 14:55:39 -05:00
Sylvie
53537cf9af Remove now-unnecessary enum keyword (#1338)
C++ does not need it
2024-03-08 19:40:41 -05:00
Rangi42
aed172071b Replace some macros with static functions or constants 2024-03-07 16:10:05 -05:00
Rangi42
7663a777d5 Remove 255-character limit on symbol names 2024-03-07 12:40:37 -05:00
Rangi42
097b7c3baf Use std::string for symbol names 2024-03-07 12:40:33 -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
d1652c0028 Refactor cases for simplicity, and remove redundant comments 2024-03-06 14:10:50 -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
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
Sylvie
1ac3c0262f Refactor structs to use methods instead of functions (#1322) 2024-03-01 13:11:45 -05:00
Rangi42
e14ba664ea Remove redundant (void) parameter declarations 2024-03-01 10:41:47 -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
beb1997378 Use std::unordered_map for the keyword dict 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
6e03504802 Use std::deque for expansions 2024-02-29 13:44:08 -05:00
Rangi42
feb342804b Use std::stack for IF stack 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
Sylvie
c0d534f5ad No more flexible array members (not standard C++) (#1307)
* Replace FAMs with `std::vector`s (or one `std::string`) in four `struct`s

* Anonymous types declared in an anonymous union are also non-standard
  Only Clang complains about this (-Wnested-anon-types)
2024-02-22 16:22:37 -05:00
Sylvie
9cdd0b8a02 No more anonymous structs (not standard C++) (#1305)
This is one step to restoring `-pedantic` builds
2024-02-19 08:12:20 +01:00
Sylvie
ef0d973187 Truncate long format spec strings before using them (#1299)
Fixes #1293
2024-02-18 14:27:03 +01:00
Sylvie
66fd5a7062 Fix some usually disabled compiler warnings (#1286)
* Fixes from temporarily re-enabling more compiler warnings

* More edits suggested by cppcheck

* Fix hanging on append_yylval_string

* Fix FOR loop increment
2024-01-18 20:47:20 +01:00
Eldred Habert
fd78a9ae83 Port linkerscript parser to Bison (#1266)
Notable side effects:
* Use the standard-conformant MSVC preproc
* Add test for linker script INCLUDE
* Improve wording of placement conflict errors
* Fix errors from not newline-terminated files
* Teach checkdiff about the linker script doc
* Call linker script "commands" "directives" instead

---------

Co-authored-by: Rangi42 <remy.oukaour+rangi42@gmail.com>
2023-12-11 02:29:37 +01:00
Rangi
8eeb40cca8 Implement #"raw strings" (#1122)
Fixes #1121
2023-11-07 23:48:23 +01:00
Rangi
1e70e703a7 Build everything as C++ (#1176) 2023-11-07 21:45:56 +01:00