Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix <> matching pair for string boundrys
  • Loading branch information
adambeynon committed Jan 9, 2014
1 parent d33ae49 commit 37703ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -106,6 +106,8 @@

* Fix `Regexp.escape` to also escape '(' character.

* Support '<' and '>' as matching pairs in string boundrys `%q<hi>`.

## 0.5.5 2013-11-25

* Fix regression: add `%i[foo bar]` style words back to lexer
Expand Down
1 change: 1 addition & 0 deletions lib/opal/parser/lexer.rb
Expand Up @@ -797,6 +797,7 @@ def yylex
when '(' then term = ')'
when '[' then term = ']'
when '{' then term = '}'
when '<' then term = '>'
else paren = "\0"
end

Expand Down
8 changes: 7 additions & 1 deletion spec/cli/parser/string_spec.rb
Expand Up @@ -31,13 +31,19 @@
end

describe "from %Q construction" do
it "can use '[', '(' or '{' matching pairs for string boundry" do
it "can use '[', '(', '{' or '<' matching pairs for string boundry" do
parsed('%Q{foo}').should == [:str, "foo"]
parsed('%Q[foo]').should == [:str, "foo"]
parsed('%Q(foo)').should == [:str, "foo"]
parsed('%Q<foo>').should == [:str, "foo"]
end

it "can use valid characters as string boundrys" do
parsed('%q!Ford!').should == [:str, 'Ford']
parsed('%qaForda').should == [:str, 'Ford']
parsed('%q?Ford?').should == [:str, 'Ford']
end

it "can parse empty strings" do
parsed('%Q{}').should == [:str, ""]
parsed('%Q[]').should == [:str, ""]
Expand Down

0 comments on commit 37703ee

Please sign in to comment.