-
Notifications
You must be signed in to change notification settings - Fork 154
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
Overloading child_nodes
in config.yml
#1268
Comments
What about Also if it's separated by category it wouldn't be possible to choose the order of fields belonging to different categories. I think renaming Regarding iterating child params, there could be a convenience method for that, that's indeed done a lot manually right now. |
@jemmaissroff in JRuby for the current AST we differentiate between child nodes and fields in that we have a childNodes() which only returns the child nodes of the current node. Non-nodes are fields (and actually we also save the child nodes as fields) but childNodes() is necessary for implementing a proper visitor. Ultimately though the only need to know child nodes from other fields (or types) is mostly to give the list of children to a visitor right? That must be done by looking for a type of node{,?,[]}. If we guaranteed child_nodes was only nodes I think that could allow type to be removed so long as cardinality specifier was still there somewhere. So:
could just become:
and so long as we are changing format we could go big (:smile:):
I guess this is maybe a good way to condense the size of config.yml. The thing I don't like about the idea is the notion that the current child_node order represents the syntactical order of all the elements. This is mostly helpful in looking up nodes in this file as a reference. It is trivial from order to know which element is which on a node (although the names are pretty good too so this is maybe not that important). |
I think order is not as helpful as you might think. For example on The other implication for ordering is the order in the struct. Ideally I think we should sort these based on the most efficient packing mechanism to make sure they don't cause any holes in the struct. I think this isn't an issue now, and certainly isn't something we need to think about for a while, but I figured I'd mention it. Overall, I'm very 👍 on this idea. Anything that makes it more readable. |
@kddnewton ah yeah I just looked at how |
There are 2 things in this issue: renaming - name: CallNode
fields:
minimal:
- name: receiver
type: node?
- name: arguments
type: node?
kind: ArgumentsNode
- name: block
type: node?
kind: BlockNode
- name: flags
type: flags
kind: CallNodeFlags
- name: name
type: string
full:
- name: call_operator_loc
type: location?
- name: message_loc
type: location?
- name: opening_loc
type: location?
- name: closing_loc
type: location? There might end up being some locations that we actually want to keep, so I think this delineation might be more useful. Closing for now, revisit later. |
@kddnewton two things for your last comment design:
|
I think TR wants both offsets AND line so there likely is a wrinkle there. |
I think it's enough to remove |
I’m looking at adding a flag to nodes, and realizing how much we’re overloading the term child_nodes in config.yml . We’re using child_nodes currently to mean params. A small, simple improvement would be renaming this. But overloading the term still leads to quite a bit of filtering and casing when actually generating the code.
I think it would be cleaner to separate out actual child nodes from other fields on a node (eg have fields on a node for child_nodes, locations, flags) to match how the templates are being used. We could define a params method which returns all of these when needed, but in most cases just use the filtered down nodes.
For example, something like this
could become:
depending on how we’d implement it, we could even get rid of the type on some of the less complicated fields.
The text was updated successfully, but these errors were encountered: