From 0a7938038bc6d5ede266cb0e38465582312331b5 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 8 Jul 2023 11:17:11 -0400 Subject: [PATCH] Make RuleSet#id read-only --- lib/propane/lexer.rb | 10 ++-------- lib/propane/rule_set.rb | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/propane/lexer.rb b/lib/propane/lexer.rb index 257ebae..cd6d6cf 100644 --- a/lib/propane/lexer.rb +++ b/lib/propane/lexer.rb @@ -24,14 +24,8 @@ class Propane } states = mode_info[:dfa].enumerate states.each do |state, id| - token = - if state.accepts && state.accepts.token - state.accepts.token.id - end - code_id = - if state.accepts && state.accepts.code_id - state.accepts.code_id - end + token = state.accepts && state.accepts.token && state.accepts.token.id + code_id = state.accepts && state.accepts.code_id && state.accepts.code_id state_table << { transition_table_index: transition_table.size, n_transitions: state.transitions.size, diff --git a/lib/propane/rule_set.rb b/lib/propane/rule_set.rb index 68e1705..3832a81 100644 --- a/lib/propane/rule_set.rb +++ b/lib/propane/rule_set.rb @@ -4,7 +4,7 @@ class Propane # @return [Integer] # ID of the RuleSet. - attr_accessor :id + attr_reader :id # @return [String] # Name of the RuleSet.