mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
ba0970cede
Also update test/dangling_else.con. See there for how if* cascades are handled in CON. It's actually kind of pretty. Also, take care to handle code deferred to after the if/if-else properly (ifpdistl, ifpdistg, ifcanseetartet). git-svn-id: https://svn.eduke32.com/eduke32@3534 1a8010ca-5511-0410-912e-c29ae57300e0
58 lines
1.3 KiB
Text
58 lines
1.3 KiB
Text
// In CON, the dangling else ambiguity is resolved in a very peculiar way:
|
|
// A cascade "ifP1 ifP2 ifP3 Stmt1 ... else Stmt2" is considered as if the
|
|
// predicates P1, P2, P3, ... are combined with a logical AND.
|
|
// So effectively, there is no ambiguity at all, and one of Stmt1 and Stmt2
|
|
// is guaranteed to be taken.
|
|
|
|
define Q 114
|
|
define GLOBAL 0
|
|
|
|
gamevar x 0 GLOBAL
|
|
// divisible by 2, 3, 5?
|
|
gamevar xm2 0 GLOBAL
|
|
gamevar xm3 0 GLOBAL
|
|
gamevar xm5 0 GLOBAL
|
|
|
|
state testelse
|
|
setvarvar xm2 x, modvar xm2 2
|
|
setvarvar xm3 x, modvar xm3 3
|
|
setvarvar xm5 x, modvar xm5 5
|
|
|
|
redefinequote Q ERROR: one path of if/else must be taken
|
|
|
|
ifvarn xm2 0
|
|
ifvarn xm3 0
|
|
ifvarn xm5 0
|
|
redefinequote Q x=%d is not divisible by either 2, 3 or 5
|
|
else
|
|
redefinequote Q x=%d is divisible by either 2, 3 or 5
|
|
|
|
qsprintf Q Q x
|
|
userquote Q
|
|
ends
|
|
|
|
onevent EVENT_ENTERLEVEL
|
|
setvar x 0
|
|
whilevarn x 31
|
|
{
|
|
state testelse
|
|
addvar x 1
|
|
}
|
|
endevent
|
|
|
|
// Test deferred code. This CON code doesn't make much sense, but check out
|
|
// the generated Lua code...
|
|
onevent EVENT_JUMP
|
|
ifpdistl 100 ifpdistg 0 ifcanseetarget
|
|
{
|
|
palfrom 32 32 32
|
|
ifcanseetarget
|
|
quote 29
|
|
ifcanseetarget
|
|
quote 30
|
|
setvar x 0
|
|
state testelse
|
|
}
|
|
else ifcanseetarget
|
|
quote 31
|
|
endevent
|