Răsfoiți Sursa

Added monkey2 manual docs.

Mark Sibly 9 ani în urmă
părinte
comite
f8b3c8a849

BIN
modules/monkey/docs/Monkey2-logo-48.png


+ 79 - 0
modules/monkey/docs/language/build-system.md

@@ -0,0 +1,79 @@
+
+### The build system
+
+Monkey2 includes  a simple build system that converts monkey2 files to C++, compiles the C++ code, and links the resultant object files.
+
+The build system also allows you to import several types of non-monkey2 files into a project for compilation and/or linking. This is done using a system import directive:
+
+`#Import` `"<`_system\_file_`>"`
+
+...or or a local import directive:
+
+`#Import `"_local\_file_"`
+
+Import directives can appear any where in a monkey2 source file, but it's generally tidiest if they are placed at the top of the file.
+
+
+#### System Imports
+
+System files are files that are generally provided with the compiler toolset, and that the compiler and/or linker are configured to find automatically. Monkey2 recognizes the following system file types:
+
+| System file type suffix	| System file type
+|:--------------------------|:----------------
+| .o, .obj, .a, .lib		| Static library.
+| .so, .dll, .dylib			| Dynamic library.
+| .framework				| MacOS framework.
+| .h, .hh, .hpp				| C/C++/Objective C header.
+| .monkey2					| Monkey2 module.
+
+Note that system file names are enclosed by `<` and `>` characters, while local file names are not.
+
+An example of importing a system library:
+
+`#Import "<wsock32.a>"`
+
+If no extension is provided for a system import, Monkey2 will assume you are importing a monkey2 module, eg:
+
+`#Import "<std>"`
+
+This will import the monkey2 'std' module. This is effectively the same as:
+
+`#Import "<std.monkey2>"`
+
+
+#### Local Imports
+
+Local files are files that are located relative to the monkey2 file that imports them.
+
+Monkey2 recognizes the following local file types:
+
+| Local file type suffix		| Local file type
+|:------------------------------|:---------------
+| .o, .obj						| Object file.
+| .a, .lib						| Static library.
+| .so, .dll, .dylib				| Dynamic library.
+| .framework					| MacOS framework.
+| .exe							| Windows executable.
+| .c, .cc, .cxx, .cpp, .m, .mm	| C/C++/Objective C source code.
+| .h, .hh, .hpp					| C/C++/Objective C header.
+| .monkey2						| Monkey2 source code.
+
+It is also possible to add local 'include directories', 'library directories' and 'framework directories' with import. This is done using syntax similar to a local import, but replacing the filename with a wildcard.
+
+For example, to add an include directory:
+
+`#Import "`_include\_directory_`/*.h"`
+
+This will allow you to import any header file inside 'include\_directory' using...
+
+`#Import "<`_include\_file_`>"`
+
+...without having to specify the full path of the file.
+
+To add a library directory:
+
+`#Import "`_staticlib\_directory_`/*.a"`
+
+To add a MacOS framework directory:
+
+`#Import "`_framework\_directory_`"/*.framework"`

+ 182 - 0
modules/monkey/docs/language/expressions.md

@@ -0,0 +1,182 @@
+
+### Expressions
+
+#### Operators
+
+| Operator			| Description				| Precedence
+|:------------------|:--------------------------|:---------:
+| `New`				| New object or array		| 1
+| `Null`			| Null value				|
+| `Self`			| Self instance				|
+| `Super`			| Super instance			|
+| `True`			| Boolean true				|
+| `False`			| Boolean false				|
+| `Cast`			| Cast operator				|
+| `Lambda`			| Lambda function			|
+| _identifier_		| Identifier				|
+| _literal_			| Literal value				|
+| | |
+| `.`				| Postfix member acccess	| 2
+| `( )`				| Postfix Invoke			|
+| `[ ]`				| Postfix Index				|
+| `< >`				| Postfix Generic instance	|
+| | |
+| `Varptr`			| Unary variable address	| 3
+| `-`				| Unary numeric negate		| 
+| `~`				| Unary integer complement 	|
+| `Not`				| Unary boolean invert		|
+| | |
+| `*`				| Numeric multiplication	| 4
+| `/`				| Numeric division			|
+| `Mod`				| Numeric modulo			|
+| | |
+| `+`				| Numeric addition			| 5
+| `-`				| Numeric subtraction		|
+| | |
+| `Shl`				| Integer shift left		| 6
+| `Shr`				| Integer shift right		|
+| | |
+| `&`				| Integer and				| 7
+| `~`				| Integer xor				|
+| | |
+| `\|`				| Integer or				| 8
+| | |
+| `<=>`				| Compare					| 9
+| | |
+| `<`				| Less than					| 10
+| `>`				| Greater than				|
+| `<=`				| Less than or equal		|
+| `>=`				| Greater than or equal		|
+| | |
+| `=`				| Equal						| 11
+| `<>`				| Not equal					|
+| | |
+| `And`				| Boolean and				| 12
+| | |
+| `Or`				| Boolean or				| 13
+| | |
+| `?` `Else`		| If-then-else				| 14
+
+#### Type balancing
+
+When evaluating an operator's operands, it is sometimes necessary to adjust the type of one or both operands.
+
+When evaluating the operands of arithemetic or comparison operators, the following rules are used:
+
+* If either operator String, the other is converted to String.
+* Else If either operand is Double, the other is converted to Double.
+* Else if either operand is Float, the other is converted to Float.
+* Else if either operand is ULong, the other is converted to ULong.
+* Else if either operand is Long, the other is converted to Long.
+* Else if either operand is UInt, the other is converted to UInt.
+* Else if either operand is unsigned, both are converted to UInt.
+* Else both operands are converted to Int.
+
+When evaluating the operands of the `&`, `|` and `^` integer operators, both operands must be integral types and are converted as follows:
+
+* If either operand is ULong, the other is converted to ULong.
+* Else if either operand is Long, the other is converted to Long.
+* Else if either operand is UInt, the other is converted to UInt.
+* Else if either operand is unsigned, both are converted to UInt.
+* Else both operands are converted to Int.
+
+When evaluating the operand of the `Shl` and `Shr` integer operators, the left-hand-side must be an integral type, while the right-hand-side 'shift amount' operand is converted to Int.
+
+#### Operator overloading
+
+Operator overloading allows you to customize the behavior of the built-in monkey2 operators for classes and structs.
+
+You overload an operator by writing an 'operator method', which is effectively just a special kind of method. Operators must appear inside classes/structs - they cannot currently be 'global'.
+
+Here is a simple example:
+<pre>
+ Struct Vec2
+
+   Field x:Float
+   Field y:Float
+
+   Method New( x:Float,y:Float )
+      Self.x=x
+      Self.y=y
+   End
+
+   Method ToString:String()
+      Return "Vec2("+x+","+y+")"
+   End
+
+   'Overload the addition operator.
+   Operator+:Vec2( rhs:Vec2 )
+      Return New Vec2( x+rhs.x,y+rhs.y )
+   End
+
+End
+</pre>
+
+The 'Operator+' declaration here defines an addition operator for Vec2. This is then used whenever a Vec2 appears as the 'left hand side' of an addition. For example:
+<pre>
+Function Main()
+   Local v1:=New Vec2( 10.0,20.0 )
+   Local v2:=New Vec2( 30.0,40.0 )
+   Local v3:=v1+v2    'note: calls Operator+ in Vec2.
+   Print v3.ToString()
+End
+</pre>
+
+The following unary operators can be overloaded: `+` `-` `~`
+
+The following binary operators can be overloaded: `*` `/` `Mod` `+` `-` `Shl` `Shr` `&` `|` `~` `=` `<>` `<` `>` `<=` `>=` `<=>`
+
+The following assignment operators can be overloaded: `*=` `/=` `Mod=` `+=` `-=` `Shl=` `Shr=` `&=` `|=` `~=`
+
+Indexing behaviour can also be overloaded using `[]` and `[]=`
+
+Note that you cannot overload `Not`, `And`, `Or` or plain assignment `=`
+
+Operators can return any type of value, and can take any type of value for their 'right hand side' argument(s). However, the precedence of operators cannot be changed.
+
+The `[]` and `[]=` operators allow you to define 'indexing' like behaviour. The `[]` operator is used when an object is indexed, and `[]=` is used when an object is indexed and assigned. Both of these operators can accept any number of parameters of any type. The `[]=` operator requires an additional parameter that is the value to be assigned. This must appear at the end of the parameter list.
+
+Here is an example of some indexing operators for the Vec2 class above:
+
+<pre>
+Struct Vec2
+
+   ...as above...
+
+   Operator[]:Float( index:Int )
+      Assert( index=0 Or index=1 )
+      If index=0 Return x Else Return y
+   End
+
+   Operator[]=( index:Int,value:Float )
+      Assert( index=0 Or index=1 )
+      If index=0 Then x=value Else y=value
+   End
+End
+</pre>
+
+With these additions, you can access Vec2 coordinates 'by index', eg:
+<pre>
+Function Main()
+	Local v:=New Vec2
+	v[0]=10.0
+	v[1]=20.0
+	Print v[0]
+	Print v[1]
+End
+</pre>
+
+You can also overload assignment operators, for example:
+<pre>
+Struct Vec2
+
+	...as above...
+	
+	Operator+=( v:Vec2 )
+		x+=v.x
+		y+=v.y
+	End
+End
+</pre>
+
+If you have already written an Operator+ (as is the case here) this is not strictly necessary, as monkey2 will generate the code for Operator+= for you. However, you may still want to provide a custom version for Operator+= if your code can do so in a more efficient way.

+ 57 - 0
modules/monkey/docs/language/functions.md

@@ -0,0 +1,57 @@
+
+### Functions
+
+#### Global functions
+
+To declare a global function:
+
+`Function` _Identifier_ [ `:` _ReturnType_ ] `(` _Arguments_ `)`
+```
+	...Statements...
+```
+`End`
+
+_ReturnType_ defaults to `Void` if omitted.
+
+_Arguments_ is a comma separated list of parameter declarations.
+
+
+#### Lambda functions
+
+To declare a lambda function:
+
+...`Lambda` [ `:` _ReturnType_ `]` `(` _Parameters_ `)`
+```
+	...Statements...
+```
+`End`...
+
+Lambda declarations must appear within an expression, and therefore should not start on a new line.
+
+For example:
+
+```
+Local myLambda:=Lambda()
+   Print "My Lambda!"
+End
+
+myLambda()
+```
+
+To pass a lambda to a function:
+
+```
+SomeFunc( Lambda()
+   Print "MyLambda"
+End )
+```
+
+Note the closing `)` after the `End` to match the opening `(` after `SomeFunc`.
+
+
+
+#### Function values
+
+Monkey2 supports 'first class' functions.
+
+This means function 'values' can be stored in variables and arrays, passed to other functions and returned from functions.

+ 18 - 0
modules/monkey/docs/language/language.md

@@ -0,0 +1,18 @@
+
+@manpage Language reference
+
+# Monkey2 Language reference
+
+The section of the monkey2 manual describes the monkey2 language in detail.
+
+Note: This documentation is currently WIP.
+
+@import modules.md
+@import namespaces.md
+@import types.md
+@import variables.md
+@import functions.md
+@import expressions.md
+@import user-types.md
+@import native-code.md
+@import build-system.md

+ 78 - 0
modules/monkey/docs/language/modules.md

@@ -0,0 +1,78 @@
+
+### Modules and Applications
+
+#### Creating modules
+
+A module consists of a sub-directory inside the top level '/modules/' directory, that contains a 'root' monkey2 file with the same name as the sub-directory and a 'module.json' file , eg:
+
+```
+/modules/my-module/
+/modules/my-module/my-module.monkey2
+/modules/my-module/module.json
+```
+
+Module names can contain any valid identifier or the `-` character. However, the `-` character cannot be used twice or more in succession, eg:
+
+```
+legal-module-name
+illegal--module--name
+```
+
+Module names live in a 'flat' namespace so should be as unique as possible.
+
+The 'module.json' file must contain a json object with the following fields:
+
+* `"module"` : string - the name of the module. Must be the same as the directory name.
+* `"author"` : string - the author of the module.
+* `"version"` : string - the version of the module. This should be in number 'dot' number 'dot' number format, eg: `"1.0.0"`.
+* `"depends"` : string array - All modules this module depends on. This will generally include all other modukes #imported by the module, eg: `["libc","std"]`.
+
+A simple module.json file might look like this:
+
+```
+{
+	"module" : "my-module",
+	"version" : "1.0.0",
+	"depends" : ["libc","std"]
+}
+```
+
+To rebuild a module, use the mx2cc 'makemods' option, eg:
+
+```
+mx2cc makemods my-module
+```
+
+This will cause the root 'modules/my-module/my-module.monkey2' file to be built, along with any local files it imports.
+
+You can also rebuild all modules with:
+
+```
+mx2cc makemods
+```
+
+This will use the "depends" information in the module.json files to determine the correct order to build the modules in.
+
+Modules must not have cyclic dependancies.
+
+Each module may also declare a single Main:Void() function that can be used to initialize the module.
+
+This function is called *after* global variables (including global Consts) have been initialized but *before* the application's Main is called.
+
+Since modules can't have cyclic dependencies, Mains will always execute in the correct order, eg: if module X imports module Y, then module Y's Main is guaranteed to be called before module X's.
+
+
+#### Importing modules
+
+Once built, a module can be imported into other modules using 'import', eg:
+
+```
+#Import "<my-module>"
+```
+ 
+
+#### Applications
+
+An application is really just a special type of module. It doesn't have to reside in the '/modules/' directory, can't be imported by other modules and produces executable files instead of archives, but is otherwise dealt with just like a module.
+
+An application must declare a Main:Void() function. Actually, there's no difference between the Main declared in the app, and Mains declared in modules. Since the app depends on ALL modules, and NO modules depend on the app, the app's Main just happens to be the last one called.

+ 81 - 0
modules/monkey/docs/language/namespaces.md

@@ -0,0 +1,81 @@
+
+### Namespaces and Using
+
+All identifiers declared in a monkey2 program file end up inside a 'namespace'. Namespaces are hierarchical, so in addition to identifiers declared by monkey2 code, namespaces can also contain other namespaces.
+
+#### Declaring namespaces
+
+You control which namespace the identifiers declared in a monkey2 file go with the namespace directive:
+
+`Namespace` _namespace-path_
+
+This directive must appear at the top of the program file, before any actual declarations are made.
+
+A namespace path is a 'dot' separated sequence of identifiers, eg:
+
+`monkey.types`
+`std.collections`
+
+The 'dot' separator indicates the namespace hierarchy, eg: `monkey.types` is a 'child' or 'inner' namespace of `monkey`.
+
+If no namespace is specified in a program file, the identifiers go into a default namespace. This is not recommended though, as the default namespace has no name - so anything inside the default namespace cannot be 'seen' by anything outside.
+
+#### Accessing namespaces
+
+Code can access an identifier in a namespace by prefixing the identifier with the namespace path, eg:
+
+`Local list:=New std.collections.List<Int>`
+
+Here, `std.collections` refers to a namespace, while `List` is an identifier inside  the `std.collections` namespace.
+
+Code inside a particular namespace does not have to use a namespace prefix to find identifiers in the same namespace or in any parent namespace, although it can still do so, eg:
+
+```
+Namespace testing
+
+Function Test()
+End
+
+Function Main()
+	Test()				'works fine...
+	testing.Test()    'also works...
+End
+```
+
+#### The Using directive
+
+To make it easier to deal with long or complex namespace paths, the using directive provides a way to add namespace 'search paths' for locating identifiers. The using directive looks like this:
+
+`Using` _namespace-path_
+
+A program can have multiple using directives. Using directives must appear at the top of the program file before any program declarations.
+
+Each using directive adds a namespace to a set of 'search paths' that is used to resolve any unknown identifiers in the program code, eg:
+
+```
+#Import "<std>"
+
+Using std.collections
+ 
+Function Main()
+	Local list:=New List<Int>
+End
+```
+
+Without the using directive, this program would fail to compile because the `List` identifier cannot be found.
+
+However, the using direct tells the compiler look for `List` in the `std.collections` namespace, where it is successfully located.
+
+If you have multiple using directives and an identifier is found in more than one namespace, you will still get a compile error. In this case, you will need to 'fully qualify' the identifier by prefixing it with the correct namespace path.
+
+Some modules declare many namespaces, and it can often be difficult to remember where everything is. To deal with this, Monkey2 provides a convenient 'double dot' form of Using that will use both a namespace AND all namespaces contained in that namespace. For example:
+
+```
+Using std..
+```
+
+The double dots must appear at the end of the using.
+
+This will use the std namespace, and the std.collections, std.filesystem etc namespaces too. This works recursively, so any namespaces inside std.collections and std.filesystem are also used.
+
+This can of course lead to more 'duplicate identifier' clashes but is none-the-less very convenient.

+ 85 - 0
modules/monkey/docs/language/native-code.md

@@ -0,0 +1,85 @@
+
+### Integration with native code
+
+In order to allow monkey2 code access to native code, monkey2 provides the 'extern' directive.
+
+Extern begins an 'extern block' and must appear at file scope. Extern cannot be used inside a class or function. An extern block is ended by a plain 'public' or 'private' directive.
+
+Declarations that appear inside an extern block describe the monkey2 interface to native code. Therefore, functions and methods that appear inside an extern block cannot have any implementation code, as they are already implemented natively.
+
+Otherwise, declarations inside an extern block are very similar to normal monkey2 declarations, eg:
+
+```
+Extern
+
+Struct S
+   Field x:Int
+   Field y:Int
+   
+   Method Update()   'note: no code here - it's already written.
+   Method Render()   'ditto...
+End
+
+Global Counter:Int
+
+Function DoSomething( x:int,y:Int )
+```
+
+
+#### Extern symbols
+
+By default, monkey2 will use the name of an extern declaration as its 'symbol'. That is, when monkey2 code that refers to an extern declaration is compiled, it will use the name of the declaration directly in the generated output code.
+
+You can modify this behaviour by providing an 'extern symbol' immediately after the declarations type, eg:
+
+```
+Extern
+
+Global Player:Actor="mylib::Player"
+
+Class Actor="mylib::Actor"
+	Method Update()
+	Method Render()
+	Function Clear()="mylib::Actor::Clear"
+End
+```
+
+
+#### Extern classes
+
+Extern classes are assumed by default to be *real* monkey2 classes - that is, they must extend the native bbObject class. 
+
+However, you can override this by declaring an extern class that extends `Void`. Objects of such a class are said to be native objects and differ from normal monkey object in several ways:
+
+* A native object is not memory managed in any way. It is up to you to 'delete' or otherwise destroy it.
+
+* A native object has no runtime type information, so it cannot be downcast using the `Cast<>` operator.
+ 
+ ---
+
+### The mx2cc tool
+
+mx2cc is the command line compiler for monkey2. The actual executable is named differently depending on the OS:
+
+/bin/mx2cc_windows.exe
+/bin/mx2cc_macos
+/bin/mx2cc_linux
+
+The command line options for mx2cc are:
+
+`mx2cc` _command_ _options_ _input_
+
+Valid commands are:
+
+* `makeapp` - make an app. _input_ should be a monkey2 file path.
+* `makemods` - make a set of modules. _input_ should be a space separated list of module names in dependency order.
+* `makedocs` - make the documentation for a set of modules. _input_ should be a space separated list of module names in dependency order.
+
+Valid options are:
+
+* `clean` - rebuilds everything from scratch.
+* `verbose` - provides more information while building.
+* `target=`_target_ - set target to `desktop` (the default) or `emscripten`.
+*  `config=`_config_ - set config to `debug` (the default) or `release`.
+* `apptype`=_apptype_ set apptype to `gui` (the default) or `console`.
+

+ 73 - 0
modules/monkey/docs/language/types.md

@@ -0,0 +1,73 @@
+
+### Monkey2 types
+
+#### Primitive types
+
+The following primtive types are supported by monkey2:
+
+| Type		| Description
+|:----------|:-----------
+| `Void`	| No type.
+| `Bool`	| Boolean type.
+| `Byte`	| 8 bit signed integer.
+| `UByte`	| 8 bit unsigned integer.
+| `Short`	| 16 bit signed integer.
+| `UShort`	| 16 bit unsigned integer.
+| `Int`		| 32 bit signed integer.
+| `UInt`	| 32 bit unsigned integer.
+| `Long`	| 64 bit signed integer.
+| `ULong`	| 64 bit signed integer.
+| `Float`	| 32 bit floating point.
+| `Double`	| 64 bit floating point.
+| `String`	| String of 16 bit characters.
+
+
+#### Compound types
+
+The following compound types are supported by monkey2:
+
+| Type						| Description
+|:--------------------------|:-----------
+| _Type_ `[]`				| Array type
+| _Type_ `Ptr`				| Pointer type
+| _Type_ `(` _Types_ `)`		| Function type
+
+
+#### Implicit type conversions
+
+These type conversions are performed automatically:
+
+| Source type					| Destination type
+|:------------------------------|:-----------------
+| Any numeric type	 			| `Bool`
+| String or array type 			| `Bool`
+| Class or interface type	 	| `Bool`
+| Any numeric type				| Any numeric type
+| Any numeric type				| `String`
+| Any pointer type				| `Void Ptr`
+| Any enum type					| Any integral type
+| Class or interface type		| Base class type or implemented interface type
+
+When numeric values are converted to bool, the result will be true if the value is not equal to 0.
+
+When strings and arrays are converted to bool, the result will be true if the length of the string or array is not 0.
+
+When class or interface instances are converted to bool, the result will be true if the instance is not equal to null.
+
+When floating point values are converted to integral values, the fractional part of the floating point value is simply chopped off - no rounding is performed.
+
+
+#### Explicit type conversions
+
+The `Cast` `<` _dest-type_ `>` `:` _dest-type_ `(` _expression_ `)` operator must be used for these type conversions:
+
+| Source type			| Destination type
+|:----------------------|:-----------------
+| `Bool`				| Any numeric type
+| `String`				| Any numeric type
+| Any pointer type		| Any pointer type, any integral type
+| Any integral type		| Any pointer type, any enum type
+| Class type			| Derived class type, any interface type
+| Interface type		| Any class type, any interface type
+
+When casting bool values to a numeric type, the result will be 1 for true, 0 for false.

+ 120 - 0
modules/monkey/docs/language/user-types.md

@@ -0,0 +1,120 @@
+
+### User defined types
+
+#### Classes
+
+To declare a class:
+
+`Class` _Identifier_ [ `Extends` _SuperClass_ ] [ `Implements` _Interfaces_ ] [ _Modifiers_ ]
+```
+	...Class members...
+```
+`End`
+
+_SuperClass_ defaults to `Object` if omitted.
+ 
+_Interfaces_ is a comma separated list of interface types.
+ 
+_Modifiers_ can be one of:
+
+* `Abstract` - class cannot be instantiated with 'New', it must be extended.
+* `Final` - class cannot be extended.
+
+Classes can contain consts, globals, fields, methods, functions and other user defined types.
+
+#### Structs
+
+To declare a struct:
+
+`Struct` _Identifier_ 
+```
+	...Struct members...
+```	
+`End`
+
+A struct can contain consts, globals, fields, methods, functions and other user defined types.
+
+Structs are similar to classes, but differ in several important ways:
+
+* A struct is a 'value type', whereas a class is a 'reference type'. This means that when you assign a struct to a variable, pass a struct to a function or return a struct from a function, the entire struct is copied in the process.
+
+* Stucts are statically typed, whereas classes are dynamically typed.
+
+* Struct methods cannot be virtual.
+
+* A struct cannot extend anything.
+
+#### Interfaces
+
+To declare an interface:
+
+`Interface` _Identifier_ [ `Extends` _Interfaces_ ]
+```
+	...Interface members...
+```
+`End`
+
+_Interfaces_ is a comma separated list of interface types. 
+
+An interface can contain consts, globals, fields, methods, functions and other user defined types.
+
+Interface methods are always 'abstract' and cannot declared any code.
+
+
+#### Fields
+
+Fields are variables that live inside the memory allocated for an instance of a class or struct. To declare a field variable:
+
+`Field` _identifier_ `:` _Type_ [ `=` _Expression_ ]
+...or...
+`Field` _identifier_ `:=` _Expression_
+
+For struct fields, _Expression_ must not contain any code that has side effects.
+
+
+#### Methods
+
+To declare a method:
+
+`Method` _Identifier_ [ `:` _ReturnType_ ] `(` _Arguments_ `)` [ _Modifiers_ ]
+```
+	...Statements...
+```
+`End`
+
+_ReturnType_ defaults to `Void` if omitted.
+
+_Arguments_ is a comma separated list of parameter declarations.
+
+_Modifiers_ can only be used with class methods, and can be one of:
+
+* `Abstract` - method is abstract and has no statements block or `End` terminator. Any class with an abstract method is implicitly abstract.
+* `Virtual` - method is virtual and can be dynamically overridden by a subclass method.
+* `Override` - method is virtual and overrides a super class or interface method.
+* `Override Final` - method is virtual, overrides a super class or interace method and cannot be overridden by subclasses.
+* `Final` - method is non-virtual and cannot be overridden by a subclass method.  
+
+Methods are 'Final' by default.
+
+
+#### Properties
+
+To declare a read/write property:
+
+`Property` _Identifier_ `:` _Type_ `()`
+...getter code...
+`Setter` `(` _Identifier `:` _Type_ `)`
+...setter code...
+`End`
+
+To declare a read only property:
+
+`Property` _Identifier_ `:` _Type_ `()`
+...getter code...
+`End`
+
+To declare a write only property:
+
+`property` `(` _Identifier `:` _Type_ `)`
+...setter code...
+`End`

+ 28 - 0
modules/monkey/docs/language/variables.md

@@ -0,0 +1,28 @@
+
+### Variables and Consts
+
+#### Local variables
+
+Local variables live on the stack. To declare a local variable:
+
+`Local` _identifier_ `:` _Type_ [ `=` _Expression_ ]
+...or...
+`Local` _identifier_ `:=` _Expression_
+
+
+#### Global variables
+
+Global variables live in global memory and exist for the lifetime of the application. To declare a global variable:
+
+`Global` _identifier_ `:` _Type_ [ `=` _Expression_ ]
+...or...
+`Global` _identifier_ `:=` _Expression_
+
+
+#### Consts
+
+Consts are stored in the same way as globals, but cannot be modified after they are initialized. To declare a const:
+
+`Const` _identifier_ `:` _Type_ `=` _Expression_
+...or...
+`Const` _identifier_ `:=` _Expression_

+ 17 - 0
modules/monkey/docs/manual.md

@@ -0,0 +1,17 @@
+
+@manpage Monkey2
+
+# Welcome to Monkey2!
+
+Monkey2 is an open-source, user-friendly, cross-platform programming language designed primarily for game programming.
+
+The monkey2 release includes a simple IDE coded in pure monkey2 called 'Ted2'. Ted2 is not a fully fledged IDE (yet) but is intended to provide a 'works anywhere' IDE solution for using monkey2 on any platform you can get it building on.
+
+Monkey2 is a crowd funded project. If you like what you see, please consider contributing to development either via paypal donation or by becoming a Patreon supporter.
+
+Have fun!
+
+@import language/language.md
+
+@import mx2cc.md
+

+ 26 - 0
modules/monkey/docs/mx2cc.md

@@ -0,0 +1,26 @@
+
+@manpage The mx2cc compiler
+
+Mx2cc is the command line compiler for monkey2. The actual executable is named differently depending on the OS:
+
+/bin/mx2cc_windows.exe  
+/bin/mx2cc_macos  
+/bin/mx2cc_linux  
+
+The command line options for mx2cc are:
+
+`mx2cc` _command_ _options_ _input_
+
+Valid commands are:
+
+* `makeapp` - make an app. _input_ should be a monkey2 file path.
+* `makemods` - make a set of modules. _input_ should be a space separated list of module names, or nothing to make all modules.
+* `makedocs` - make the documentation for a set of modules. _input_ should be a space separated list of module names, or nothing to make all modules.
+
+Valid options are:
+
+* `clean` - rebuilds everything from scratch.
+* `verbose` - provides more information while building.
+* `target=`_target_ - set target to `desktop` (the default) or `emscripten`.
+* `config=`_config_ - set config to `debug` (the default) or `release`.
+* `apptype=`_apptype_ set apptype to `gui` (the default) or `console`.