Skip to content

Commit

Permalink
Fix only: parsing bug
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
kevinastone committed Mar 5, 2016
1 parent 069056f commit 7462855
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.4.1 - 2016-03-05

- Fixed parsing bug for `only:` modifier

## 0.4.0 - 2016-03-05

- Added start-of-line (<<) and end-of-line (>>) position operators
Expand Down
18 changes: 9 additions & 9 deletions lib/grammar.js

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

2 changes: 1 addition & 1 deletion lib/grammar.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ positions =
identifier =
firstChar:[a-zA-Z_] suffix:[a-zA-Z0-9_-]* { return firstChar + suffix.join(''); }

only = "only:" / "=" { return "="; }
only = ("only:" / "=") { return "="; }
modifier = only:only { return only }

scopeSuffix =
Expand Down
18 changes: 18 additions & 0 deletions spec/grammar-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,34 @@ describe('Grammar', () => {
]);
});

it('should parse single part scope', () => {
expect(parse.parse('<- only:something')).toEqual([
[1],
['=', ['something']],
]);
});

it('should parse grouped scope', () => {
expect(parse.parse('<- =(something else)')).toEqual([
[1],
['=', ['something', 'else']],
]);
});

it('should parse grouped scope', () => {
expect(parse.parse('<- only:(something else)')).toEqual([
[1],
['=', ['something', 'else']],
]);
});

it('should not parse ungrouped scope', () => {
expect(() => parse.parse('<- =something else')).toThrow();
});

it('should not parse ungrouped scope', () => {
expect(() => parse.parse('<- only:something else')).toThrow();
});
});
});
});
Expand Down

0 comments on commit 7462855

Please sign in to comment.