Regular expressions are used for finding patterns in a string. This is the key reason why I chose to use them to detect the commands. Currently, this is accomplished through a mixture of inheritance and the @dynamic_attributes decorator. To define a regular expression for a command, it is accomplished with a class attribute _syntax. While this is perfectly fine on the surface, it raises a clear issue.
Let's say that I'm using the svst.Metadata node, and I pass in the command META window_width = 852. This works fine, but if I pass in a version that has a typo, say METS window_width = 852, then it doesn't pass and gets recognized as a svst.UnknownSyntax node. This is undefined behaviour, since this would raise an error/qualm that only says "Unknown syntax". It should tell whether or not this was a typo.
To fix this, I think the .evaluate_syntax() function should instead take in a command, and evaluate its syntax to see if there is a close match. It should still raise the qualm, but it could be more precise about what exactly it thinks is wrong.
This is a challenging feature, but I think moving forward with this would be wise.
Regular expressions are used for finding patterns in a string. This is the key reason why I chose to use them to detect the commands. Currently, this is accomplished through a mixture of inheritance and the
@dynamic_attributes
decorator. To define a regular expression for a command, it is accomplished with a class attribute_syntax
. While this is perfectly fine on the surface, it raises a clear issue.Let's say that I'm using the svst.Metadata node, and I pass in the command
META window_width = 852
. This works fine, but if I pass in a version that has a typo, sayMETS window_width = 852
, then it doesn't pass and gets recognized as a svst.UnknownSyntax node. This is undefined behaviour, since this would raise an error/qualm that only says "Unknown syntax". It should tell whether or not this was a typo.To fix this, I think the
.evaluate_syntax()
function should instead take in a command, and evaluate its syntax to see if there is a close match. It should still raise the qualm, but it could be more precise about what exactly it thinks is wrong.This is a challenging feature, but I think moving forward with this would be wise.