--
You received this message because you are subscribed to the Google Groups "ply-hack" group.
To post to this group, send email to ply-...@googlegroups.com.
To unsubscribe from this group, send email to ply-hack+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/ply-hack/-/SmlFGUBxU4cJ.
For more options, visit https://groups.google.com/groups/opt_out.
I also wrote a parser for Java but I just copied the grammar Java Developer Tools (JDT) for Eclipse uses. It turns out that this is actually a fairly complicated problem. Keep in mind that there is also the >>> operator which further complicates this. Add to that that Java has both type arguments as well as type parameters with different syntaxes. The grammar JDT uses creates new symbols in order to keep track how many brackets have been opened.
I hope it's OK to link my ported solution here. The juicy bits are:
- type arguments: https://github.com/musiKk/plyj/blob/41bce63c2a2bed6defd12e336b55c207b0cf0677/plyj/parser.py#L1129
- type parameters: https://github.com/musiKk/plyj/blob/41bce63c2a2bed6defd12e336b55c207b0cf0677/plyj/parser.py#L1275
By the way being fairly new to parsing I found the Java grammar extremely complex. Kudos for doing well so far.