Odd because it doesn't even look at the function being called. It just uses the rule name, which has to be unique. I know there's a problem with "And" and "Or" rules because they don't output the rule name in the generated code, but that should have erred in the other direction (it moves backward/upward until it finds a comment representing a rule name). Oh, but I knew the line counter was off a bit... I thought it wouldn't matter because the lines would be sufficiently separated by braces and comments and code and such, but perhaps not. I should probably subtract one or whatever.
At least it gets close. I should also improve it by making it look not only at the rule name, but also the function and parameters. Then And and Or rules could work better.