What if I had all the ifs?

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.

1 Like

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)


Like, test that the code works correctly?

Here’s how I’d structure this program:

run quicktest.html
print results
1 Like

Actually. In theory Choicescript IDE does that in execution time. Highlighting the brackets as you type them.

I say in theory because that feature is a little buggy.

There is a glitch in choicescript IDE that makes the application consider a " ] " as if it was the same of a " ) ". And that causes some errors…

1 Like

Useful. Can it also check the ‘rule of two’ because that’s the tricky one - i.e. pick up that ((a or b) or (c and d) and (e and f)) is incorrect?

1 Like