summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2012-08-11 00:05:41 -0400
committerOri Bernstein <ori@eigenstate.org>2012-08-11 00:05:41 -0400
commite6707e0fbad837ce2dc82f810b2cd64b33d76aff (patch)
tree75366481dd6d0083379c07144c41ee8f3ef1b1b2 /doc
parentf26cc32b00f294de441e7144b22214b720825817 (diff)
downloadmc-e6707e0fbad837ce2dc82f810b2cd64b33d76aff.tar.gz
Rearrange sections.
Diffstat (limited to 'doc')
-rw-r--r--doc/lang.txt272
1 files changed, 137 insertions, 135 deletions
diff --git a/doc/lang.txt b/doc/lang.txt
index f62971d..8f6520a 100644
--- a/doc/lang.txt
+++ b/doc/lang.txt
@@ -10,14 +10,13 @@ TABLE OF CONTENTS:
3.1. Declarations
3.2. Literal Values
3.3. Control Constructs and Blocks
- 3.4. Data Types
- 3.5. Packages and Uses
- 3.6. Expressions
- 4. TYPE SYSTEM
- 5. TOOLCHAIN
- 6. EXAMPLES
- 7. STYLE GUIDE
- 8. FUTURE DIRECTIONS
+ 3.4. Expressions
+ 3.5. Data Types
+ 3.6. Packages and Uses
+ 4. TOOLCHAIN
+ 5. EXAMPLES
+ 6. STYLE GUIDE
+ 7. FUTURE DIRECTIONS
1. OVERVIEW:
@@ -275,8 +274,105 @@ TABLE OF CONTENTS:
and increments. They run the test on every iteration of the loop,
and
+ 3.4. Expressions:
- 3.4. Data Types:
+ Myrddin expressions are relatively similar to expressions in C. The
+ operators are listed below in order of precedence, and a short
+ summary of what they do is listed given. For the sake of clarity,
+ 'x' will stand in for any expression composed entirely of
+ subexpressions with higher precedence than the current current
+ operator. 'e' will stand in for any expression. Unless marked
+ otherwise, expressions are left associative.
+
+ BUG: There are too many precedence levels.
+
+
+ Precedence 0: (*ok, not really operators)
+ (,,,) Tuple Construction
+ (e) Grouping
+ name Bare names
+ literal Values
+
+ Precedence 1:
+ x.name Member lookup
+ x++ Postincrement
+ x-- Postdecrement
+ x[e] Index
+ x[from,to] Slice
+
+ Precedence 2:
+ ++x Preincrement
+ --x Predecrement
+ *x Dereference
+ &x Address
+ !x Logical negation
+ ~x Bitwise negation
+ +x Positive (no operation)
+ -x Negate x
+
+ Precedence 3:
+ x << x Shift left
+ x >> x Shift right
+
+ Precedence 4:
+ x * x Multiply
+ x / x Divide
+ x % x Modulo
+
+ Precedence 5:
+ x + x Add
+ x - x Subtract
+
+ Precedence 6:
+ x & y Bitwise and
+
+ Precedence 7:
+ x | y Bitwise or
+ x ^ y Bitwise or
+
+ Precedence 8:
+ `Name x Union construction
+
+ Precedence 9:
+ x casttto(type) Cast expression
+
+ Precedence 10:
+ x == x Equality
+ x != x Inequality
+ x > x Greater than
+ x >= x Greater than or equal to
+ x < x Less than
+ x <= x Less than or equal to
+
+ Precedence 11:
+ x && x Logical and
+
+ Precedence 12:
+ x || x Logical or
+
+ Precedence 13:
+ x = x Assign Right assoc
+ x += x Fused add/assign Right assoc
+ x -= x Fused sub/assign Right assoc
+ x *= x Fused mul/assign Right assoc
+ x /= x Fused div/assign Right assoc
+ x %= x Fused mod/assign Right assoc
+ x |= x Fused or/assign Right assoc
+ x ^= x Fused xor/assign Right assoc
+ x &= x Fused and/assign Right assoc
+ x <<= x Fused shl/assign Right assoc
+ x >>= x Fused shr/assign Right assoc
+
+ Precedence 14:
+ -> x Return expression
+
+ All expressions on integers act on complement-two values which wrap
+ on overflow. Right shift expressions fill with the sign bit on
+ signed types, and fill with zeros on unsigned types.
+
+
+
+ 3.5. Data Types:
The language defines a number of built in primitive types. These
are not keywords, and in fact live in a separate namespace from
@@ -287,7 +383,7 @@ TABLE OF CONTENTS:
must be explicitly cast if you want to convert, and the casts must
be of compatible types, as will be described later.
- 3.4.1. Primitive types:
+ 3.5.1. Primitive types:
void
bool char
@@ -322,7 +418,7 @@ TABLE OF CONTENTS:
var y : float32 declare y as a 32 bit float
- 3.4.2. Composite types:
+ 3.5.2. Composite types:
pointer
slice array
@@ -346,7 +442,7 @@ TABLE OF CONTENTS:
foo[123] type: array of 123 foo
foo[,] type: slice of foo
- 3.4.3. Aggregate types:
+ 3.5.3. Aggregate types:
tuple struct
union
@@ -380,7 +476,7 @@ TABLE OF CONTENTS:
;;
- 3.4.4. Magic types:
+ 3.5.4. Magic types:
tyvar typaram
tyname
@@ -409,9 +505,35 @@ TABLE OF CONTENTS:
@foo creates a type parameter
named '@foo'.
- 3.4.5. :
- 3.6. Packages and Uses:
+ 3.6.
+
+ The myrddin type system is a system similar to the Hindley Milner
+ system, however, types are not implicitly generalized. Instead, type
+ 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. and define
+ the constraints that they require.
+
+ num-binop:
+ + - * / %
+ += -= *= /= %
+ num-unary:
+ - +
+
+ int-binop:
+ | & ^ << >>
+ |= &= ^= <<= >>
+ int-unary:
+ ~ ++ --
+
+ bool-binop:
+ || && == !=
+ < <= > >=
+
+
+ 3.7. Packages and Uses:
pkg use
@@ -453,128 +575,8 @@ TABLE OF CONTENTS:
them in the body of the code for readability. Scanning the export
list is desirable from a readability perspective.
- 3.7. Expressions:
-
- Myrddin expressions are relatively similar to expressions in C. The
- operators are listed below in order of precedence, and a short
- summary of what they do is listed given. For the sake of clarity,
- 'x' will stand in for any expression composed entirely of
- subexpressions with higher precedence than the current current
- operator. 'e' will stand in for any expression. Unless marked
- otherwise, expressions are left associative.
-
- BUG: There are too many precedence levels.
-
-
- Precedence 0: (*ok, not really operators)
- (,,,) Tuple Construction
- (e) Grouping
- name Bare names
- literal Values
-
- Precedence 1:
- x.name Member lookup
- x++ Postincrement
- x-- Postdecrement
- x[e] Index
- x[from,to] Slice
-
- Precedence 2:
- ++x Preincrement
- --x Predecrement
- *x Dereference
- &x Address
- !x Logical negation
- ~x Bitwise negation
- +x Positive (no operation)
- -x Negate x
-
- Precedence 3:
- x << x Shift left
- x >> x Shift right
-
- Precedence 4:
- x * x Multiply
- x / x Divide
- x % x Modulo
-
- Precedence 5:
- x + x Add
- x - x Subtract
-
- Precedence 6:
- x & y Bitwise and
-
- Precedence 7:
- x | y Bitwise or
- x ^ y Bitwise or
-
- Precedence 8:
- `Name x Union construction
-
- Precedence 9:
- x casttto(type) Cast expression
-
- Precedence 10:
- x == x Equality
- x != x Inequality
- x > x Greater than
- x >= x Greater than or equal to
- x < x Less than
- x <= x Less than or equal to
-
- Precedence 11:
- x && x Logical and
-
- Precedence 12:
- x || x Logical or
-
- Precedence 13:
- x = x Assign Right assoc
- x += x Fused add/assign Right assoc
- x -= x Fused sub/assign Right assoc
- x *= x Fused mul/assign Right assoc
- x /= x Fused div/assign Right assoc
- x %= x Fused mod/assign Right assoc
- x |= x Fused or/assign Right assoc
- x ^= x Fused xor/assign Right assoc
- x &= x Fused and/assign Right assoc
- x <<= x Fused shl/assign Right assoc
- x >>= x Fused shr/assign Right assoc
-
- Precedence 14:
- -> x Return expression
-
- All expressions on integers act on complement-two values which wrap
- on overflow. Right shift expressions fill with the sign bit on
- signed types, and fill with zeros on unsigned types.
-
4. TYPE SYSTEM:
- The myrddin type system is a system similar to the Hindley Milner
- system, however, types are not implicitly generalized. Instead, type
- 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. and define
- the constraints that they require.
-
- num-binop:
- + - * / %
- += -= *= /= %
- num-unary:
- - +
-
- int-binop:
- | & ^ << >>
- |= &= ^= <<= >>
- int-unary:
- ~ ++ --
-
- bool-binop:
- || && == !=
- < <= > >=
-
5. TOOLCHAIN: