Open d-u-d-e opened 1 week ago
Not sure about it. This is not like a true type system. For example it may be used by your IDE for auto completion, etc. It needs to be updated frequently if we add more types (e.g. a constant can be integral, float, ...), so the risk is becoming stale.
I think there is a typo there: an identifier is not an expression.
True!
In ASDL, identifier is a built-in type that represents function and variable names; they’re basically strings, but we want to distinguish them from string literals like "Hello, World!" because they appear in different parts of an AST. Since identifier is a built-in type, it has no children
It's an AST node that extends from a TreeNode
I have specified the type of the parent node an AST node wants because I think it's more clear this way. For example: since the FunctionDefinition AST node can only have the Program AST node as a parent (for now), I have forced the
__init__
method ofFunctionDefinition
to receive a Program AST node as a parent.I would leave it like this, and we can generalize in the future. What do you think @d-u-d-e?
@CremaLuca would you pass the generic
TreeNode
type instead of a specific one? This looks like the principle of clean code you told me, but in this case I don't think it fully applies.