Skip to content

Commit

Permalink
update examples for The Great Renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
MESYETI committed Dec 15, 2024
1 parent 5beed9e commit 952a5ee
Show file tree
Hide file tree
Showing 36 changed files with 97 additions and 97 deletions.
4 changes: 2 additions & 2 deletions examples/add_args.cal
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ include "std/conv.cal"
include "std/io.cal"

if get_args_length 3 < then
"Required parameters: a b\n" printstr
"Required parameters: a b\n" print_str
1 exit
end

let Array arg
1 &arg get_arg &arg parse_int
2 &arg get_arg &arg parse_int
+ printdec new_line
+ print_dec new_line

4 changes: 2 additions & 2 deletions examples/alias.cal
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ include "cores/select.cal"
include "std/io.cal"

alias int cell
"int.sizeof = " printstr int.sizeOf printdec new_line
"int.sizeof = " print_str int.sizeOf print_dec new_line

let int myInt
65 -> myInt
myInt printdec new_line
myInt print_dec new_line
2 changes: 1 addition & 1 deletion examples/arithmetic.cal
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ include "cores/select.cal"
include "std/io.cal"
include "std/common.cal"

2 2 + 3 * 4 / 10 % printdec
2 2 + 3 * 4 / 10 % print_dec
6 changes: 3 additions & 3 deletions examples/arrays.cal
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ include "std/array.cal"
let Array myArray
[u16 1 2 3 4 5] &myArray a<

0 &myArray a@ printdec 10 printch
1 &myArray a@ printdec 10 printch
0 &myArray a@ print_dec 10 print_ch
1 &myArray a@ print_dec 10 print_ch

100 2 &myArray a!
2 &myArray a@ printdec 10 printch
2 &myArray a@ print_dec 10 print_ch
2 changes: 1 addition & 1 deletion examples/break_continue.cal
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let cell i

while 1 do
i 1 + -> i
i printdec new_line
i print_dec new_line

if i 5 = then
break
Expand Down
6 changes: 3 additions & 3 deletions examples/cat.cal
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include "std/io.cal"
include "std/args.cal"

if get_args_length 2 < then
"Required parameter: path\n" printstr
"Required parameter: path\n" print_str
0 exit
end

Expand All @@ -14,7 +14,7 @@ let File file
&path FILE_READ open_file &file file<

if &file @ -2 = then
"Failed to open file\n" printstr
"Failed to open file\n" print_str
1 exit
end

Expand All @@ -32,4 +32,4 @@ fileSize &fileArray Array.length + !

&file &fileContents fileSize file@

&fileArray printstr new_line
&fileArray print_str new_line
4 changes: 2 additions & 2 deletions examples/comments.cal
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ include "cores/select.cal"
include "std/io.cal"

# This is a single line comment
"hi\n" printstr
"hi\n" print_str

(
This is a multi line comment
)
"hello\n" printstr
"hello\n" print_str
8 changes: 4 additions & 4 deletions examples/compare_strings.cal
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ let Array str2
"Hello" &str1 a<
"Hello" &str2 a<

&str1 &str2 a= printdec new_line
&str1 &str2 a= print_dec new_line

"Hi" &str2 a<
&str1 &str2 a= printdec new_line
&str1 &str2 a= print_dec new_line

"Greetings" &str1 a<
&str1 &str2 a= printdec new_line
&str1 &str2 a= print_dec new_line

&str1 "Greetings" a= printdec new_line
&str1 "Greetings" a= print_dec new_line
2 changes: 1 addition & 1 deletion examples/constants.cal
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ include "std/io.cal"

const myConst 5

myConst printdec new_line
myConst print_dec new_line
2 changes: 1 addition & 1 deletion examples/countTo10.cal
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ include "std/io.cal"
let cell i
0 -> i
while i 10 < do
i 1 + printdec new_line
i 1 + print_dec new_line
i 1 + -> i
end
4 changes: 2 additions & 2 deletions examples/echo.cal
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ let Array arg

while i get_args_length < do
i &arg get_arg
&arg printstr
' ' printch
&arg print_str
' ' print_ch
i 1 + -> i
end

Expand Down
2 changes: 1 addition & 1 deletion examples/error.cal
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ version x86_64
error
end

"Hello, world!" printstr
"Hello, world!" print_str
2 changes: 1 addition & 1 deletion examples/exceptions.cal
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end

try foo
catch
exception_msg printstr new_line
exception_msg print_str new_line
end

foo
2 changes: 1 addition & 1 deletion examples/fib.cal
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ func fib cell n -> cell res begin
end
end

9 fib printdec new_line
9 fib print_dec new_line
2 changes: 1 addition & 1 deletion examples/funcPointers.cal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include "cores/select.cal"
include "std/io.cal"

func sayHello begin
"Hello!\n" printstr
"Hello!\n" print_str
end

&sayHello call
2 changes: 1 addition & 1 deletion examples/funny_hello_world.cal
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ include "std/nullterm.cal"

let cell a
36762444129608 -> a
&a printntstr new_line # Prints "Hello!"
&a print_ntstr new_line # Prints "Hello!"
2 changes: 1 addition & 1 deletion examples/helloWorld.cal
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include "cores/select.cal"
include "std/io.cal"

"Hello, world!\n" printstr
"Hello, world!\n" print_str
10 changes: 5 additions & 5 deletions examples/inheritance.cal
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ struct Building : Thing
cell numWindows
end

"Thing.name = " printstr Thing.name printdec new_line
"Thing.sizeof = " printstr Thing.sizeOf printdec new_line
"Building.name = " printstr Building.name printdec new_line
"Building.numWindows = " printstr Building.numWindows printdec new_line
"Building.sizeof = " printstr Building.sizeOf printdec new_line
"Thing.name = " print_str Thing.name print_dec new_line
"Thing.sizeof = " print_str Thing.sizeOf print_dec new_line
"Building.name = " print_str Building.name print_dec new_line
"Building.numWindows = " print_str Building.numWindows print_dec new_line
"Building.sizeof = " print_str Building.sizeOf print_dec new_line
6 changes: 3 additions & 3 deletions examples/initDeinit.cal
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ struct meow
end

implement meow init
"meow init\n" printstr
"meow init\n" print_str
5 swap !
end

implement meow deinit
"meow end\n" printstr
"meow end\n" print_str
end

let meow myMeow
&myMeow @ printdec new_line
&myMeow @ print_dec new_line
6 changes: 3 additions & 3 deletions examples/literals.cal
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ include "cores/select.cal"
include "std/io.cal"

# Hexadecimal - prints 16
0x10 printdec new_line
0x10 print_dec new_line

# Binary - prints 16
0b00010000 printdec new_line
0b00010000 print_dec new_line

# Octal - prints 16
0o20 printdec new_line
0o20 print_dec new_line
14 changes: 7 additions & 7 deletions examples/memAlloc.cal
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ include "cores/select.cal"
include "std/io.cal"

let addr meow
8 malloc -> meow
8 alloc -> meow

"Address: " printstr
meow printdec new_line
"Address: " print_str
meow print_dec new_line

64 meow !
meow @ printdec new_line
meow @ print_dec new_line

"New address: " printstr
meow 16 realloc printdec new_line
"New address: " print_str
meow 16 realloc print_dec new_line

128 meow 8 + !
meow 8 + @ printdec new_line
meow 8 + @ print_dec new_line
2 changes: 1 addition & 1 deletion examples/random.cal
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ let cell i
0 -> i

while i 10 < do
rand printdec new_line
rand print_dec new_line
i 1 + -> i
end
4 changes: 2 additions & 2 deletions examples/return.cal
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ include "cores/select.cal"
include "std/io.cal"

func returnExample begin
"Hello 1\r\n" printstr
"Hello 1\r\n" print_str
return
"Hello 2\r\n" printstr
"Hello 2\r\n" print_str
end

returnExample
14 changes: 7 additions & 7 deletions examples/sdl.cal
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ end
let addr window
let addr renderer

"Init " printstr
SDL_INIT_VIDEO SDL_Init printdec new_line
"Init " print_str
SDL_INIT_VIDEO SDL_Init print_dec new_line

"Window " printstr
"Window " print_str
"Callisto\0" Array.elements + @ 0 0 320 240 0 SDL_CreateWindow -> window
window printdec new_line
window print_dec new_line

"Renderer " printstr
"Renderer " print_str
window -1 SDL_RENDERER_PRESENTVSYNC SDL_RENDERER_ACCELERATED or SDL_CreateRenderer -> renderer
renderer printdec new_line
renderer print_dec new_line

while true do
let SDL_Event e
while &e SDL_PollEvent do
if &e d@ SDL_QUIT = then
"Bye!\n" printstr
"Bye!\n" print_str
renderer SDL_DestroyRenderer
window SDL_DestroyWindow
SDL_Quit
Expand Down
10 changes: 5 additions & 5 deletions examples/sierpinski.cal
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ func man sierpinski cell n begin
0 -> x

while x pad < do
' ' printch
' ' print_ch
x 1 + -> x
end

0 -> x

while x n 2 / < do
if x n y 1 + - and then
' ' printch
' ' print_ch
else
'*' printch
'*' print_ch
end
' ' printch
' ' print_ch

x 1 + -> x
end

y 1 + -> y
pad 1 - -> pad
13 printch 10 printch
13 print_ch 10 print_ch
end
end

Expand Down
6 changes: 3 additions & 3 deletions examples/stars.cal
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ let cell y
while y 20 < do
while x 40 < do
if x 1 + y 1 + % 0 = then
'*' printch
'*' print_ch
else
' ' printch
' ' print_ch
end

x 1 + -> x
end
13 printch 10 printch
13 print_ch 10 print_ch
y 1 + -> y
0 -> x
end
8 changes: 4 additions & 4 deletions examples/structs.cal
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ struct Animal
end

# Print offsets
"Animal.name = " printstr Animal.name printdec new_line
"Animal.sound = " printstr Animal.sound printdec new_line
"Animal.name = " print_str Animal.name print_dec new_line
"Animal.sound = " print_str Animal.sound print_dec new_line

# Create animal instance
let Animal cat
"cat" &cat Animal.name + a<
"mrrrp" &cat Animal.sound + a<

# Print fields
"Name: " printstr &cat Animal.name + printstr new_line
"Sound: " printstr &cat Animal.sound + printstr new_line
"Name: " print_str &cat Animal.name + print_str new_line
"Sound: " print_str &cat Animal.sound + print_str new_line
6 changes: 3 additions & 3 deletions examples/structs_with_arrays.cal
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ struct MyStruct
cell baz
end

MyStruct.foo printdec new_line
MyStruct.bar printdec new_line
MyStruct.baz printdec new_line
MyStruct.foo print_dec new_line
MyStruct.bar print_dec new_line
MyStruct.baz print_dec new_line
2 changes: 1 addition & 1 deletion examples/tak.cal
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ func tak cell x cell y cell z -> cell res begin
end
end

48 20 12 tak printdec 10 printch
48 20 12 tak print_dec 10 print_ch
2 changes: 1 addition & 1 deletion examples/time.cal
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ include "std/io.cal"

requires Time

get_epoch_time printdec new_line
get_epoch_time print_dec new_line
6 changes: 3 additions & 3 deletions examples/unions.cal
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ union MyUnion
Array
end

"MyUnion.sizeof = " printstr MyUnion.sizeOf printdec new_line
"MyUnion.sizeof = " print_str MyUnion.sizeOf print_dec new_line

let MyUnion foo

65 &foo !
&foo @ printdec new_line
&foo @ print_dec new_line

"Hello, world!\n" &foo a<
&foo printstr
&foo print_str
Loading

0 comments on commit 952a5ee

Please sign in to comment.