aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/alias.prose9
-rw-r--r--examples/argcv.prose8
-rw-r--r--examples/c.prose27
-rw-r--r--examples/call.prose18
-rw-r--r--examples/from.prose19
-rw-r--r--examples/hello.prose7
6 files changed, 88 insertions, 0 deletions
diff --git a/examples/alias.prose b/examples/alias.prose
new file mode 100644
index 0000000..0fae9a6
--- /dev/null
+++ b/examples/alias.prose
@@ -0,0 +1,9 @@
+public function main
+ types
+ mytype alias pointer to array of 8 word
+ linkage
+ status word
+ storage
+ myvar mytype
+ procedure returning status
+ set status to 0
diff --git a/examples/argcv.prose b/examples/argcv.prose
new file mode 100644
index 0000000..da50b59
--- /dev/null
+++ b/examples/argcv.prose
@@ -0,0 +1,8 @@
+public function main
+ linkage
+ argc word
+ argv pointer to array of etc byte
+ status word
+ procedure using argc argv returning status
+ display "argc is " argc ", argv is " argv
+ set status to 0
diff --git a/examples/c.prose b/examples/c.prose
new file mode 100644
index 0000000..8224fb5
--- /dev/null
+++ b/examples/c.prose
@@ -0,0 +1,27 @@
+* C interoperatibility example (without imports)
+public function main
+ types
+ socket prototype
+ linkage
+ domain word
+ type word
+ protocol word
+ fd word
+ procedure using domain type protocol returning fd
+
+ close prototype
+ linkage
+ fd word
+ status word
+ procedure using fd returning status
+
+ AF_INET constant to 2
+ SOCK_STREAM constant to 2
+ linkage
+ status word
+ storage
+ fd word
+ procedure returning status
+ call socket using AF_INET SOCK_STREAM 0 returning fd
+ display "fd is " fd
+ call close using fd returning status
diff --git a/examples/call.prose b/examples/call.prose
new file mode 100644
index 0000000..d90ccff
--- /dev/null
+++ b/examples/call.prose
@@ -0,0 +1,18 @@
+* function calls
+function foo
+ linkage
+ myparam word
+ ret word
+ procedure using myparam returning ret
+ display "myparam is " myparam
+ set ret to 0
+
+public function main
+ linkage
+ status word
+ storage
+ myvar word
+ procedure returning status
+ set myvar to 123
+ call foo using myvar returning status
+ display "status is " status
diff --git a/examples/from.prose b/examples/from.prose
new file mode 100644
index 0000000..746371d
--- /dev/null
+++ b/examples/from.prose
@@ -0,0 +1,19 @@
+* 'from' loop example
+function foo
+ procedure
+ from 0 to 3
+ display "\tfoo"
+ end
+
+public function main
+ linkage
+ status word
+ storage
+ iterator ulong
+ procedure returning status
+ from 0 to 8
+ display "hello"
+ call foo
+ end
+
+ set status to 0
diff --git a/examples/hello.prose b/examples/hello.prose
new file mode 100644
index 0000000..00c0fe1
--- /dev/null
+++ b/examples/hello.prose
@@ -0,0 +1,7 @@
+* hello world example
+public function main
+ linkage
+ status word
+ procedure returning status
+ display "hello world"
+ set status to 0