Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Specifying extension has odd precedence #20

glenjamin opened this Issue · 3 comments

2 participants


After digging around for a while, I discovered that this is actually documented, but I don't see why it would be implemented this way; the following rule:

rule a
  b c d { ruby_code}
rule d

attaches the extension to the instance of d used in the a rule, rather than to the a rule as I would have expected.


I'm not sure why the order of precedence is so strange in this case. If you were writing Ruby code, the block would bind tighter to the d than it would to any preceding symbols, unless you also used parentheses to change the order of precedence. My thinking in making the binding of extensions higher than that of sequences was to make it as similar to Ruby as possible.


While that does make sense, I can't see any case where it's useful (or neat) to bind a callback to one specific expression of a rule.

In the above fragment, it's far neater to put the block in the definition of d.


I agree that it's a bit messy to put the block on the end of a line with multiple nested method calls, but that's how Ruby works. I'd prefer to keep it that way to conform to the principle of least surprise.

@mjackson mjackson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.