class SyntaxSuggest::LeftRightLexCount

Find 基于词法计数的匹配语法错误

用于检测缺失的元素对,例如每个关键字都需要一个 end,每个 ‘{’ 需要一个 ‘}’ 等。

示例

left_right = LeftRightLexCount.new
left_right.count_kw
left_right.missing.first
# => "end"

left_right = LeftRightLexCount.new
source = "{ a: b, c: d" # Note missing '}'
LexAll.new(source: source).each do |lex|
  left_right.count_lex(lex)
end
left_right.missing.first
# => "}"