diff options
author | Ori Bernstein <ori@eigenstate.org> | 2012-08-09 18:34:23 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2012-08-09 18:34:23 -0400 |
commit | 27ca8d448e65696f0194fe9f7f367ddc6ba3a00b (patch) | |
tree | 652b18cb401814900e506fb329cac459a6b38886 /doc | |
parent | d15b6a7213e876047859dc6add85255829a4f6c4 (diff) | |
download | mc-27ca8d448e65696f0194fe9f7f367ddc6ba3a00b.tar.gz |
Add more docs.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/lang.txt | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/doc/lang.txt b/doc/lang.txt index 10be239..f62971d 100644 --- a/doc/lang.txt +++ b/doc/lang.txt @@ -556,10 +556,25 @@ TABLE OF CONTENTS: schemes (type parameters, in Myrddin lingo) must be explicitly provided in the declarations. For purposes of brevity, instead of specifying type rules for every operator, we group operators which behave identically - from the type system perspective into a small set of classes + from the type system perspective into a small set of classes. and define + the constraints that they require. + + num-binop: + + - * / % + += -= *= /= % + num-unary: + - + + + int-binop: + | & ^ << >> + |= &= ^= <<= >> + int-unary: + ~ ++ -- + + bool-binop: + || && == != + < <= > >= - Binop: - + - 5. TOOLCHAIN: @@ -570,9 +585,46 @@ TABLE OF CONTENTS: 6m [-h] [-o outfile] [-d[dbgopts]] inputs -I path Add 'path' to use search path -o Output to outfile - 5. EXAMPLES: + + 5.1. Hello World: + + use std + const main = { + std.put("Hello World!\n") + -> 0 + } + + 5.2. Conditions + + const intmax = {a, b + if a > b + -> a + else + -> b + ;; + } + + const main = { + var x = 123 + var y = 456 + std.put("The max of %i, %i is %i\n", x, y, max(x, y)) + } + + 5.3. Looping + + const innerprod = {a, b + var i + var sum + for i = 0; i < a.len; i++ + sum += a[i]*b[i] + ;; + } + + const main = { + std.put("The inner product is %i\n", innerprod([1,2,3], [4,5,6])) + } 6. STYLE GUIDE: |