fix(lexers): recognize TypeScript binary, octal and exponent literals

the typescript lexer only had three number rules, so literals like 0b1010, 0o17, 0XFF, 1e5 and 1_000 were split into a number and a name. this ports the javascript number rules, with the float rule also keeping a fraction and an exponent together (1.5e10) as before, and adds a testdata/typescript/number_literals fixture.
This commit is contained in:
dualfroz committed 2026-10-07 20:10:35 +02:00
1 parent e6499d1d6d
commit dc8e36e79b
3 files changed
+90 -3

No files matched your search

+9 -3
View File
@@ -275,13 +275,19 @@
<rule pattern="[$a-zA-Z_]\w*">
<token type="NameOther" />
</rule>
<rule pattern="[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?">
<rule pattern="\d+(\.\d*([eE][+\-]?\d+)?|[eE][+\-]?\d+)">
<token type="LiteralNumberFloat" />
</rule>
<rule pattern="0x[0-9a-fA-F]+">
<rule pattern="0[bB][01]+">
<token type="LiteralNumberBin" />
</rule>
<rule pattern="0[oO][0-7]+">
<token type="LiteralNumberOct" />
</rule>
<rule pattern="0[xX][0-9a-fA-F]+">
<token type="LiteralNumberHex" />
</rule>
<rule pattern="[0-9]+">
<rule pattern="[0-9][0-9_]*">
<token type="LiteralNumberInteger" />
</rule>
<rule pattern="&#34;(\\\\|\\&#34;|[^&#34;])*&#34;">