From d56092f2410ac248b2c7009da7f9788a7475dc9b Mon Sep 17 00:00:00 2001 From: kolen Date: Thu, 15 Feb 2024 01:32:31 +0300 Subject: [PATCH] Add error sentinel to scanner --- grammar.js | 4 +++- src/grammar.json | 4 ++++ src/scanner.cc | 6 ++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/grammar.js b/grammar.js index f18337d..b6e4702 100644 --- a/grammar.js +++ b/grammar.js @@ -39,7 +39,9 @@ module.exports = grammar({ $._attr_value_ruby_p, // () $._attr_value_ruby_s, // [] $._attr_value_ruby_b, // {} - $.ruby + $.ruby, + + $._error_sentinel ], rules: { diff --git a/src/grammar.json b/src/grammar.json index f5913ba..6689bb6 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -1579,6 +1579,10 @@ { "type": "SYMBOL", "name": "ruby" + }, + { + "type": "SYMBOL", + "name": "_error_sentinel" } ], "inline": [], diff --git a/src/scanner.cc b/src/scanner.cc index 1d33cd1..b555f4b 100644 --- a/src/scanner.cc +++ b/src/scanner.cc @@ -18,7 +18,9 @@ enum TokenType { ATTR_VALUE_RUBY_P, ATTR_VALUE_RUBY_S, ATTR_VALUE_RUBY_B, - RUBY + RUBY, + + ERROR_SENTINEL }; class Scanner { @@ -186,7 +188,7 @@ class Scanner { } } - if (valid_symbols[RUBY]) { + if (valid_symbols[RUBY] && !valid_symbols[ERROR_SENTINEL]) { return scan_ruby(lexer); }