Rangi
1dafc1c762
Allow empty macro arguments, with a warning
...
Fixes #739
2021-02-28 10:38:49 -08:00
Rangi
63d15ac8c9
append_yylval_tzString should always evaluate its argument
...
Fixes #762
2021-02-28 10:38:49 -08:00
Rangi
1f579deaff
Trim right whitespace from macro args before warning about length
2021-02-28 10:38:49 -08:00
Rangi
fad48326f8
Support /* block comments */ in macro arguments
...
Fixes #746
2021-02-28 10:38:49 -08: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
Eldred Habert
dafef5a953
Remove column 1 restriction for labels with colons ( #635 )
...
Partial fix for #457
2021-02-23 14:42:24 -05:00
ISSOtm
cd072d5e6a
Add assertion check for potential UAF trigger
...
It actually currently triggers if an INCLUDE directive is given at EOF,
but #742 will fix that.
2021-02-19 16:53:30 +01:00
ISSOtm
c29b616f93
Fix forgotten initialization of lexerState->isReferenced
2021-02-18 16:33:06 +01:00
Rangi
39c179aa32
Fix missing newline in a dbgPrint
2021-02-17 13:14:02 -05:00
Rangi
efbfeca292
Avoid two peek(1) calls when lexing """multi-line strings"""
2021-02-17 10:36:36 -05:00
Rangi
d049ffc0f0
Handle string literals within macro arguments ( #685 )
...
Fixes #683 and #691
The lexer's raw mode for reading macro args already attempted
to handle semicolons inside string literals, versus outside ones
which start comments. This change reuses the same function for
reading string literals in normal and raw modes, also handling:
- Commas in strings versus between macro args
- Character escapes
- {Interpolations} and \1-\9 args inside vs. outside strings
- Multi-line string literals
Macro args now allow escaping '\', '"', and '\\'.
A consistent model for expanding macro args and interpolations,
within macro args, string literals, and normal context:
- "{S}" should always equal the contents of S
- "\1" should always act like quoting the value of \1
2021-02-16 22:44:25 -05:00
Rangi
96bce05be2
Newlines in multi-line strings update the line number
...
This affects error and warning messages, and dbgPrint
2021-02-14 16:16:52 +01:00
Rangi
8415ce3ed0
Correct the keywordDict size
...
The stale keywords XDEF and GLOBAL were removed,
so there can be fewer keyword nodes.
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
70bbb098d3
Remove stale keywords
...
They were removed from the grammar, but not the lexer
2021-01-23 00:05:56 +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
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
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
7ce5cf1595
Convert floating to fixed point by rounding, not truncation
...
Fixes #678
2021-01-04 21:23:43 +01:00
Rangi
7e3fc1db03
Fix Actions CI for MSVC
...
Fixes #616
2021-01-04 02:01:25 +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
ISSOtm
bd244e6865
Remove deprecated features
...
Trimming off the fat!
- GLOBAL and XDEF keywords
- Colon-less global labels
- *-comments
2021-01-02 02:42:44 +01:00
Rangi
a70ecba06f
Implement PRINT and PRINTLN ( #672 )
...
Fixes #669
Closes #368
Closes #624
Deprecate PRINTT, PRINTV, PRINTI, and PRINTF
Default STRFMT("%f") to 5 fractional digits like "{f:}"
Any use of string formatting will share this default
2021-01-02 02:37:32 +01:00
Rangi
9d2d5cfcfe
Implement REDEF to allow redefining EQUS string equates
...
Fixes #677
2021-01-02 01:49:00 +01:00
Rangi
895ec5564d
Update mathematical functions ( #675 )
...
Document the existing `ROUND`, `CEIL`, and `FLOOR` functions
Also update the trig function docs for searchability
Implement `POW` and `LOG`
Addresses part of #675
Implement ** for integer exponents
** has higher precedence than -, like Python, so -3**4 == -(3**4) == 81
2021-01-02 01:39:20 +01:00
Rangi
7bb6f71f0b
Change FOREACH to FOR ( #680 )
2021-01-02 00:46:26 +01:00
Rangi
2a9d52871b
Make dbgPrint in lexer.c report the correct colNo ( #676 )
...
Fixes #656
2021-01-01 18:44:47 +01:00
ISSOtm
c4fb5591ee
Fix size of unterminated REPT/FOREACH blocks
...
Do not "uncapture" ENDR if it was not read in the first place
2020-12-30 15:52:24 +01:00
Rangi
c0ce1da4c3
Implement STRFMT and more printf-like format specifiers for string interpolation ( #646 )
...
Fixes #570
Fixes #178
Use errors for inapplicable format spec flags instead of -Wstring-format
2020-12-29 22:53:15 +01:00
Rangi
6874f694e5
Implement FOREACH ( #658 )
...
This acts like `REPT` with a variable automatically
incremented across a range of values
Fixes #432
2020-12-29 21:30:42 +01:00
ISSOtm
c20ac35074
Refactor readString
...
Much more readable, and avoids `peek(nz)`
2020-12-19 13:02:05 +01:00
Rangi
255b8bf9ba
Implement """triple-quoted""" multi-line strings
...
Fixes #589
2020-12-19 12:34:32 +01:00
Rangi
1d9cc01ae1
Macro arguments within a string literal are read into the string, not expanded
...
Fixes #643
2020-12-15 21:28:15 +01:00
ISSOtm
8f2a894b88
Add anonymous labels
...
Fix #497
2020-12-14 10:14:40 +01:00
Rangi
0e40543757
Implement \# to expand to all unshifted macro arguments
...
Fixes #596
2020-12-14 00:12:36 +01:00
Rangi
ce58f6d6be
Allow {symbol} interpolation outside of strings
...
Fixes #629
Closes #631
2020-12-13 23:53:16 +01:00
Rangi
861cb552c4
discardBlockComment sets lexerState->disableMacroArgs = true, like discardComment
2020-12-12 01:34:01 +01:00
ISSOtm
21b58b08b8
Fix not shifting CRLF at end of raw lines
...
Fixes line reporting errors on Windows
2020-12-10 15:37:50 +01:00
Rangi
af530859f0
Allow underscores in numeric literals
...
Fixes #539
Changes \@'s output to start with "_u", not "_", so it will be valid within labels but not numerics
2020-12-10 15:34:21 +01:00
Rangi
58739b0bf2
Implement STRRIN, like STRIN but searching from the right
2020-12-10 15:32:17 +01:00
ISSOtm
2b6d9cd1e0
Avoid using yytoken_kind_t
...
Apparently it was added in a fairly recent Bison version...
2020-12-10 13:32:18 +01:00
ISSOtm
9b6f01047c
Enable raw token types
...
Removes one layer of indirection for the parser, and helps remove all literals from the grammar
The latter preparing the next change
2020-12-09 21:22:05 +01:00
ISSOtm
462fd7539c
Prohibit nested macros
...
After discussion (starting there:
https://github.com/gbdev/rgbds/pull/594#issuecomment-706437458
), it was decided that plain nested macros should not be
allowed.
Since #590 is fixed, EQUS can be used as a workaround;
multiline strings (#589 ) will make that easier on the
user when implemented.
Fixes #588 , supersedes and closes #594 .
Additionally, closes #388 .
2020-12-09 10:44:39 +01:00
ISSOtm
f16e34b804
Fix captures beginning in expansions
...
Fixes #590
2020-12-09 09:54:55 +01:00