ISSOtm
eb5af70d79
Add unsigned right shift operator
2022-02-05 20:12:15 +01:00
Rangi
20a26599a3
Simplify allocating multiple ds args
...
Dealing with indexes is only necessary for `strfmt`
2021-12-01 20:24:31 -05:00
Rangi
7bdfc9da23
Really don't use new as a variable name
2021-11-30 17:06:36 -05:00
Rangi
b9fd85470e
Reword docs now that SET is deprecated ( #946 )
...
- '=' constants are "variables" (not "mutable constants")
- EQU constants are "numeric constants" (not "immutable constants")
- EQUS constants are "string constants" (not "string equates")
- DS declarations are "static allocations" (not "variables")
2021-11-22 17:08:29 -05:00
ISSOtm
b04e71ed34
Use correct length type for Abs*Group
2021-11-21 18:28:42 +01:00
Rangi
8e2a164a32
Implement compound assignment operators for mutable constants
...
Fixes #943
2021-11-19 08:50:00 +01:00
Rangi
b76819792d
Deprecate SET in favor of =
...
`SET` is redundant with `=`, and is already the name of an instruction.
2021-11-19 00:05:49 +01:00
Rangi
3e945679ad
Standardize on "east const" (type const * not const type *)
...
Avoid "WARNING: Move const after static - use 'static const char'"
2021-11-18 09:12:00 +01:00
Rangi
e5552e27f2
strrstr can take and return char const *
2021-11-17 22:47:05 -05:00
Rangi
0bb815edc0
Implement -Wnumeric-string[=0|1|2] ( #935 )
...
Fixes #934
2021-11-12 23:09:35 +01:00
Rangi
47442941b6
Support ! operator for condition codes ( #720 )
...
Fixes #719
2021-11-02 00:16:52 +01:00
Rangi
80a376f045
Syntax errors resets the lexer right away
...
`DEF`, `REDEF`, etc disable EQUS expansion, and reading
macro or OPT arguments sets the lexer to raw mode.
Syntax errors resume normal parsing at the line's end,
but should resume normal tokenization even before that.
2021-05-22 16:08:55 -04:00
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
Rangi
5ad48851ed
Allow error messages for subsequent syntax errors ( #892 )
...
Fixes #891
2021-05-21 17:04:27 -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
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
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
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
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
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
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
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
2005ed1df9
Implement CHARLEN and CHARSUB
...
Fixes #786
2021-04-17 18:18:34 -04:00
Rangi
2c30ab8731
Allow OPT to modify -L
...
-L is a Boolean flag option, so you specify 'OPT L' or 'OPT !L'.
2021-04-18 00:11:18 +02:00
Rangi
c08cf783c8
Remove 'inline' from functions not in headers
2021-04-13 10:27:08 -04:00
Rangi
310d34c655
Comment on REG_SP and REG_AF both being 3
...
No instruction needs to distinguish them both
2021-03-31 18:41:42 -04:00
Rangi
363b3d0134
Flush stdout after PRINTLN
...
This allows debug PRINTLN statements to run even if
subsequent rgbasm directives cause a crash.
2021-03-31 11:22:41 -04:00
Rangi
aaa92659ea
Require a plus sign in ld hl, sp + <e8>
...
Fixes #810
2021-03-30 13:05:21 -04:00
Rangi
be877134e5
Remove support for ld bc/de/hl/sp for ld hl, bc/de/hl/sp
...
Fixes #811
2021-03-30 13:01:49 -04:00
Rangi
7e127a4e52
Don't expand string symbols in MACRO and FOR symbol names
...
Explicit {interpolation} can still achieve this, but
to match DEF, REDEF, and PURGE, these new directives that
define symbols do not expand string EQUS.
2021-03-19 01:48:36 +01:00
Rangi
b8093847dc
New definition syntax with leading DEF keyword
...
This will enable fixing #457 later once the old
definition syntax is removed.
2021-03-19 01:48:36 +01:00
ISSOtm
60019cf476
Fix a bunch of Clang warnings
...
As reported by #789
Should avoid relying on 32-bit int (for implicit conversions)
and account for more extreme uses of RGBDS.
2021-03-10 10:56:57 +01:00
Rangi
5e2bd35239
Factor out a 'plain_directive' parser rule similar to the reverted 'last_line'
...
Also expand on the comment explaining how the EOF-newline hack affects the parser
2021-03-02 20:46:17 -05:00
Rangi
6655e04ef0
Restore the "EOF-newline" lexer hack
...
This was removed in b3c0db218d
(along with two unrelated changes).
Removing this hack introduced issue #742 , whereby INCLUDing
a file without a trailing newline can cause a syntax error.
A more proper fix would involve Bison's tracking locations,
but for now the EOF-newline hack fixes the issue while only
affecting some reported errors (expecting "newline"
instead of "end of file").
Fixes #742
2021-03-02 16:53:56 -08:00
daid
5d6e0677d9
Fix error-related issues ( #773 )
...
* Mark `error` as a `format` function, to properly scan its format
* Fix the call to error() from parser.y:
- Use '%s' to avoid passing an arbitrary format
- Simplify yyerror overall
* Fix size parameter of %.*s format being an int... bonkers standard.
* Report the number of arguments required and provided on a STRFMT mismatch
* Add an assert to check for a very unlikely bug
2021-03-02 16:34:19 +01:00
Rangi
56071599e7
Allow trailing commas in bare lists
...
This applies to macro arguments, DB, DW, DL, DS,
PRINT, PRINTLN, EXPORT, PURGE, and OPT.
It also removes support for empty entries in DB/DW/DL.
(Deprecating it would require keeping parser support,
which is ambiguous with trailing commas.)
Fixes #753
2021-03-02 11:48:20 +01:00
Rangi
0774f5eb9d
Rename math.c/mymath.h to fixpoint.c/.h
...
This also changes the functions' prefix
from "math_" to "fix_".
2021-03-02 11:40:03 +01:00
Rangi
1dafc1c762
Allow empty macro arguments, with a warning
...
Fixes #739
2021-02-28 10:38:49 -08:00
Rangi
953f79c0d9
Support 'MACRO mac' as well as 'mac: MACRO' for defining macros
...
The new syntax is used in documentation, but
the old syntax is not yet deprecated.
2021-02-25 04:42:35 +01:00
Rangi
3c5e1caa7c
Disallow "." as a local label
...
Fixes #760
2021-02-25 04:40:42 +01:00
Rangi
d4028fff10
Prevent ELIF or ELSE after an ELSE
...
Fixes #749
2021-02-25 04:39:49 +01:00
ISSOtm
bee62076c6
Allow ENDC at EOF without a newline
2021-02-20 00:51:33 +01:00
Rangi
8c0275480c
Allow ds to take multiple values to repeat for a count ( #725 )
...
Fixes #722
2021-02-16 22:01:23 -05:00
Rangi
76d6ef8695
Implement LOAD UNION and LOAD FRAGMENT
...
Fix #632
2021-02-17 03:42:06 +01:00
Rangi
ee20d9010e
Make @ relative to the start of a ds even at link time
...
Fix #737
2021-02-16 22:47:07 +01:00