-
Notifications
You must be signed in to change notification settings - Fork 57
Grammar pattern matching ignoring 'end' rule #52
Comments
Cloning https://github.com/garborg/atom-language-test, |
Apologies, if you cloned my repo and the and had trouble testing -- I pushed the |
In case the previous example isn't simple enough for a quick response, here's a minimal example (the test.cson #...
patterns: [
{
include: "#p1"
}
{
include: "#p2"
}
]
repository:
p1:
begin: "cat"
end: "hat"
name: "p1.hat.test"
p2:
begin: "cat"
end: "boots"
name: "p2.boots.test" test-spec.coffee # ...
it "passes the baseline", -> # passes
{tokens} = grammar.tokenizeLine("catinhat")
console.log(tokens)
expect(tokens[0]).toEqual value: "cat", scopes: ["source.test", "p1.hat.test"]
expect(tokens[1]).toEqual value: "in", scopes: ["source.test", "p1.hat.test"]
expect(tokens[2]).toEqual value: "hat", scopes: ["source.test", "p1.hat.test"]
it "understands 'inboots' doesn't contain 'hat' but contains 'boots'", -> # fails
{tokens} = grammar.tokenizeLine("catinboots")
console.log(tokens)
expect(tokens[0]).toEqual value: "cat", scopes: ["source.test", "p2.boots.test"]
expect(tokens[1]).toEqual value: "in", scopes: ["source.test", "p2.boots.test"]
expect(tokens[2]).toEqual value: "boots", scopes: ["source.test", "p2.boots.test"] |
Context: This is coming up improving the grammar for Julia, where in between 'begin' and 'end', the contents may be nearly arbitrary Julia. Without a way around this, I can't see how to consistently differentiate between, say, a function call ( Is ignoring 'end' like this expected? Thanks. |
Reproduced. Also, as expected, if you move |
Is there anything I can do to help this along? I don't spend too much of my time in JS, but if someone pointed me to the right place to start, I'd be happy to take a look, with the caveat that if finding a fix meant stealing more developer time, I'd throw it back rather than creating extra work for everyone. |
Are any collaborators on this project planning to dig into this? Thanks, Sean |
Ping. I could also take a look and work under the same conditions that @garborg laid out. I just don't know where to look |
https://manual.macromates.com/en/language_grammars#language_rules The behavior that it only matches the first rule only is by design. |
Thanks, @Ingramz. I suppose this is a dead end then. It will unfortunately keep us from having reliable highlighting, etc., unless/until a more powerful grammar is supported in Atom. Here's what I found on that topic: Perhaps this close this once someone in the know links any other relevant discussions? |
A line matches the 'begin' pattern of two rules. It doesn't match the 'end' pattern for the first rule and does match the 'end' pattern for the second rule. I'd expect the second rule to win, but the first rule does.
Example at end.
Is this expected, and if so, any ideas on workarounds given that the contents between 'begin' and 'end' must match '$source' (or a large subset thereof)?
test-spec.coffee
test.cson
The text was updated successfully, but these errors were encountered: