Support more syntax in linkerscripts (#1752)

* No need to use `locale`s

* Implement octal numbers, `_` digit separators, and `0x/0b/0o` prefixes in linkerscripts

* Refactor some functions out of `yylex`

* Support `\0` in linkerscripts
This commit is contained in:
Rangi
2025-07-16 15:00:02 -04:00
committed by GitHub
parent cf6e5fec63
commit 7f24d46d44
7 changed files with 209 additions and 109 deletions

View File

@@ -24,18 +24,20 @@ They are simply ignored.
.Pp
Keywords are composed of letters and digits (but they can't start with a digit); they are all case-insensitive.
.Pp
Numbers can be written in decimal format, or in binary using the
.Ql %
prefix, or in hexadecimal using the
.Ql $
prefix (hexadecimal digits are case-insensitive).
Note that unlike
.Xr rgbasm 5 ,
an octal
.Ql &
prefix is not supported, nor are
.Ql _
digit separators.
Numbers can be written in a number of formats.
.Bl -column -offset indent "Hexadecimal" "Possible prefixes"
.It Sy Format type Ta Sy Possible prefixes Ta Sy Accepted characters
.It Decimal Ta none Ta 0123456789
.It Hexadecimal Ta Li $ , 0x , 0X Ta 0123456789ABCDEF
.It Octal Ta Li & , 0o , 0O Ta 01234567
.It Binary Ta Li % , 0b , 0B Ta 01
.El
.Pp
Underscores are also accepted in numbers, except at the beginning of one.
This can be useful for grouping digits, like
.Ql 1_234
or
.Ql $ff_80 .
.Pp
Strings begin with a double quote, and end at the next (non-escaped) double quote.
Strings must not contain literal newline characters.
@@ -46,8 +48,9 @@ are supported, specifically
.Ql \e" ,
.Ql \en ,
.Ql \er ,
.Ql \et ,
and
.Ql \et .
.Ql \e0 .
Other backslash escape sequences in
.Xr rgbasm 5
are only relevant to assembly code and do not apply in linker scripts.