diff options
| author | Baitinq <[email protected]> | 2025-07-11 00:30:28 +0200 |
|---|---|---|
| committer | Baitinq <[email protected]> | 2025-07-11 00:32:50 +0200 |
| commit | 055fbcfb9db4087cde5f102c0753999f569b2f35 (patch) | |
| tree | 5f2189b3dfc89d725f6f372c9ca3cb05424c9ae1 /examples | |
| parent | Bootstrap: Support variable assignment (diff) | |
| download | pry-lang-055fbcfb9db4087cde5f102c0753999f569b2f35.tar.gz pry-lang-055fbcfb9db4087cde5f102c0753999f569b2f35.tar.bz2 pry-lang-055fbcfb9db4087cde5f102c0753999f569b2f35.zip | |
Bootstrap: Support addition
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/0.pry | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/examples/0.pry b/examples/0.pry index d0054f2..eb9f990 100644 --- a/examples/0.pry +++ b/examples/0.pry @@ -1,7 +1,79 @@ /* HELLO! Welcome to the unnamed language */ +extern printf = (*i8, varargs) => void; +extern exit = (i64) => void; + +let strcmp = (stra: *i8, strb: *i8) => bool { + let i = 0; + while i < 10 { + printf("I: %d\n", i); /* CONTINUE */ + i = i + 1; + }; + + return true; +}; + +let isdigit = (c: i8) => bool { + if c >= '0' { + if c <= '9' { + return true; + }; + }; + return false; +}; + +let isalpha = (c: i8) => bool { + if c >= 'a' { + if c <= 'z' { + return true; + }; + }; + if c >= 'A' { + if c <= 'Z' { + return true; + }; + }; + return false; +}; + +let isalphanum = (c: i8) => bool { + if isalpha(c) { + return true; + }; + if isdigit(c) { + return true; + }; + + return false; +}; + +let iswhitespace = (c: i8) => bool { + if c == ' ' { + return true; + }; + + if c >= '\t' { + if c <= '\r' { + return true; + }; + }; + + return false; +}; + +let assert = (cond: bool) => void { + if !cond { + printf("ASSERTION FAILED\n"); + exit(1); + }; + + return; +}; + let main = (argc: i64, argv: *i64) => i64 { printf("%d\n", argc); + isdigit('a'); + strcmp("a", "b"); return 2; }; |