Class: Collie::Linter::Rules::UndefinedSymbol
- Defined in:
- lib/collie/linter/rules/undefined_symbol.rb
Overview
Detects references to undeclared tokens or nonterminals
Instance Method Summary collapse
Methods inherited from Base
#autocorrectable?, #initialize
Constructor Details
This class inherits a constructor from Collie::Linter::Base
Instance Method Details
#check(ast, context = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/collie/linter/rules/undefined_symbol.rb', line 15 def check(ast, context = {}) symbol_table = context[:symbol_table] || build_symbol_table(ast) ast.rules.each do |rule| rule.alternatives.each do |alt| alt.symbols.each do |symbol| next if symbol_table.declared?(symbol.name) add_offense(symbol, message: "Undefined symbol '#{symbol.name}'") end end end @offenses end |