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
Rangi
fc2bf3d11d
Prefer sizeof($$) to MAXSTRLEN + 1
...
This makes `strsubUTF8` similar to `strrpl` and `strfmt`
2021-02-14 16:16:52 +01:00
Rangi
ebb5aab6db
Correct some comments
...
nPCOffset no longer exists, and the lexer only
returns T_NEWLINE for EOF in raw mode.
2021-02-14 16:16:52 +01:00
ISSOtm
88e1cc7302
Make EOF token name consistent across Bison versions
...
The "end of file" name apparently only became a default recently
2021-02-11 13:04:43 +01:00
ISSOtm
b3c0db218d
Remove "EOF-newline" lexer hack
...
In preparation for an upcoming change
Makes for nicer error messages, complaining about EOF instead of newlines
The hack had to be kept for the lexer raw mode to avoid a bug;
see the relevant code comment for more info.
2021-02-11 12:48:37 +01:00
ISSOtm
76446e6d00
Change behavior of merging FRAGMENTs to constrain each fragment individually
...
Additionally, remove the deprecated merging of non-fragment SECTIONs
2021-02-10 10:19:16 +01:00
ISSOtm
70bbb098d3
Remove stale keywords
...
They were removed from the grammar, but not the lexer
2021-01-23 00:05:56 +01:00
ISSOtm
1926065377
Enable Bison warnings
...
-Wall should be old enough.
Also use %empty instead of comments
2021-01-23 00:05:56 +01:00
Rangi
e3d355d976
Attempt to recover from syntax errors with bison
...
Fixes #595
2021-01-22 15:54:24 +01:00
ISSOtm
a679e02246
Get rid of asm.h and localasm.h
...
No need to make them global
2021-01-22 13:34:16 +01:00
ISSOtm
fa0fa4d5ac
Significantly overhaul OPT code
...
Simplify the mess that was option setting (2 redundant variables !?)
Move options to a separate file
Have "modules" own their options, and OPT only access them (less redundancy)
Simplify code, respect naming conventions better
2021-01-22 10:41:09 +01:00
ISSOtm
1487eebe79
Remove time counter
...
Nobody uses that, and it requires running extra code for each line
2021-01-22 08:51:57 +01:00
Rangi
f28b4abafc
Fix a potential buffer overflow in strrpl
...
This caused an error using clang with -O3 -flto
2021-01-20 10:21:53 +01:00
Rangi
fb39c3a70e
Consistently refer to "directives", not "pseudo-ops"
...
Some docs and warnings already referred to SECTION and
db/dw/dl "directives", but others used "pseudo-ops".
2021-01-19 15:03:22 +01:00
Rangi
93d83e17dc
Don't override bison's internal 'yytnamerr' function
...
This is not used in all bison versions, which causes a
"defined but not used" warning for the 'rgbasm_yytnamerr'
replacement, treated as an error by 'make develop'.
2021-01-15 11:51:31 +01:00
Rangi
df16e64fc6
Handle MACRO and REPT/FOR bodies differently
...
Fixes #697
2021-01-15 02:16:37 +01:00
Rangi
eb4952c188
Use more verbose syntax error messages
...
Fixes #385
2021-01-14 18:36:10 +01:00
ISSOtm
57b734a7df
Reinstate RL into the _RS family
...
Removal of colon-less labels lifted the grammar ambiguity that
prevented `RL` from being usable as a variable declarator.
Thus, reinstate its functionality.
2021-01-11 01:38:03 +01:00
Rangi
cab9cb06a3
Store IF depth relative to each fstack context
...
This disallows starting/ending an IF inside an
INCLUDEd file or a macro expansion
2021-01-09 20:12:14 +01:00
Rangi
62bea23c49
Implement BREAK to exit REPT and FOR loops
...
Fixes #684
2021-01-08 21:13:23 +01:00
Rangi
77279984a5
Implement STRRPL
...
Fixes #660
STRRPL(str, "", new) does nothing
(warn about it with -Wempty-strrpl)
2021-01-04 00:20:35 +01:00