Can't include a single ' in a curly block #26

Closed
drbrain opened this Issue Aug 1, 2013 · 0 comments

Projects

None yet

1 participant

@drbrain
Collaborator

For RDoc I was given a patch which added a "'" in the header section for the parser (a contraction in the comment block). This resulted in a syntax error.

I came up with this test:

diff --git a/test/test_kpeg_format.rb b/test/test_kpeg_format.rb
index 1be9af8..2157d09 100644
--- a/test/test_kpeg_format.rb
+++ b/test/test_kpeg_format.rb
@@ -431,6 +431,24 @@ a=b
     assert_equal expected, m.directives
   end

+  def test_parser_directive_single_quote
+    m = match <<-GRAMMAR
+%% header {
+# It's a bug I found
+}
+
+a=b
+    GRAMMAR
+
+    assert_rule G.ref("b"), m
+
+    expected = {
+      "header" => KPeg::Action.new("\n# It's a bug I found\n")
+    }
+
+    assert_equal expected, m.directives
+  end
+
   def test_parser_setup
     m = match "%% { def initialize; end }\na=b"
     assert_rule G.ref("b"), m

I'm not sure if it's possible to change curly to support unmatched ' though. Nothing came to mind after messing with it for a few minutes.

@evanphx evanphx closed this in a742e81 Apr 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment