-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
indent capibability, for loop, bug fixes
- Loading branch information
Showing
11 changed files
with
222 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
nöff my_program | ||
nöff complex_program | ||
|
||
nöf num1 = 16 | ||
nöf num2 = d | ||
nöf count = 0 | ||
nöf limit = 5 | ||
|
||
slingshot cubic_root_num1 | ||
nör main_loop $limit | ||
oink "Current count: $count" | ||
add $count 1 | ||
når | ||
|
||
// function to cubic root the num1 | ||
pig cubic_root_num1 | ||
|
||
divide num1 1 | ||
|
||
oink "$num1" | ||
niff $count == $limit : slingshot end_program | ||
|
||
pig end_program | ||
oink "Program finished with count: $count" | ||
gip |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import start, error, variable | ||
|
||
|
||
def start_loop(): | ||
loop_name = get_loop_name_from_start_for_loops(start.line_number) | ||
try: | ||
only_loop_name = loop_name.split(" ", 2)[0] | ||
except: | ||
error.invalid_for_loop() | ||
|
||
loop_number = loop_name.split(" ", 2)[1] | ||
|
||
if variable.is_variable(loop_number): | ||
loop_number = variable.get_variable_value(loop_number) | ||
loop_number = int(loop_number) | ||
|
||
loop_number -= 1 | ||
change_loop_name(start.for_loops, start.line_number, | ||
only_loop_name + " " + str(loop_number)) | ||
|
||
def end_loop(): | ||
# get the start line number by the giving the end line number | ||
try: | ||
start_line, loop_name = get_start_line(start.for_loops, | ||
start.line_number) | ||
loop_number = loop_name.split(" ", 2)[1] | ||
except: | ||
error.invalid_for_loop() | ||
|
||
if variable.is_variable(loop_number): | ||
loop_number = variable.get_variable_value(loop_number) | ||
loop_number = int(loop_number) | ||
|
||
if int(loop_number) <= 0: | ||
pass | ||
else: | ||
start.goto_number = start_line | ||
|
||
def get_start_line(loops, end_line): | ||
for loop_name, (start_line, loop_end_line) in loops.items(): | ||
if loop_end_line == end_line: | ||
return start_line, loop_name | ||
return None | ||
|
||
def change_loop_name(loops, start_line, new_name): | ||
for loop_name, (loop_start_line, end_line) in list(loops.items()): | ||
if loop_start_line == start_line: | ||
loops[new_name] = loops.pop(loop_name) | ||
return | ||
error.loop_not_found(start_line) | ||
|
||
def get_loop_name_from_start_for_loops(start_line): | ||
for loop_name, (loop_start_line, end_line) in start.for_loops.items(): | ||
if loop_start_line == start_line: | ||
return loop_name | ||
return None |
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,8 +1,11 @@ | ||
import start | ||
import start, error | ||
|
||
|
||
def slingshot(line): | ||
slingshot_variable = line.split(" ", 1)[1] | ||
try: | ||
slingshot_variable = line.split(" ", 1)[1] | ||
except: | ||
error.invalid_slingshot() | ||
start.last_came.append(start.line_number + 1) | ||
start.goto_number = start.functions[slingshot_variable][0] + 1 | ||
|
Oops, something went wrong.