lib/treetop/compiler/node_classes/character_class.rb in treetop-1.2.0 vs lib/treetop/compiler/node_classes/character_class.rb in treetop-1.2.1

- old
+ new

@@ -2,18 +2,22 @@ module Compiler class CharacterClass < AtomicExpression def compile(address, builder, parent_expression = nil) super - builder.if__ "input.index(/#{text_value}/, index) == index" do + builder.if__ "input.index(/#{escaped_text_value}/, index) == index" do assign_result "(#{node_class_name}).new(input, index...(index + 1))" extend_result_with_inline_module builder << "@index += 1" end builder.else_ do "terminal_parse_failure(#{single_quote(characters)})" assign_result 'nil' end + end + + def escaped_text_value + text_value.gsub(/\/|#(@|\$)/) {|match| "\\#{match}"} end end end end \ No newline at end of file