Add filter support to selector grammar

Currently these are unimplemented but they can now be parsed
successfully since they are used by certain snippets.
This commit is contained in:
Kevin Sawicki 2013-08-06 16:57:52 -07:00
parent a72e1813e9
commit a98791ebd0
2 changed files with 19 additions and 1 deletions

View File

@ -21,6 +21,9 @@ describe "TextMateScopeSelector", ->
expect(new TextMateScopeSelector('a_b_c').matches(['a_b_c'])).toBeTruthy()
expect(new TextMateScopeSelector('a_b_c').matches(['a_b'])).toBeFalsy()
it "matches filters", ->
expect(new TextMateScopeSelector('R:g').matches(['g'])).toBeTruthy()
it "matches disjunction", ->
expect(new TextMateScopeSelector('a | b').matches(['b'])).toBeTruthy()
expect(new TextMateScopeSelector('a|b|c').matches(['c'])).toBeTruthy()

View File

@ -30,8 +30,21 @@ group
return selector;
}
filter
= prefix:([LRB]":") _ group:group {
return group;
}
/ prefix:([LRB]":") _ path:path {
return path;
}
expression
= "-" _ group:group _ {
= "-" _ filter:filter _ {
return new matchers.NegateMatcher(filter);
}
/ "-" _ group:group _ {
return new matchers.NegateMatcher(group);
}
@ -39,6 +52,8 @@ expression
return new matchers.NegateMatcher(path);
}
/ filter
/ group
/ path