Skip to content

Commit

Permalink
Handle strings in invoke args better
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Suraci committed Apr 17, 2011
1 parent a9be526 commit bc23db7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kpeg/format.kpeg
Expand Up @@ -56,7 +56,7 @@ sgl_escape_quote = "\\'" { "'" }

curly_block = curly
curly = "{" < (/[^{}"']+/ | string | curly)* > "}" { @g.action(text) }
nested_paren = "(" (/[^()]+/ | nested_paren)* ")"
nested_paren = "(" (/[^()"']+/ | string | nested_paren)* ")"

value = value:v ":" var:n { @g.t(v,n) }
| value:v "?" { @g.maybe(v) }
Expand Down
11 changes: 11 additions & 0 deletions test/test_kpeg_format.rb
Expand Up @@ -95,6 +95,17 @@ def test_invoke_with_arg
assert_equal "(1)", rule.op.arguments
end

def test_invoke_with_double_quoted_strings
m = match "a=b(\")\")"
assert_equal "(\")\")", m.find("a").op.arguments
end

def test_invoke_with_single_quoted_strings
m = match "a=b(')')"
assert_equal "(')')", m.find("a").op.arguments
end


def test_invoke_with_multiple_args
assert_rule G.invoke("b", "(1,2)"), match("a=b(1,2)"), "a"
end
Expand Down

0 comments on commit bc23db7

Please sign in to comment.