From 37d6917b49a79bbd6f746193d5c87896b09cd0c2 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 27 Jul 2021 21:22:46 -0400 Subject: [PATCH] Rework Rule constructor --- lib/imbecile/grammar.rb | 1 + lib/imbecile/grammar/rule.rb | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/imbecile/grammar.rb b/lib/imbecile/grammar.rb index e1ac614..3581204 100644 --- a/lib/imbecile/grammar.rb +++ b/lib/imbecile/grammar.rb @@ -51,6 +51,7 @@ module Imbecile @tokens << Token.new(nil, pattern, @tokens.size) elsif input.slice!(/\A(\S+)\s*:\s*\[(.*?)\] <<\n(.*?)^>>\n/m) rule_name, rule, code = $1, $2, $3 + rule = rule.strip.split(/\s+/) @rules << Rule.new(rule_name, rule, code) else if input.size > 25 diff --git a/lib/imbecile/grammar/rule.rb b/lib/imbecile/grammar/rule.rb index 5733326..3e2f31b 100644 --- a/lib/imbecile/grammar/rule.rb +++ b/lib/imbecile/grammar/rule.rb @@ -9,9 +9,8 @@ module Imbecile attr_reader :code - def initialize(name, rule, code) + def initialize(name, rule_components, code) @name = name - rule_components = rule.split(/\s+/) @components = rule_components @code = code end