Rangi
0068c1375c
Syntax error message hints to indent macro invocations
...
This message is only printed for identifiers parsed as
`T_LABEL` (since they're at the start of a line) but
already defined as macros. Otherwise it may not be
relevant, e.g. for `MyLabel;:` or `My Label::`.
2021-05-22 14:58:26 +02:00
ISSOtm
06ea7b20bf
Reinstate "empty filename" assertion in __FILE__ callback
...
This assertion was mentioned by a comment, but deleted for some reason.
2021-05-21 17:20:47 -04:00
ISSOtm
a3c4652bfd
Fix dead stores in charmap_ConvertNext
...
Also cleanup / rearrange some of the function while we're at it.
2021-05-21 17:20:47 -04:00
Rangi
5ad48851ed
Allow error messages for subsequent syntax errors ( #892 )
...
Fixes #891
2021-05-21 17:04:27 -04:00
ISSOtm
e3b7339dd6
Save UNION stack when using PUSHS as well
...
This allows using the latter within the former
2021-05-21 09:47:27 +02:00
ISSOtm
69d7f84502
Reset LOAD offset when changing SECTIONs
...
This would cause spurious section overflow messages, since the load offset
is added to the section's when computing its size.
2021-05-21 09:37:17 +02:00
Rangi
23721694ea
Comment that anonymous labels internally start with '!'
...
`startsIdentifier` should not accept this character so
anonymous labels won't conflict with nonymous ones.
2021-05-15 12:57:22 -04:00
ISSOtm
aa02958e18
Fix mandoc warnings
2021-05-15 12:23:05 +02:00
Rangi
6a5e2f439e
Fix the STRFMT documentation in rgbasm(5)
...
Fixes #886
2021-05-09 17:23:57 -04:00
Rangi
5a38f6e148
rgbasm supports "Q16.16" fixed-point literals
...
"Qm.n" signifies an m-bit two's complement integer
with n fractional bits.
<https://en.wikipedia.org/wiki/Q_(number_format) >
2021-05-06 23:17:08 -04:00
Eldred Habert
c06985a7ad
Fix incorrect lexing of "$ff00+c" ( #882 )
...
Fixes #881 by moving the task from the lexer to the parser.
This both alleviates the need for backtracking in the lexer,
removing what is (was) arguably a hack, and causes tokenization
boundaries to be properly respected, fixing the issue mentioned above.
Co-authored-by: Rangi <remy.oukaour+rangi42@gmail.com >
2021-05-05 02:04:19 +02:00
ISSOtm
75f1bcde31
Make SECTION size overflow non-fatal
...
Fixes #538
2021-05-04 15:34:20 +02:00
ISSOtm
8bbafb7200
Rename out_ functions in section.c to sect_
...
More consistent with convention used everywhere, and makes it easier to
know which file the functions come from.
2021-05-03 12:22:14 +02:00
ISSOtm
75ce230dce
Make UNION-related errors non-fatal
2021-05-03 10:57:14 +02:00
ISSOtm
1d01268249
Remove LOAD FRAGMENT
...
It's very troublesome, with flaky semantics and a very restricted use space.
2021-05-03 10:51:55 +02:00
ISSOtm
02cb5a0526
Avoid performing invalid actions on LOAD errors
...
These are rejected because they could lead to incorrect behavior,
so then don't do it...
2021-05-03 10:46:52 +02:00
Jakub Kądziołka
d360d03403
Enable address sanitizer in develop builds ( #834 )
...
Co-authored-by: ISSOtm <eldredhabert0@gmail.com >
2021-05-02 18:08:03 +02:00
Rangi
e9bfe849ad
Allow OPT to toggle -h
2021-05-02 11:06:53 +02:00
Rangi
665eb916a2
OPT L acts like -L and *dis*ables optimizing LD to LDH
...
Fixes #867
2021-05-02 11:06:53 +02:00
ISSOtm
dcb8c69661
Fix UAF in lexer capture
...
Fixes #689
2021-05-02 03:24:18 +02:00
ISSOtm
38a9a613da
Make data output outside of a SECTION non-fatal
2021-05-01 23:48:48 +02:00
Eldred Habert
21b59c4651
Reinstate PUSHS clearing the SECTION scope ( #870 )
...
* Reinstate PUSHS clearing the SECTION scope
Otherwise you can use `PUSHS` to simulate the old `ds -21`, and possibly cause bugs
* Have PUSHS push LOAD block state as well
It does not make sense not to, and coud cause bugs.
2021-05-01 23:30:09 +02:00
Rangi
ca36422ac9
Parse 'ld hl, sp - <e8>' correctly
...
Fixes #864
2021-05-01 11:08:01 +02:00
Rangi
8e4ba8d2e4
Allow REDEF for EQU constants
...
Fixes #853
2021-04-29 12:24:07 +02:00
Rangi
ee67f1039c
Fix REDEF EQUS behavior
...
Redefining an EQUS constant will now update its filename,
like redefining a SET/= constant.
Attempting to redefine as EQUS a non-EQUS constant will
print an appropriate error message.
This also standardizes on `sym` versus `symbol` as a
variable name (which pairs with `symName`).
2021-04-28 12:11:26 -04:00
Rangi
d37aa93a7d
Port some cleanup from the WIP 'strings' branch
...
This is mostly variable renaming
2021-04-28 11:58:56 -04:00
Rangi
bba532193b
Port some cleanup from PR #847
...
- Update some whitespace formatting
- Factor out some functions
- Free data after outputting to an object file
2021-04-28 11:58:56 -04:00
Rangi
3fdf01c0f5
Resolve some TODO comments
...
- `out_PushSection` should not set `currentSection` to NULL because
PUSHS, PUSHC, and PUSHO consistently keep the current section,
charmap, and options, even though the stack has been pushed.
- `Callback__FILE__` does not need to assert that `fileName` is not
empty because `__FILE__`'s value is quoted, and can safely be empty.
- `YY_FATAL_ERROR` and `YYLMAX` are not needed since the lexer is
not generated with flex.
2021-04-26 15:52:30 -04:00
Rangi
e050803ed1
Use size_t for measuring nested depths
...
Multiple functions involve tracking the current depth
of a nested structure (symbol expansions, interpolations,
REPT/FOR blocks, parentheses).
2021-04-23 14:28:10 +02:00
Rangi
27f38770d4
Parentheses in macro args prevent commas from starting new arguments
...
This is similar to C's behavior, and convenient for passing
function calls as single values, like `MUL(3.0, 4.0)` or
`STRSUB("str", 2, 1)`.
Fixes #704
2021-04-23 14:28:10 +02:00
Rangi
4d21588eb2
Make invalid UTF-8 characters in strings non-fatal
...
STRLEN and STRSUB report the erroneous bytes
Fixes #848
2021-04-22 09:59:02 +02:00
Rangi
e596dbfc80
Make failed macro arg expansions non-fatal
...
Expanding empty strings is valid but pointless;
macro args already skipped doing so, now other
`beginExpansion` calls do too.
This also fixes failed interpolations (which were
already non-fatal) to continue reading characters,
not evaluate to their initial '{' character.
2021-04-22 09:59:02 +02:00
Rangi
c3e27217dd
More specific "Symbol name too long" error messages
...
Identifiers, {interpolations} and \<macroArgs> are distinct
2021-04-20 17:14:21 +02:00
Rangi
fe3521c7a4
Switch from parentheses to angle brackets
...
`\(` is more likely to be a valid escape sequence in the
future (as is `\[`) and `\{` is already taken.
2021-04-20 17:14:21 +02:00
Rangi
7a314e7aff
Support numeric symbol names in \(parentheses)
...
For example, \(_NARG) will get the last argument
2021-04-20 17:14:21 +02:00
Rangi
637bbbdf43
Support multi-digit macro arguments in parentheses
...
This allows access to arguments past \9 without using 'shift'
2021-04-20 17:14:21 +02:00
Rangi
8230e8165c
Eliminate isAtEOF by changing yylex control flow
...
`yylex` calls `yywrap` at the beginning of the next call, after it
has set `lexerState->lastToken` to `T_EOB`.
2021-04-20 17:10:08 +02:00
Rangi
a727a0f81f
Capture termination status is equivalent to not having reached EOF
...
This avoids the need for a separate `terminated` flag
2021-04-20 17:10:08 +02:00
Rangi
7a587eb7d6
Use midrule action values for captures' terminated status
...
Bison 3.1 introduces "typed midrule values", which would write
`<captureTerminated>{ ... }` and `$$` instead of `{ ... }` and
`$<captureTerminated>[1-9]`, but rgbds supports 3.0 or even lower.
2021-04-20 17:10:08 +02:00
Rangi
7ac8bd6e24
Return a marker token at the end of any buffer
...
Removes the lexer hack mentioned in #778
2021-04-20 17:10:08 +02:00
Rangi
be2572edca
Track nested interpolation depth even outside string literals
...
Fixes #837
2021-04-20 09:37:29 -04:00
Rangi
cf2bbe6435
Position -1 is the last character of a string
...
Position 0 is invalid, which matches with STRIN/STRRIN
returning 0 on failure.
2021-04-20 14:27:59 +02:00
Rangi
dc5b7802c8
Make the len parameter optional in STRSUB(str, pos, len)
...
An unspecified length will continue to the end of the string.
2021-04-20 14:27:59 +02:00
Rangi
b1e6c73197
STRSUB and CHARSUB allow zero or negative positions
...
These are offsets from the end of the string, as if the
STRLEN or CHARLEN respectively were added to the position.
Fixes #812
2021-04-20 14:27:59 +02:00
Rangi
459773b3f0
Update some whitespace after Hungarian prefixes were removed
...
Keep the parameter alignment and 100-char line limit
2021-04-19 16:47:39 -04:00
ISSOtm
6d0a3c75e9
Get rid of Hungarian notation for good
...
Bye bye it was not nice knowing ya
2021-04-19 22:12:10 +02:00
Rangi
52797b6f68
Implement SIZEOF("Section") and STARTOF("Section") ( #766 )
...
Updates the object file revision to 8
Fixes #765
2021-04-17 18:36:26 -04:00
Rangi
5108c5643c
Let charmap_ConvertNext advance its output pointer
2021-04-17 18:18:34 -04:00
Rangi
2005ed1df9
Implement CHARLEN and CHARSUB
...
Fixes #786
2021-04-17 18:18:34 -04:00
Rangi
d43408f4f3
Allow OPT to modify -W
...
Warning flags are processed individually;
PUSHO and POPO (re)store all the warning states.
2021-04-18 00:11:18 +02:00