diff --git a/grammar.js b/grammar.js index a50f3ea..bc70d61 100644 --- a/grammar.js +++ b/grammar.js @@ -51,7 +51,7 @@ const PREC = { }; const DEC_DIGITS = token(sep1(/[0-9]+/, /_+/)); const HEX_DIGITS = token(sep1(/[0-9a-fA-F]+/, /_+/)); -const BIN_DIGITS = token(sep1(/[01]/, /_+/)); +const BIN_DIGITS = token(sep1(/[01]+/, /_+/)); const REAL_EXPONENT = token(seq(/[eE]/, optional(/[+-]/), DEC_DIGITS)); module.exports = grammar({ diff --git a/src/grammar.json b/src/grammar.json index b70fff3..1eab122 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -6130,7 +6130,7 @@ "members": [ { "type": "PATTERN", - "value": "[01]" + "value": "[01]+" }, { "type": "REPEAT", @@ -6143,7 +6143,7 @@ }, { "type": "PATTERN", - "value": "[01]" + "value": "[01]+" } ] } diff --git a/src/parser.c b/src/parser.c index 7f7fea1..3b18f7b 100644 --- a/src/parser.c +++ b/src/parser.c @@ -19332,6 +19332,8 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) { case 519: ACCEPT_TOKEN(sym_bin_literal); if (lookahead == '_') ADVANCE(172); + if (lookahead == '0' || + lookahead == '1') ADVANCE(519); END_STATE(); case 520: ACCEPT_TOKEN(anon_sym_SQUOTE);