Open Holt59 opened 3 years ago
Best idea is to write a wizard and test it in the old parser :woman_shrugging:
The parser code isn't exactly nice to navigate and it's very, very loose with what it allows. I think the intent of Break
s is to exit the whole Select*
as soon as one is hit, otherwise it would fall through to the next cases afterwards, similar to a switch with fall-through in most programming languages.
Default
s look like they can go anywhere, and they're probably available in SelectOne
s because the two share pretty much the exact same implementation (e.g. they both use the Select
flow type). The intention is probably to put them at the end of SelectMany
statements, to catch cases where users selected nothing.
Also, don't put too much stock on the wizards in the tests
directory - the most complex wizards are missing from there, since almost all of them are under copyright.
Calling the Technical Readme a specification is a bit of a strong term - plus the parser itself doesn't obey it. For example, it allows this:
hw = "Hello World".len
... even though the Technical Readme claims that function calls need parentheses.
The parser code isn't exactly nice to navigate and it's very, very loose with what it allows. I think the intent of
Break
s is to exit the wholeSelect*
as soon as one is hit, otherwise it would fall through to the next cases afterwards, similar to a switch with fall-through in most programming languages.
Well, if this was the case, then the SelectMany
would not work I guess? Since there are Break
in SelectMany
. I'll check with the old parser if I have time.
Also, don't put too much stock on the wizards in the tests directory - the most complex wizards are missing from there, since almost all of them are under copyright.
Even if you don't put the wizards in the repository, could you put links to them somewhere (if these are available online) so that we can check them?
Even if you don't put the wizards in the repository, could you put links to them somewhere (if these are available online) so that we can check them?
Added that to the TODO list in #1
Edit: Beermotor also posted a link to a bunch of his wizards here. I haven't gotten around to adding them to the test suite, but none of them seem to use 'Default` either.
Thanks for the extra wizards, I'll try them when I can.
I checked a few things with the current release of Wrye Bash and
Break
statement is not mandatory and will perform fallthrough, both in SelectOne
and SelectMany
.Default
statement is used when nothing is selected in SelectMany
, and if the selected option does not have a Case
statement in SelectOne
.Also, I noticed that the Case
label can be written without quotes... I know you are fixing bad stuff in this parser, I am not sure if this was intentional. If so, maybe indicates this somewhere?
Also, I noticed that the Case label can be written without quotes... I know you are fixing bad stuff in this parser, I am not sure if this was intentional. If so, maybe indicates this somewhere?
What exactly do you mean by that? Something like this?
Case foo
Note 'bar'
Break
I'm not sure how the current parser handles this - does it read this as one of its weird bare strings? And what if foo is defined as a variable beforehand, i.e. would this work?
foo = "Option 1"
; ...
Case foo
Note 'bar'
Break
The bare strings thing is definitely a bad idea and should already not work anymore, all those bare strings will now get parsed as identifiers instead. The question here is then only if we want to allow the new parser to use variables for Case
s, or if I should restrict it to only literal strings.
Both works actually...
Case foo
Note 'bar'
Break
If there is a foo
variable, then the content of the foo
variable will be substituted, but if there is no variable foo
, the literal "foo"
is considered.
Also, the Default
in SelectOne
is actually used if the user select nothing... I am not familiar with Wrye Bash so I assumed SelectOne
meant "Select exactly one", but it seems to be "Select at most one"?
I think SelectOne
is at least supposed to be exactly one. It's possible that it's bugged, of course.
Me, again....
The specification+ for the
SelectOne
/SelectMany
+ Case / Default is not clear for me.Is each
Case
/Default
followed by exactly oneBreak
? For instance, is this valid (like in many language):If it is valid, what is the expected behavior? In particular for
SelectMany
? Case A implies A + B?If it is not valid, then I think it would be a good idea to explicitly add the
'Break'
in the grammar in theselectCaseList
rule.Also, is
Default
allowed to not be the last case? And isDefault
allowed inSelectMany
, in which case, is it run when nothing is selected?Edit: Well, actually, what is the purpose of
Default
? I assume withSelectOne
, the user has to select an option, so no default, and forSelectMany
... If none of the option was selected?None of the test wizards in
tests/
haveDefault
and all uses aBreak
afterCase
, so having this kind of rule:Would be very nice to write an interpreter :D
+ I am assuming this is the official specification : https://wrye-bash.github.io/docs/Wrye%20Bash%20Technical%20Readme.html, let me know if it's not !