how to verify that the AST is empty? #969
-
how to verify that the AST is empty? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Why would you want to do that? Perhaps iterate the statements and counting them? You'd need the Beware that a script can become empty after optimization after Rhai removes all unnecessary statements so it depends on what you define as empty. Alternately you can just check whether a script is empty, but you'll get tripped up by comments. |
Beta Was this translation helpful? Give feedback.
-
to check if the script needs to be compiled in ast or if it has already been done |
Beta Was this translation helpful? Give feedback.
If you already have an
AST
then you should have compiled a script already... This is a poor way to detect whether a script is there because some scripts compile down to an emptyAST
.You can try using
Option<AST>
if you need to be sure.