Skip to content

Commit

Permalink
Coerce state names into symbols instead of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ashmaroli committed May 31, 2019
1 parent 6c7da8a commit 0b44962
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rouge/regex_lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,18 @@ def self.start(&b)
# Define a new state for this lexer with the given name.
# The block will be evaluated in the context of a {StateDSL}.
def self.state(name, &b)
name = name.to_s
name = name.to_sym
state_definitions[name] = StateDSL.new(name, &b)
end

def self.prepend(name, &b)
name = name.to_s
name = name.to_sym
dsl = state_definitions[name] or raise "no such state #{name.inspect}"
replace_state(name, dsl.prepended(&b))
end

def self.append(name, &b)
name = name.to_s
name = name.to_sym
dsl = state_definitions[name] or raise "no such state #{name.inspect}"
replace_state(name, dsl.appended(&b))
end
Expand All @@ -204,7 +204,7 @@ def self.get_state(name)
return name if name.is_a? State

states[name.to_sym] ||= begin
defn = state_definitions[name.to_s] or raise "unknown state: #{name.inspect}"
defn = state_definitions[name.to_sym] or raise "unknown state: #{name.inspect}"
defn.to_state(self)
end
end
Expand Down

0 comments on commit 0b44962

Please sign in to comment.