ref: b98b1cb5d6f7e068de349cbac3d5418c5c174dbe
parent: ecf60a52205c9d7d8d731a83006e866f34354a66
author: Ori Bernstein <[email protected]>
date: Wed Aug 22 13:09:00 EDT 2012
Kill trailing whitespace.
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -43,7 +43,7 @@
The language is composed of several classes of token. There
are comments, identifiers, keywords, punctuation, and whitespace.
-
+
Comments, begin with "/*" and end with "*/". They may nest.
/* this is a comment /* with another inside */ */
@@ -83,8 +83,8 @@
In the compiler, single semicolons (';') , semicolons and newlines (\x10)
characters are treated identically, and are therefore interchangable.
They will both be referred to "endline"s thoughout this manual.
-
+
3. SYNTAX OVERVIEW:
Myrddin syntax will likely have a familiar-but-strange taste
@@ -105,7 +105,7 @@
modified at run time. Constants must have
initializers defined.
var: Declares a variable value. This value may be
- assigned to, copied from, and
+ assigned to, copied from, and
generic: Declares a specializable value. This value
has the same restricitions as a const, but
taking its address is not defined. The type
@@ -125,8 +125,8 @@
and will be inferred:
const x = 123
-
- Declare a variable with no value and no type defined. The
+
+ Declare a variable with no value and no type defined. The
value can be assigned later (and must be assigned before use),
and the type will be inferred.
@@ -216,7 +216,7 @@
eg: {a : int, b
-> a + b
}
-
+
Sequence literals describe either an array or a structure
literal. They begin with a '[', followed by an initializer
sequence and closing ']'. For array literals, the initializer
@@ -239,10 +239,10 @@
eg: (1,), (1,'b',"three")
3.3. Control Constructs and Blocks:
-
+
if for
while match
- goto
+ goto
The control statements in Myrddin are similar to those in many other
popular languages, and with the exception of 'match', there should
@@ -257,10 +257,10 @@
number of declarations, expressions, control constructs, and empty
lines. Every control statement example below will (and, in fact,
must) have a block attached to the control statement.
-
+
If statements branch one way or the other depending on the truth
value of their argument. The truth statement is separated from the
- block body
+ block body
if true
std.put("The program always get here")
@@ -303,7 +303,7 @@
a value to match against.
- Literal patterns
-
+
Any literal value can be matched against.
- Constant patterns
@@ -384,7 +384,7 @@
Precedence 9:
x + x Add
x - x Subtract
-
+
Precedence 8:
x & y Bitwise and
@@ -425,7 +425,7 @@
x <<= x Fused shl/assign Right assoc
x >>= x Fused shr/assign Right assoc
- Precedence 0:
+ Precedence 14:
-> x Return expression
All expressions on integers act on complement-two values which wrap
@@ -445,7 +445,7 @@
3.5.1. Primitive types:
- void
+ void
bool char
int8 uint8
int16 uint16
@@ -498,7 +498,7 @@
They are reference types that store the length of their
contents. They are declared by appending a '[,]' to the base
type.
-
+
foo* type: pointer to foo
foo[123] type: array of 123 foo
foo[,] type: slice of foo
@@ -528,7 +528,7 @@
struct a struct containing an int named
a : int 'a', and a char named 'b'.
- b : char
+ b : char
;;
union a union containing one of
@@ -567,7 +567,7 @@
named '@foo'.
- 3.6.
+ 3.6.
The myrddin type system is a system similar to the Hindley Milner
system, however, types are not implicitly generalized. Instead, type
@@ -584,15 +584,15 @@
3.6.1 Types for leaf nodes:
- Variable Type
+ Variable Type
----------------------
var foo $t
-
+
A type variable is the most specific type for a declaration
or function without any specified type
var foo : t t
-
+
If a type is specified, that type is taken for the
declaration.
@@ -606,7 +606,7 @@
Char literals are of type 'char'
true bool
- false bool
+ false bool
true/false are boolean literals
@@ -614,7 +614,7 @@
Integer literals get a fresh type variable of type with
the constraints for int-like types.
-
+
123.1 $t::(tcfloat,tcnum,tctest)
Float literals get a fresh type variable of type with
@@ -631,8 +631,8 @@
+ - * / %
+= -= *= /= %
- Number binops require the constraint 'tcnum' for both the
-
+ Number binops require the constraint 'tcnum' for both the
+
num-unary:
- +
Number binops require the constraint 'tcnum'.
@@ -710,7 +710,7 @@
-> 0
}
- TODO: DESCRIBE CONSTRUCTS.
+ TODO: DESCRIBE CONSTRUCTS.
5.2. Conditions
@@ -729,7 +729,7 @@
std.put("The max of %i, %i is %i\n", x, y, max(x, y))
}
- TODO: DESCRIBE CONSTRUCTS.
+ TODO: DESCRIBE CONSTRUCTS.
5.3. Looping
@@ -746,8 +746,8 @@
std.put("The inner product is %i\n", innerprod([1,2,3], [4,5,6]))
}
- TODO: DESCRIBE CONSTRUCTS.
-
+ TODO: DESCRIBE CONSTRUCTS.
+
6. STYLE GUIDE:
6.1. Brevity:
@@ -767,13 +767,13 @@
to what the function does. For functions, a single verb is ideal. For
local variables, a single character might suffice. Compact notation
is simpler to read, typographically.
-
+
Variables names should describe the value contained, and function
names should describe the value returned.
Good: spawn(myfunc)
Bad: create_new_thread_starting_at_function(myfunc)
-
+
The identifiers used for constant values are put in Initialcase.
Functions and types are in singleword style, although underscores are
occasionally necessary to specify additional information within
@@ -801,7 +801,7 @@
6.3. Collections:
-
+
7. STANDARD LIBRARY: