Implement greedy name parsing#2
Conversation
Schottkyc137
left a comment
There was a problem hiding this comment.
This looks really good! I feel like we're moving big steps into the right direction with this PR.
I have left some comments about what I think about some stuff you implemented, but most is up for discussion. Just let me know what you think.
4c60dbb to
566c862
Compare
|
I think I got all your comments. To better support bounded lookaheads I introduced a Calling the unbounded Let me know what you think. (We can also move the |
|
@Schottkyc137 Not sure if you missed it, or just didn't have time yet but here is a ping anyway :) |
|
Sorry about the delay, it's the latter :/ |
|
Oh okay. Sorry for the ping then 😅 |
566c862 to
15b2594
Compare
|
I haven't really considered it until now, but providing a bounded variant of I scanned through the LRM and found a few grammar rules which might benefit from it: While extracting the trailing parenthesized list from a name might not be a lot of trouble during analyzation, Do you see anything against it? |
Could you motivate for me why a separate |
So far I don't see anything against it. It should also be easy enough to revert, if the benefit isn't there. But for the examples you provided, this could make sense. |
It could be done either way, really. Using an absolute token index as bound instead of a relative token length is less housekeeping if you need to use the bound more than once. While implementing If that's not clear enough, take a look at I figured using absolute indices avoids a lot of headache :)
Perfect. I will give it a go then. |
I see, this makes sense to me now. Generally, I prefer not adding more fields to the |
|
I think I got all your comments worked in and I am happy with it. |
Nope, I think this is in a pretty good state now. This truly brings this project forward; name parsing was one of the things I was a bit worried about. Thanks a lot for putting in the work! |
I implemented a first version of name parsing.
As already discussed through Matrix chat, this first implementation cannot fully differentiate some constructs and therefore clumps some tokens together in a generic
Internal(...Tokens)node. This can be improved upon, but for simple names (especially selected names) it should work just fine.Also, I added some test to show how the resulting structure may look like. The resulting
SyntaxNodestructure and naming is up for debate.I implemented some (but definitely not all) of the name related production rules, like
association_list,rangeandsignature.The big TODO is parsing of
expressionandsubtype_indication. If there is a way to differentiate between these two on the fly, we could maybe avoid doing a second pass to parseInternal(...)nodes.