-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add visitors to TESTed-AST to write better code #564
Comments
I have found that adding visitors to TESTed is significantly more complex than initially anticipated. The main issue lies in the way Union types are defined, for example: Value = Union[
NumberType, StringType, BooleanType, SequenceType, ObjectType, NothingType
]
Expression = Identifier | Value | FunctionCall
Assignment = VariableAssignment | PropertyAssignment
Statement = Assignment | Expression All other types in the TESTed-AST are classes (like assignments or NumberType). To make the The biggest challenge, however, arises when the output of a student evaluation is parsed and needs to be converted into a
Example: {
"data": [
{"data": "Hiccup", "type": "text", "diagnostic": null},
{"data": "Toothless", "type": "text", "diagnostic": null},
{"data": "Stoick", "type": "text", "diagnostic": null},
{"data": "Astrid", "type": "text", "diagnostic": null},
{"data": "Gobber", "type": "text", "diagnostic": null}
],
"type": "list",
"diagnostic": null
} This serialized output is passed as the typing.Union[
tested.serialisation.NumberType,
tested.serialisation.StringType,
tested.serialisation.BooleanType,
tested.serialisation.SequenceType,
tested.serialisation.ObjectType,
tested.serialisation.NothingType
] For my implementation, this type would need to match the |
Each language implements their own
generator.py
. Almost all of them have functions that look like the following:To write this better a visitor could be used. This way all the if-statements will be removed.
The text was updated successfully, but these errors were encountered: