-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graph based droppability #186
base: master
Are you sure you want to change the base?
Conversation
…also hit common use case
857b01a
to
0f0db8f
Compare
return helper.ENCOURAGE | ||
else | ||
return helper.FORBID | ||
|
||
TreewalkParser.parens = (leading, trailing, node, context) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the similarly-worded "contexts" here (context (== node.parent), node.parseContext, and node.nodeContext.type) can get confusing. Can we omit the input argument's context and use the info from the node itself? (Also applicable to other places using argument context).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should rename context
-> parent
? One of the things having the argument gives us it that parens
can be called to "prepare" a node for dropping into a new spot before it actually gets dropped there (so node.parent != context
).
Perhaps parseContext can be named as parseContextType to reflect that it's a string type not a NodeContext object? |
I'm adding a few more high-level questions that I wanted to ask in the meeting:
|
Hmm, you're right. What do you think good names would be for I do not know if Dijkstra is essential; the graphs usually do not have a lot of edges so I think performance is not a huge problem (the library I found that finds shortest paths just happens to use it). It uses the path cost when it figures out how to wrap in parentheses; it seeks to wrap using the fewest number of parenthesis rules possible. For instance, when Right now CoffeeScript and JS still use custom droppability rules, implementing the |
How about "outmostClass" (for "parseContext") and "classComponents" (for "nodeContext")? I tried to avoid the words "context" and "type" that are already used in other places (e.g., "node.type", "context.type") with different implications from "nodeContext", "nodeContext.type", etc. |
Sorry, I overlooked that you are using the shortestPath() with costs involved. That probably justifies the use of tree and searching. |
@dabbler0 If you have "example-c.coffee," do you mind checking it in to whichever the up-to-date branch? Thanks! |
Restructures a lot of old code having to do with parenthesis wrapping and droppabilty. Things that were changed:
precedence
,socketLevel
, andclasses
fields, replacing them withparseContext
,nodeContext
, andshape
.parseContext
must always be a string that can be passed to the parser indicating what AST node to start the parse at when reparsing this node.nodeContext
must be an instance ofNodeContext
, and has information indicating how to un-paren-wrap this node.shape
is one of the oldsocketLevel
constants and represents whether to put a nubby in on the block.