This commit is contained in:
2022-04-10 15:55:56 +02:00
parent 2a9aa13058
commit c9eacbfdfc
35 changed files with 2118 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
func add(a, b) begin
print "adding", a, "and", b
return a + b
end
func main()
begin
print 2 + add(40, 2) + 2
end

View File

@@ -0,0 +1,3 @@
func main() begin
print "Hello, World!"
end

View File

@@ -0,0 +1,30 @@
// This program tests activation records, function call and return
func funcall ()
begin
var x,y,z
x := 5
y := 10
print "Calling my_function with parameters", x, y
z := my_function ( x, y )
print "The returned result is", z
z := my_other_function ()
print "The other returned result is", z
return 0
end
func my_function ( s, t )
begin
var u
u := s*s + t*t
print "Parameter s is", s
print "Parameter t is", t
print "The sum of their squares is", u
return u
end
func my_other_function ()
begin
var x
x := 42
return x
end

View File

@@ -0,0 +1,24 @@
func main() begin
var a, b
a := 1
begin
var a
a := 2
b := 40
begin
var a
a := b + 2
print a, b
end
print a
begin
var b
b := 38
a := b + 3
print a, b
end
print a
end
print b
end