-
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.
ALong with 'loop' statement, I have also implemented the 'break' statement. Loop is essentially a infinite loop which never stops. I generated unconditional jumps for it. Break statement simply jumps to the end of the loop body.
- Loading branch information
1 parent
ca56ed0
commit c5f99df
Showing
10 changed files
with
212 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
def __socket__() -> integer; | ||
def extern print_int(x: integer) -> void; | ||
def extern print(x: str) -> void; | ||
|
||
def main() -> void { | ||
let a: integer = __socket__(); | ||
def double_it(x: integer) -> integer { | ||
return x * 2; | ||
} | ||
|
||
def main() -> integer { | ||
let a: long = 1; | ||
let msg: str = "'a' is greater than 5. Exiting..."; | ||
loop { | ||
if (a > 5) { | ||
print(msg); | ||
break; | ||
} | ||
print_int(double_it(a)); | ||
a = a + 1; | ||
} | ||
return a; | ||
} |
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
Oops, something went wrong.