Skip to content

Commit

Permalink
Add error sentinel to scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
kolen committed Feb 14, 2024
1 parent fe36cfc commit d56092f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ module.exports = grammar({
$._attr_value_ruby_p, // ()
$._attr_value_ruby_s, // []
$._attr_value_ruby_b, // {}
$.ruby
$.ruby,

$._error_sentinel
],

rules: {
Expand Down
4 changes: 4 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,10 @@
{
"type": "SYMBOL",
"name": "ruby"
},
{
"type": "SYMBOL",
"name": "_error_sentinel"
}
],
"inline": [],
Expand Down
6 changes: 4 additions & 2 deletions src/scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ enum TokenType {
ATTR_VALUE_RUBY_P,
ATTR_VALUE_RUBY_S,
ATTR_VALUE_RUBY_B,
RUBY
RUBY,

ERROR_SENTINEL
};

class Scanner {
Expand Down Expand Up @@ -186,7 +188,7 @@ class Scanner {
}
}

if (valid_symbols[RUBY]) {
if (valid_symbols[RUBY] && !valid_symbols[ERROR_SENTINEL]) {
return scan_ruby(lexer);
}

Expand Down

0 comments on commit d56092f

Please sign in to comment.