Module: Ibex::Codegen::SymbolLabels

Defined in:
lib/ibex/codegen/symbol_labels.rb

Overview

Builds human-facing symbol labels without changing Grammar IR identities.

Class Method Summary collapse

Class Method Details

.build(grammar) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/ibex/codegen/symbol_labels.rb', line 8

def self.build(grammar)
  labels = grammar.symbols.to_h { |symbol| [symbol.id, symbol.display_name || symbol.name] }
  grammar.productions.each do |production|
    expression = production.origin[:expression]
    labels[production.lhs] = expression if expression.is_a?(String)
  end
  labels
end