Skip to content
This repository was archived by the owner on Jun 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #63 from thejoeejoee/develop
Browse files Browse the repository at this point in the history
Release [1.4.6]
thejoeejoee authored Nov 30, 2017
2 parents 7725c41 + 466e736 commit ae630fc
Showing 23 changed files with 360 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ifj2017/__init__.py
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
from os import path

__PROJECT_ROOT__ = path.join(path.abspath(path.dirname(__file__)), '..')
__version__ = version = '1.4.5'
__version__ = version = '1.4.6'
6 changes: 6 additions & 0 deletions ifj2017/tests/04_expressions/42.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
' maximum for C integer

scope
dim a as double = 1.79761e+308
print a;
end scope
4 changes: 4 additions & 0 deletions ifj2017/tests/04_expressions/tests.json
Original file line number Diff line number Diff line change
@@ -87,6 +87,10 @@
{
"name": "41",
"stdout": " 2147483647"
},
{
"name": "42",
"stdout": " 1.79769e+308"
}
]
}
10 changes: 10 additions & 0 deletions ifj2017/tests/13_cycles/02.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
' Basic UNTIL loop

scope
dim i as integer

do until i > 10
print i;
i = i + 1
loop
end scope
10 changes: 10 additions & 0 deletions ifj2017/tests/13_cycles/03.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
' Simple do ... loop while

scope
dim i as integer

do
print i;
i = i + 2
loop while i < 9
end scope
16 changes: 16 additions & 0 deletions ifj2017/tests/13_cycles/04.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'Infinite loop with exit

scope
dim i as integer

do
i = i + 1

if i > 10 then
exit do
else
i = i + 1
print i;
end if
loop
end scope
22 changes: 22 additions & 0 deletions ifj2017/tests/13_cycles/05.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'Continue in nested loops

scope
dim i as integer
dim j as integer

do while i < 10
j = 0
do until j > 8
j = j + 1
if i = 5 then
Continue do
else
j = j + 1
end if
print j;
loop

print !"\n";
i = i + 1
loop
end scope
31 changes: 31 additions & 0 deletions ifj2017/tests/13_cycles/06.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'Exit in nested loops

scope
dim i as integer
dim j as integer

do
i = i + 1
j = 0

do until j > 100
j = j + 1

if j > 10 then
exit do
else
i = i + 1
end if
print j;
loop

print i;

if i > 100 then
exit do
else
i = i + 1
end if
print !",";
loop
end scope
9 changes: 9 additions & 0 deletions ifj2017/tests/13_cycles/07.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'Simple for cycle

scope
dim i as integer

for i = 1 to 4
print i;
next
end scope
8 changes: 8 additions & 0 deletions ifj2017/tests/13_cycles/08.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'For loop with new variable

scope
for i as integer = 20 to 25
print i;
i = i + 1
next
end scope
7 changes: 7 additions & 0 deletions ifj2017/tests/13_cycles/09.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'For loop with step

scope
for i as double = 0.5 to 5.0 step 0.5
print i;
next
end scope
13 changes: 13 additions & 0 deletions ifj2017/tests/13_cycles/10.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'Nested do and for loops

scope
dim i as integer

do
for j as integer = i to i + 5
print j;
next
print !"\n";
i = i + 1
loop while i < 5
end scope
17 changes: 17 additions & 0 deletions ifj2017/tests/13_cycles/11.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'Exit from nested do loops (do, do)

scope
dim i as integer

do while i < 5
do while i < 3
print i;
if i >= 2 then
exit do, do
else
i = i + 1
end if
loop
i = i + 1
loop
end scope
10 changes: 10 additions & 0 deletions ifj2017/tests/13_cycles/12.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'Exit from nested loops (for, for)

scope
for i as integer = 3 to 6
for j as integer = i to 4
print j;
exit for, for
next
next
end scope
10 changes: 10 additions & 0 deletions ifj2017/tests/13_cycles/13.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'For next with iterator

scope
dim max as integer = 6
dim s as integer = 2

for i as integer = 0 to max step s
print i;
next i
end scope
27 changes: 27 additions & 0 deletions ifj2017/tests/13_cycles/14.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'Lots of computation with loops

function pow (b as integer, e as integer) as integer
dim result as integer = 1

for i as integer = 1 to e
result = result * b
next i
return result
end function

scope
dim i as double = 0 - 450
dim j as integer

for num as integer = 0 to 20 step 20
j = num
do while num > j - 19
i = i + num
num = num - 1
loop
i = i * 0.5
next num

i = pow (i, 3)
print i;
end scope
13 changes: 13 additions & 0 deletions ifj2017/tests/13_cycles/15.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'Iterator name collision

scope
dim i as integer

i = 20

for i as double = 0 to 1 step 0.125
print i;
next i

print i;
end scope
56 changes: 56 additions & 0 deletions ifj2017/tests/13_cycles/tests.json
Original file line number Diff line number Diff line change
@@ -3,6 +3,62 @@
{
"name": "01",
"stdout": " 20 19 18 17 16 15 14 13 12 11 11 10 10 9 9 8 8 7 7 6 6 5 5 4 4 3 3 2 2 1 1 0"
},
{
"name": "02",
"stdout": " 0 1 2 3 4 5 6 7 8 9 10"
},
{
"name": "03",
"stdout": " 0 2 4 6 8"
},
{
"name": "04",
"stdout": " 2 4 6 8 10"
},
{
"name": "05",
"stdout": " 2 4 6 8 10\n 2 4 6 8 10\n 2 4 6 8 10\n 2 4 6 8 10\n 2 4 6 8 10\n\n 2 4 6 8 10\n 2 4 6 8 10\n 2 4 6 8 10\n 2 4 6 8 10\n"
},
{
"name": "06",
"stdout": " 1 2 3 4 5 6 7 8 9 10 11, 1 2 3 4 5 6 7 8 9 10 23, 1 2 3 4 5 6 7 8 9 10 35, 1 2 3 4 5 6 7 8 9 10 47, 1 2 3 4 5 6 7 8 9 10 59, 1 2 3 4 5 6 7 8 9 10 71, 1 2 3 4 5 6 7 8 9 10 83, 1 2 3 4 5 6 7 8 9 10 95, 1 2 3 4 5 6 7 8 9 10 107"
},
{
"name": "07",
"stdout": " 1 2 3 4"
},
{
"name": "08",
"stdout": " 20 22 24"
},
{
"name": "09",
"stdout": " 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5"
},
{
"name": "10",
"stdout": " 0 1 2 3 4 5\n 1 2 3 4 5 6\n 2 3 4 5 6 7\n 3 4 5 6 7 8\n 4 5 6 7 8 9\n"
},
{
"name": "11",
"stdout": " 0 1 2"
},
{
"name": "12",
"stdout": " 3"
},
{
"name": "13",
"stdout": " 0 2 4 6"
},
{
"name": "14",
"stdout": " 6859000"
},
{
"name": "15",
"stdout": " 0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1 20"
}
],
"extensions": [
12 changes: 12 additions & 0 deletions ifj2017/tests/42_combination_of_extensions/06.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
' GLOBAL, SCOPE

scope
dim i as integer

do while i < 4
static counter as integer
counter = counter + 1
print counter;
i = i + 1
loop
end scope
8 changes: 8 additions & 0 deletions ifj2017/tests/42_combination_of_extensions/tests.json
Original file line number Diff line number Diff line change
@@ -49,6 +49,14 @@
"GLOBAL",
"IFTHEN"
]
},
{
"name": "06",
"stdout": " 1 2 3 4",
"extensions": [
"GLOBAL",
"SCOPE"
]
}
]
}
21 changes: 21 additions & 0 deletions ifj2017/tests/96_programs/14.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'Reverse string function

function Reverse_str(s as string) as string
dim str_len as integer = length(s)
dim reversed as string

dim i as integer
do while i < str_len
reversed = reversed + substr(s, str_len - i, 1)
i = i + 1
loop

return reversed
end function

scope
dim s as string
input s
s = reverse_str(s)
print s;
end scope
39 changes: 39 additions & 0 deletions ifj2017/tests/96_programs/15.code
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'Taylor polynom for log

function taylor_log(x as double, n as integer) as double
dim result as double
dim x_exp as double = 1
dim numerator_fraction as double
dim i as integer = 1

if x > 1 then
numerator_fraction = (x - 1) / x

do while i <= n
x_exp = x_exp * numerator_fraction
result = result + x_exp / i
i = i + 1
loop
else
x = 1 - x

do while i <= n
x_exp = x_exp * x
result = result - (x_exp / i)
i = i + 1
loop
end if
return result
end function

scope
dim d as double

input d
d = taylor_log(d, 10)
print d; !"\n";

input d
d = taylor_log(d, 20)
print d; !"\n";
end scope
10 changes: 10 additions & 0 deletions ifj2017/tests/96_programs/tests.json
Original file line number Diff line number Diff line change
@@ -39,6 +39,16 @@
"UNARY",
"FUNEXP"
]
},
{
"name": "14",
"stdin": "whatareversedstring",
"stdout": "? gnirtsdesreveratahw"
},
{
"name": "15",
"stdin": "12.25\n0.125",
"stdout": "? 2.24298\n? -2.06119\n"
}
]
}

0 comments on commit ae630fc

Please sign in to comment.