trystyncote / scripted-video

This is a project that attempts to produce an animation-looking video based on a given script.
MIT License
0 stars 0 forks source link

Change the use of svst.Node.evaluate_syntax() to not depend as strongly on regular expressions. #25

Closed trystyncote closed 1 year ago

trystyncote commented 1 year ago

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.

trystyncote commented 1 year ago

Closed in response to #26.