Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,7 @@
|
|||
if (s == 'Hello World') {
|
||||
foo();
|
||||
} else if (s == 'Bye World') {
|
||||
bar();
|
||||
} else {
|
||||
deusEx();
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if(obj != null && obj.foo()){
|
||||
aMethod();
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if(obj != null & obj.foo()){
|
||||
aMethod();
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
s == 'Hello World' ? foo() : bar();
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
If 1
|
||||
YEP()
|
||||
End
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
!If 1
|
||||
NOPE()
|
||||
End
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
If 1
|
||||
YEP()
|
||||
Else
|
||||
NOPE()
|
||||
End
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
If 1=0
|
||||
NOPE()
|
||||
ElseIf 1=1
|
||||
YEP()
|
||||
Else
|
||||
NOPE()
|
||||
End
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
If 1=0
|
||||
NOPE()
|
||||
Else!If 1=2
|
||||
YEP()
|
||||
Else
|
||||
NOPE()
|
||||
End
|
||||
|
|
@ -0,0 +1 @@
|
|||
IF condition THEN PRINT "True"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
IF condition THEN
|
||||
PRINT "True"
|
||||
ELSE
|
||||
PRINT "False"
|
||||
ENDIF
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
IF choice=1 THEN
|
||||
PRINT "One"
|
||||
ELIF choice=2 THEN
|
||||
PRINT "Two"
|
||||
ELSE
|
||||
Print "None of the above"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
CASE choice OF
|
||||
WHEN 1
|
||||
PRINT "One"
|
||||
WHEN 2
|
||||
PRINT "Two"
|
||||
OTHERWISE
|
||||
PRINT "Some other choice"
|
||||
ENDCASE
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Dim a As Integer = 1
|
||||
If a = 1 Then
|
||||
sub1
|
||||
ElseIf a = 2 Then
|
||||
sub2
|
||||
Else
|
||||
sub3
|
||||
End If
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
Dim a As Integer = 1
|
||||
Select Case a
|
||||
Case 1
|
||||
sub1
|
||||
Case 2
|
||||
sub2
|
||||
Case Else
|
||||
sub3
|
||||
End Select
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Dim b As Boolean = True
|
||||
Dim i As Integer = IIf(b, 1, 2)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Dim a As Integer = 1
|
||||
On a Goto label1, label2
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Dim b As Boolean = True
|
||||
If b Goto label
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Dim a As Integer = 1
|
||||
On a Gosub label1, label2
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#DEFINE WORDSIZE 16
|
||||
#IF (WORDSIZE = 16)
|
||||
' Do some some 16 bit stuff
|
||||
#ELSEIF (WORDSIZE = 32)
|
||||
' Do some some 32 bit stuff
|
||||
#ELSE
|
||||
#ERROR WORDSIZE must be set to 16 or 32
|
||||
#ENDIF
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#DEFINE _DEBUG
|
||||
#IFDEF _DEBUG
|
||||
' Special statements for debugging
|
||||
#ENDIF
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#IFNDEF _DEBUG
|
||||
#DEFINE _DEBUG
|
||||
#ENDIF
|
||||
|
|
@ -0,0 +1 @@
|
|||
if <condition> then <truebranch> else <falsebranch>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
IF X THEN
|
||||
// do if X is not 0
|
||||
ELSE
|
||||
// do if X is 0
|
||||
END;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
CASE
|
||||
IF X == 1 THEN
|
||||
// do stuff if X equals 1
|
||||
END
|
||||
IF X == 2 THEN
|
||||
// do stuff if X equals 1
|
||||
END
|
||||
IF X == 3 THEN
|
||||
// do stuff if X equals 3
|
||||
END
|
||||
DEFAULT
|
||||
// do other stuff
|
||||
END;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
IF x == 1
|
||||
SomeFunc1()
|
||||
ELSEIF x == 2
|
||||
SomeFunc2()
|
||||
ELSE
|
||||
SomeFunc()
|
||||
ENDIF
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
DO CASE
|
||||
CASE x == 1
|
||||
SomeFunc1()
|
||||
CASE x == 2
|
||||
SomeFunc2()
|
||||
OTHERWISE
|
||||
SomeFunc()
|
||||
ENDCASE
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
SWITCH x
|
||||
CASE 1
|
||||
SomeFunc1()
|
||||
EXIT
|
||||
CASE 2
|
||||
SomeFunc2()
|
||||
EXIT
|
||||
OTHERWISE
|
||||
SomeFunc()
|
||||
ENDSWITCH
|
||||
20
Task/Conditional-structures/I/conditional-structures.i
Normal file
20
Task/Conditional-structures/I/conditional-structures.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
software {
|
||||
var a = 3
|
||||
|
||||
//This is not guaranteed to be quicker than a if-else chain.
|
||||
switch a {
|
||||
case 3
|
||||
print("3=3")
|
||||
case 2
|
||||
print("WHAT?")
|
||||
default
|
||||
print("3!=2")
|
||||
}
|
||||
|
||||
if a != 2
|
||||
print("3!=2")
|
||||
print("verified")
|
||||
else
|
||||
print("3=2!!!")
|
||||
end
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
BR or BRnzp ; unconditional branch, i.e.
|
||||
; branch if (result < 0 || result == 0 || result > 0)
|
||||
; ^ this is always true
|
||||
|
||||
BRn ; branch if (result < 0)
|
||||
BRz ; branch if (result == 0)
|
||||
BRp ; branch if (result > 0)
|
||||
|
||||
; or any combination of these condition codes, e.g.
|
||||
BRnz ; branch if (result <= 0)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
.orig x3000
|
||||
LD R1, x ; get x
|
||||
LD R2, y ; get y
|
||||
NOT R0, R2 ; R0 = ~y
|
||||
ADD R0, R0, 1 ; R0 = -y
|
||||
ADD R0, R0, R1 ; R0 = x - y
|
||||
BRZ BRANCH ; if (x == y) { go to BRANCH }
|
||||
LEA R0, nottaken
|
||||
PUTS ; else print "Branch Not Taken!"
|
||||
BR END
|
||||
BRANCH
|
||||
LEA R0, taken
|
||||
PUTS ; print "Branch Taken!"
|
||||
END HALT
|
||||
x .fill 1
|
||||
y .fill 1
|
||||
taken .stringz "Branch Taken!"
|
||||
nottaken .stringz "Branch Not Taken!"
|
||||
.end
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
che cosè var? # switch var
|
||||
minore di 0: # case var < 0
|
||||
...
|
||||
maggiore di 0: # case var > 0
|
||||
...
|
||||
o tarapia tapioco: # else (none of the previous cases)
|
||||
...
|
||||
e velocità di esecuzione
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
if(s == "Hello World")
|
||||
{
|
||||
foo();
|
||||
}
|
||||
else if(s == "Bye World")
|
||||
bar();
|
||||
else
|
||||
{
|
||||
baz();
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
if(obj isnt null and obj.foo())
|
||||
doSomething();
|
||||
|
|
@ -0,0 +1 @@
|
|||
var t = if(s == "Hello World") foo() else bar();
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
switch (num)
|
||||
{
|
||||
case (0)
|
||||
{ /* empty case requires braces */ }
|
||||
case (1)
|
||||
{ var one = "one"; result = one; }
|
||||
case (2,3) // case may contain a nonempty list of values
|
||||
result = "a few";
|
||||
default
|
||||
result = "a lot";
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
if x == 0:
|
||||
foo()
|
||||
elif x == 1:
|
||||
bar()
|
||||
elif x == 2:
|
||||
baz()
|
||||
else:
|
||||
boz()
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
case x
|
||||
of 0:
|
||||
foo()
|
||||
of 2,5,9:
|
||||
baz()
|
||||
of 10..20, 40..50:
|
||||
baz()
|
||||
else: # All cases must be covered
|
||||
boz()
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
aBoolean ifTrue: [ ...]
|
||||
aBoolean ifFalse: [ ... ]
|
||||
aObject ifNull: [ ... ]
|
||||
aObject ifNotNull: [ ... ]
|
||||
aObject ifZero: [ ... ]
|
||||
|
|
@ -0,0 +1 @@
|
|||
else: [ ... ]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Number virtual: sgn
|
||||
self isPositive
|
||||
ifTrue: [ self ==0 ifTrue: [ 0 ] else: [ 1 ] ]
|
||||
else: [ -1 ] ;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
var a = 5;
|
||||
if (a == 5) {
|
||||
doSomething();
|
||||
} else if (a > 0) {
|
||||
doSomethingElse();
|
||||
} else {
|
||||
error();
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
If x == 1
|
||||
SomeFunc1()
|
||||
But x == 2
|
||||
SomeFunc2()
|
||||
Else
|
||||
SomeFunc()
|
||||
Ok
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Switch x
|
||||
On 1
|
||||
SomeFunc1()
|
||||
On 2
|
||||
SomeFunc2()
|
||||
Other
|
||||
SomeFunc()
|
||||
Off
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
01010000000000100000000000000000 -10 to c
|
||||
00000000000000110000000000000000 Test
|
||||
01110000000000000000000000000000 14 to CI
|
||||
|
|
@ -0,0 +1 @@
|
|||
if cond then f else g end
|
||||
|
|
@ -0,0 +1 @@
|
|||
if cond then f elif cond1 then f1 .... else g end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
if empty then 2 else 3 end # produces no value
|
||||
if 1 then 2 else 3 end # produces 2
|
||||
if [false, false] then 2 else 3 end # produces 2
|
||||
if (true, true) then 2 else 3 end # produces a stream: 2, 2
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
exp
|
||||
| if . == true then "true"
|
||||
elif . == false then "false"
|
||||
elif . == null then "maybe"
|
||||
elif type == "string" then .
|
||||
else error("unexpected value: \(.)")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue