Skip to content

Conversation

@AlexandrosAlexiou
Copy link

Fixes binary literals with underscore separators.

Problem:
BIN_DIGITS used /[01]/ instead of /[01]+/ causing parse errors:
val x = 0b1101_0010 // ERROR - couldn't parse

The regex matched single digits only, not digit groups.

Changes:

  • grammar.js: Changed BIN_DIGITS from /[01]/ to /[01]+/

Now matches one or more binary digits, consistent with:

  • DEC_DIGITS: /[0-9]+/
  • HEX_DIGITS: /[0-9a-fA-F]+/

Example:
val binary = 0b11010010_01101001 // Now works
val hex = 0xFF_EC_DE_5E // Already worked
val dec = 1_000_000 // Already worked

Tests: 111/111 pass

Fixes binary literals with underscore separators.

Problem:
BIN_DIGITS used /[01]/ instead of /[01]+/ causing parse errors:
  val x = 0b1101_0010  // ERROR - couldn't parse

The regex matched single digits only, not digit groups.

Changes:
- grammar.js: Changed BIN_DIGITS from /[01]/ to /[01]+/

Now matches one or more binary digits, consistent with:
- DEC_DIGITS: /[0-9]+/
- HEX_DIGITS: /[0-9a-fA-F]+/

Example:
  val binary = 0b11010010_01101001  // Now works
  val hex = 0xFF_EC_DE_5E          // Already worked
  val dec = 1_000_000              // Already worked

Tests: 111/111 pass
@github-actions github-actions bot added the grammar Related to the grammar label Nov 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

grammar Related to the grammar

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant