-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from KDesp73/dev
Dev
- Loading branch information
Showing
18 changed files
with
347 additions
and
58 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Design | ||
|
||
## Pre-defined methods | ||
|
||
- echo "Hello World" | ||
- exit `exit-code` (int) | ||
|
||
- run "path/to/script" -- Run external kd script (maybe handled by the preprocessor) | ||
|
||
- input() -- Should change | ||
- val(expression) -- Should change | ||
- str(expression) -- Should change | ||
|
||
## Blocks | ||
|
||
- if-else | ||
|
||
``` | ||
if condition { | ||
} else { | ||
} | ||
``` | ||
|
||
- while | ||
|
||
``` | ||
while condition { | ||
} | ||
``` | ||
|
||
- do-while | ||
|
||
``` | ||
do { | ||
} while condition | ||
``` | ||
|
||
- for | ||
|
||
``` | ||
for i in 2..3 { | ||
} | ||
``` | ||
|
||
## Functions | ||
|
||
``` | ||
# Declaration | ||
func name { | ||
} | ||
# Call | ||
call name | ||
# Call with arguments | ||
call name <- x, 2, 3 | ||
# Get return value | ||
a = call name <- 1.3 | ||
``` | ||
|
||
## Preprocessor | ||
|
||
``` | ||
#import "path/to/file" -- Include methods from file | ||
#assign A 2 | ||
#run "path/to/file" -- Run file as script | ||
``` | ||
|
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 +1,5 @@ | ||
echo "hello # world\n" | ||
# This should be removed | ||
|
||
echo "hello # world\n" # this should be removed | ||
|
||
# This should be removed |
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,13 +1,20 @@ | ||
func divisionByZero { | ||
a = 4 | ||
|
||
while a >= 0 { | ||
b = 12 / a | ||
echo "a: ", a, "\n" | ||
echo "b: ", b, "\n" | ||
echo 12, "/", a, "=", b, "\n" | ||
|
||
a = a - 1 | ||
} | ||
} | ||
|
||
func mod_example { | ||
i = 0 | ||
while i < 20 { | ||
echo i % 5, "\n" | ||
i = i + 1 | ||
} | ||
} | ||
|
||
#call mod_example | ||
call divisionByZero |
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,51 @@ | ||
func home { | ||
echo "Home selected\n" | ||
} | ||
|
||
func settings { | ||
echo "Settings selected\n" | ||
} | ||
|
||
func about { | ||
echo "About selected\n" | ||
} | ||
|
||
func exit { | ||
echo "Exiting...\n" | ||
} | ||
|
||
func menu { | ||
echo "1. Home\n" | ||
echo "2. Settings\n" | ||
echo "3. About\n" | ||
echo "4. Exit\n" | ||
echo "> " | ||
choice = val(input()) | ||
|
||
while choice < 1 | choice > 4 { | ||
echo "> " | ||
choice = val(input()) | ||
} | ||
|
||
if choice == 4 { | ||
call exit | ||
esc | ||
} | ||
|
||
|
||
if choice == 1 { | ||
call home | ||
} | ||
|
||
if choice == 2 { | ||
call settings | ||
} | ||
|
||
if choice == 3 { | ||
call about | ||
} | ||
|
||
call menu | ||
} | ||
|
||
call menu |
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 |
---|---|---|
|
@@ -21,4 +21,4 @@ func print_pyramid { | |
} | ||
} | ||
|
||
call print_pyramid | ||
call print_pyramid <- x, 2, 3 |
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 +1,11 @@ | ||
echo "Hello" echo " World\n" | ||
func test { | ||
a = 1 + 2 | ||
echo a, "\n" | ||
echo "Hello\n" | ||
|
||
exit a - 2 | ||
|
||
echo "World\n" | ||
} | ||
|
||
call test |
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.