Skip to content

Commit dfadef3

Browse files
committed
feat: support luajit binary number
1 parent 4fbec84 commit dfadef3

File tree

4 files changed

+497
-329
lines changed

4 files changed

+497
-329
lines changed

grammar.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,16 @@ module.exports = grammar({
353353
number_literal(hex_digits, 'p', decimal_digits)
354354
);
355355

356-
return token(choice(decimal_literal, hex_literal));
356+
const bin_digits = /[01]+/;
357+
const bin_literal = seq(
358+
choice('0b', '0B'),
359+
choice(
360+
seq(bin_digits, /U?LL/i),
361+
seq(bin_digits, optional(choice('i', 'I')))
362+
)
363+
);
364+
365+
return token(choice(decimal_literal, hex_literal, bin_literal));
357366
},
358367

359368
// LiteralString

src/grammar.json

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)