Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Allow for quoted empty strings with double-quotes (fixes #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Dec 20, 2016
1 parent 4f92906 commit e4c22c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions parser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ hsla\(\s*[0-9]+\s*\,\s*[0-9]+\%\s*\,\s*[0-9]+\%\s*\,\s*([0-1]|0?\.[0-9]+)\s*\)
[0-9]+("."[0-9]+)?\b return 'NUMBER';
[a-zA-Z0-9-_.]+\b return 'STRING';
\'(\\[^\']|[^\'\\])*\' yytext = yytext.slice(1,-1); return 'STRING';
\"(\\[^\"]|[^\"\\])*\" yytext = yytext.slice(1,-1); return 'STRING';
"(" return 'LPAREN';
")" return 'RPAREN';
"==" return 'RELOP';
Expand Down
18 changes: 10 additions & 8 deletions parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ test('@if true { foo: bar } @else if false { bar: baz } @else { bat: quux }', 'f
test('@if false { foo: bar } @else if true { bar: baz } @else { bat: quux }', 'bar: baz');
test('@if false { foo: bar } @else if false { bar: baz } @else { bat: quux }', 'bat: quux');
test('@if \'\' == \'\' { foo: bar }', 'foo: bar');
test('@if "" == "" { foo: bar }', 'foo: bar');
test('@if \'\' == "" { foo: bar }', 'foo: bar');
test('@if "" == \'\' { foo: bar }', 'foo: bar');
test('@if \'foo\\bar\' == \'foo\\bar\' { foo: bar }', 'foo: bar');
test('@if .foo == .foo { foo: bar }', 'foo: bar');
test('@if .foo == .bar { foo: bar }', '');

0 comments on commit e4c22c2

Please sign in to comment.