I am working on a little side project to build a test tool for Choicescript. I was hoping that the lovely community could help me out.
The *IF command can take lots of different structures of brackets, ands, ors and variables and I’d like to compile a nice library of valid commands that I can validate my code against. Whilst I can construct my own examples, it’s useful to have real examples that my tool would need to correctly parse.
Could you please innundate me with examples of *IF commands from your code?
Whilst I only need one example of each unique structure (e.g., *IF (cond_a or cond_b) and cond_c) - It’s probably easier to just dump your examples here and for me to sift and categorise them afterwards.
I think rather than a number of examples, the main thing you need to check is that there is an equal number of left and right parentheses and that no pair of parentheses contains more than two choices. (this is one of the pains of choice script but that’s the way it is).
Thus, the following are really all the same check - one rule covers them all:
(a or b)
((a or b) or (c and d))
(((a or b) or (c and d)) or (d and f))
Writing a program to make this check is left as an exercise for the reader (ahem). There may be some hideously fiendish regular expression that does it but that’s beyond my skills.
(Note: the choice script interpreter must make this check - I don’t know whether that code is available, or whether one of the authors might give you a hint)