musiKk / plyj

A Java parser written in Python using PLY.
Other
150 stars 69 forks source link

Fixed a parsing bug in MethodInvocation #14

Closed Algy closed 10 years ago

Algy commented 10 years ago

When parsing 'System.out.println("Yeay!")', We should get MethodInvocation(name='println', target=Name('System.out'), ...), not MethodInvocation(name=Name('System.out.println'), target=None).

Unfortunately, It parses the expression into the latter one. I fixed it.

Algy commented 10 years ago

Should I have sent the pull request pointing to a commit, not a branch?

musiKk commented 10 years ago

Thanks for the patch.

A lot of names actually cannot get resolved during parse time and require an additional pass that ascribes some meaning to that name. Looking at your example: Is System a package or a class? Is out an inner class of System or a field? I guess that's the reason why such expressions are always parsed as they currently are.

However you're probably right in that the last part of a name directly preceding parentheses is always a method name. I'm going to look into this.

musiKk commented 10 years ago

Well, I guess your version is better. I'm still not 100% sure whether it will hold forever because according to the Spec the name before the open parenthesis is just that: a (ambiguous) name. It is disambiguated in a later phase. If either disambiguation rules or the grammar change, this may have to be looked at again.

Thanks for your time!