-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
67 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
# from os import _exit | ||
from os import _exit | ||
from .global_var import output_error, console | ||
from .AST import stack | ||
|
||
def quit(code=0): | ||
output_error() | ||
console.postloop() | ||
stack.delete() | ||
exit(code) | ||
# _exit(code) | ||
_exit(code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
DECLARE test_num : INTEGER | ||
DECLARE t : REAL | ||
|
||
test_num <- 370 | ||
|
||
FUNCTION aux(n:INTEGER, acc1:INTEGER, acc2:INTEGER) RETURNS INTEGER | ||
IF n = 1 THEN RETURN acc1 ENDIF | ||
IF n = 2 THEN RETURN acc2 ENDIF | ||
RETURN aux(n - 1, acc2, acc1 + acc2) | ||
ENDFUNCTION | ||
|
||
t <- Time() | ||
OUTPUT "aux: " | ||
OUTPUT aux(test_num+1, 0, 1) | ||
OUTPUT Time() - t | ||
|
||
|
||
DECLARE arr : ARRAY[1:test_num] OF INTEGER | ||
FUNCTION fib(i:INTEGER) RETURNS INTEGER | ||
IF i = 1 THEN RETURN 1 ENDIF | ||
IF i = 2 THEN RETURN 1 ENDIF | ||
IF arr[i] <> 0 THEN RETURN arr[i] ENDIF | ||
arr[i] <- fib(i - 1) + fib(i - 2) | ||
RETURN arr[i] | ||
ENDFUNCTION | ||
|
||
t <- Time() | ||
OUTPUT "fib: " | ||
OUTPUT fib(test_num) | ||
OUTPUT Time() - t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,3 @@ | ||
DECLARE t1 : REAL | ||
DECLARE t2 : REAL | ||
|
||
FUNCTION aux(n:INTEGER, acc1:INTEGER, acc2:INTEGER) RETURNS INTEGER | ||
IF n = 1 THEN RETURN acc1 ENDIF | ||
IF n = 2 THEN RETURN acc2 ENDIF | ||
RETURN aux(n - 1, acc2, acc1 + acc2) | ||
ENDFUNCTION | ||
|
||
t1 <- PYTHON("from time import time; _result=time()") | ||
OUTPUT "aux: " | ||
OUTPUT aux(46, 0, 1) | ||
OUTPUT PYTHON("from time import time; _result=time()") - t1 | ||
|
||
|
||
FUNCTION fib(i:INTEGER) RETURNS INTEGER | ||
IF i = 1 THEN RETURN 1 ENDIF | ||
IF i = 2 THEN RETURN 1 ENDIF | ||
RETURN fib(i - 1) + fib(i - 2) | ||
ENDFUNCTION | ||
|
||
t2 <- PYTHON("from time import time; _result=time()") | ||
OUTPUT "fib: " | ||
OUTPUT fib(46) | ||
OUTPUT PYTHON("from time import time; _result=time()") - t2 | ||
DECLARE a : INTEGER | ||
a <- 1 | ||
OUTPUT a |