]> Nishi Git Mirror - gwion.git/commitdiff
:book: Doc clean
authorfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 5 Jul 2019 01:16:57 +0000 (03:16 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Fri, 5 Jul 2019 01:16:57 +0000 (03:16 +0200)
21 files changed:
docs/01_Overview/00_First_Steps/01_InstallingGwion.md [new file with mode: 0644]
docs/01_Overview/00_First_Steps/Configure.md [new file with mode: 0644]
docs/01_Overview/BUILDING.md [new file with mode: 0644]
docs/01_Overview/Keywords.md [new file with mode: 0644]
docs/01_Overview/Make.md [moved from docs/Make.mdr with 100% similarity]
docs/01_Overview/SpecialWords.md [new file with mode: 0644]
docs/01_Overview/Testing.md [new file with mode: 0644]
docs/01_Overview/declaration.md [new file with mode: 0644]
docs/01_Overview/globalvalues.md [new file with mode: 0644]
docs/02_Reference/01_Functions/Lambdas.md [new file with mode: 0644]
docs/02_Reference/01_Functions/Variadic.md [new file with mode: 0644]
docs/02_Reference/01_Functions/function.md [new file with mode: 0644]
docs/02_Reference/ControlFlow/ControlFlow.md [new file with mode: 0644]
docs/02_Reference/ControlFlow/Loops.md [new file with mode: 0644]
docs/02_Reference/ControlFlow/forloop.md [new file with mode: 0644]
docs/02_Reference/Extending/WIP_Driver.md [new file with mode: 0644]
docs/02_Reference/Extending/WIP_Plugins.md [new file with mode: 0644]
docs/08_Contributing/03_ContributingTranslation.mdr
docs/Extending/WIP_Driver.md [new file with mode: 0644]
docs/Extending/WIP_Plugins.md [new file with mode: 0644]
docs/index.md [new file with mode: 0644]

diff --git a/docs/01_Overview/00_First_Steps/01_InstallingGwion.md b/docs/01_Overview/00_First_Steps/01_InstallingGwion.md
new file mode 100644 (file)
index 0000000..1e7717b
--- /dev/null
@@ -0,0 +1,39 @@
+# Installing gwion
+
+## Get the sources
+
+The source is accessible on [github](https://github.com).
+
+Provided you have git installed, you can get it with:
+
+``` sh
+git clone https://github.com/fennecdjay/gwion
+```
+
+then change to the source directory
+``` sh
+cd gwion
+```
+
+### Don't forget submodules
+
+You'll need the sources for all base module
+``` sh
+git submodule update --init util ast
+```
+
+> At this point, you might want to configure the build.
+  In this case, have a look at the [configuration page](Configure.md)
+
+
+## Build the libraries and program
+``` sh
+make
+```
+
+## Install the package
+
+``` sh
+make install
+```
+> You may need root privilege to do this.
diff --git a/docs/01_Overview/00_First_Steps/Configure.md b/docs/01_Overview/00_First_Steps/Configure.md
new file mode 100644 (file)
index 0000000..b05d398
--- /dev/null
@@ -0,0 +1,18 @@
+# Configuring Gwion
+
+## util/config.mk
+
+double
+
+gettext
+
+memcheck
+
+lto
+
+coverage
+
+## ast/config.mk
+
+## config.mk
+Here are a few choices left
diff --git a/docs/01_Overview/BUILDING.md b/docs/01_Overview/BUILDING.md
new file mode 100644 (file)
index 0000000..1babfe5
--- /dev/null
@@ -0,0 +1,38 @@
+# Build / Configure Gwion
+
+## Configure
+### gwion-util
+
+  * `USE_MEMCHECK`: compile with debug flags (`-g`) and enable asserts
+  * `USE_COVERAGE`: add coverage instrumentation
+
+
+## Make 
+Basically, all that is left to do is
+```sh
+make
+```
+The only environment variable affecting the operation is `PREFIX`
+
+Except `--(no-)double`, everything can be set when running make,
+using environment variables.  
+
+Drivers can be set on using, e.g. for *alsa* : `ALSA_D=1` or `ALSA_D=on`.  
+In the same way, then can be disabled with     `ALSA_D=0` or `ALSA_D=off`
+
+### Running tests
+```bash
+make tests
+```
+to run all tests, or 
+```bash
+bash util/test.sh my_file_or_directory (.. other files/dirs ...)
+```
+to run specific ones.
+look [here](#testing.md) for more.
+## Install
+*maybe as root*
+```sh
+make install
+```
+The only environment variable affecting the operation is `PREFIX`
diff --git a/docs/01_Overview/Keywords.md b/docs/01_Overview/Keywords.md
new file mode 100644 (file)
index 0000000..0f8af7c
--- /dev/null
@@ -0,0 +1,31 @@
+# Keywords
+
+ * fun/function
+ * operator
+ * return
+ * goto
+ * switch/case/default
+ * if/else
+ * break/continue
+ * until/do/while/for/repeat
+
+
+
+
+ * global/static
+ * private/protect
+ * const
+
+ * new
+ * spork
+ * fork
+ * typeof
+
+ * typedef
+ * class
+   * dtor
+   * extends
+ * enum
+ * union
+
+ * auto
similarity index 100%
rename from docs/Make.mdr
rename to docs/01_Overview/Make.md
diff --git a/docs/01_Overview/SpecialWords.md b/docs/01_Overview/SpecialWords.md
new file mode 100644 (file)
index 0000000..3b4286a
--- /dev/null
@@ -0,0 +1,6 @@
+# Special Values
+
+  * me
+  * this
+  * vararg
+  * maybe
diff --git a/docs/01_Overview/Testing.md b/docs/01_Overview/Testing.md
new file mode 100644 (file)
index 0000000..3c3a79d
--- /dev/null
@@ -0,0 +1,28 @@
+# Tests
+[test.sh](https://github.com/fennecdjay/Gwion/blob/dev/util/test.sh)
+requires [valgrind](http://valgrind.org/) 
+there are two kinds of tests:
+  * [gwion](#gwion-tests)
+  * [bash](#bash-tests)
+  
+## Gwion tests
+those tests are just gwion (.gw) files, handling special comments:
+  * `// [skip]`     (*optionally* followed by reason to skip)
+  * `// [todo]`     (*optionally* followed by reason to delay testing)
+  * `// [contains]` followed by string to match
+  * `// [excludes]` followed by string not to match
+
+## Shell test
+those tests are just bash (.sh) files.  
+they should start with this snippet
+```bash
+#!/bin/bash
+# [test] #5
+n=0
+[ "$1" ] && n="$1"
+[ "$n" -eq 0 ] && n=1
+source tests/sh/common.sh
+```
+
+## TODO
+  [ ] `bailout` system for early exit on failure
diff --git a/docs/01_Overview/declaration.md b/docs/01_Overview/declaration.md
new file mode 100644 (file)
index 0000000..fcf0671
--- /dev/null
@@ -0,0 +1,50 @@
+# Declarations
+
+## Basics
+
+Declaring a primitive or an object is quite straight forward:
+``` gw
+int i;
+Object o;
+<<<i, " ", o>>>;
+```
+0 0x56418af88660
+
+## Declaring a reference
+However ...
+``` gw
+Object @ref;
+<<<"Reference points to no object yet: ", ref>>>;
+//Object o @=> ref;
+new Object @=> ref;
+<<<"But now it does: ", ref>>>;
+```
+make[1] : on entre dans le répertoire « /home/djay/src/git/gwion/gwion-github »
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+(int[]) (nil)<br/>
+(int[]) 0x4dedc10<br/>
+t: (nil)<br/>
+But now it does: 0x4dedc30<br/>
+&#10004;
+</p>
+make[1] : on quitte le répertoire « /home/djay/src/git/gwion/gwion-github »
+
+## Arrays
+
+### array as refs
+
+``` gw
+int ref[];
+<<<ref>>>;
+new int[2] @=> ref;
+<<<ref>>>;
+```
+make[1] : on entre dans le répertoire « /home/djay/src/git/gwion/gwion-github »
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+(int[]) (nil)<br/>
+(int[]) 0x4dedc10<br/>
+t: (nil)<br/>
+But now it does: 0x4dedc30<br/>
+&#10004;
+</p>
+make[1] : on quitte le répertoire « /home/djay/src/git/gwion/gwion-github »
diff --git a/docs/01_Overview/globalvalues.md b/docs/01_Overview/globalvalues.md
new file mode 100644 (file)
index 0000000..8156695
--- /dev/null
@@ -0,0 +1,16 @@
+# Global Values
+
+  * adc
+  * blackhole
+  * dac
+  * pi
+  * null
+  * samp
+  * ms
+  * second
+  * hour
+  * me
+  * this
+  * \__func__
+  * \__file__
+  * \__line__
diff --git a/docs/02_Reference/01_Functions/Lambdas.md b/docs/02_Reference/01_Functions/Lambdas.md
new file mode 100644 (file)
index 0000000..bf261a8
--- /dev/null
@@ -0,0 +1,46 @@
+# Lambda
+
+## Overview
+
+Simply put, *lambda*s are anonymous functions.  
+
+The syntax to create them is simple:
+```
+\ variable0 variable1 ... {  your code here }
+```
+You can even use it to
+### Call a function just once
+``` gw
+\ i { <<<"passed '", i, "'">>>; }(3);
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+passed '3'<br/>
+&#10004;
+</p>
+
+
+## Use case
+
+### Passing to a function pointer
+``` gw
+typedef void fptr_t(int);
+\ i { <<<"passed '", i, "'">>>; } @=> fptr_t fptr;
+fptr(4);
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+passed '4'<br/>
+&#10004;
+</p>
+
+### As Argument to Functions
+``` gw
+typedef void fptr_t(int);
+fun void test(fptr_t fptr) {
+   fptr(5);
+}
+test(\ i { <<<"passed '", i, "'">>>; });
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+passed '5'<br/>
+&#10004;
+</p>
diff --git a/docs/02_Reference/01_Functions/Variadic.md b/docs/02_Reference/01_Functions/Variadic.md
new file mode 100644 (file)
index 0000000..092b3dd
--- /dev/null
@@ -0,0 +1,18 @@
+# Variadic functions
+
+> A function whoses arity is not fixed.
+
+Well, a function that takes a fixed number of arguments, and additionnal ones.
+
+## a simple example
+``` gw
+fun void variadic_test(int i, ...) {
+  <<< "first argument is ", i >>>;
+  vararg.start;
+  <<< "\tadditionnal argument", vararg.i >>>;
+  vararg.end;
+}
+variadic_test(1);
+variadic_test(1, 2);
+variadic_test(1, 2, 3);
+```
diff --git a/docs/02_Reference/01_Functions/function.md b/docs/02_Reference/01_Functions/function.md
new file mode 100644 (file)
index 0000000..d5034ef
--- /dev/null
@@ -0,0 +1,23 @@
+# Functions
+
+## a simple (commented example)
+
+``` gw
+// declare function 'test_function'
+// with return type int
+// taking an int as argument
+fun int test_function(int arg) {
+  // return the argument + 2
+  return arg + 2;
+}
+
+// now call the function (and debug print the result)
+<<<test_function(0)>>>;
+// or use alternate syntax
+<<<1 => test_function>>>;
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+(int) 2<br/>
+(int) 3<br/>
+&#10004;
+</p>
diff --git a/docs/02_Reference/ControlFlow/ControlFlow.md b/docs/02_Reference/ControlFlow/ControlFlow.md
new file mode 100644 (file)
index 0000000..2e9c185
--- /dev/null
@@ -0,0 +1,4 @@
+# Control Flow
+
+## Repeats
+let start simple ;-)  
diff --git a/docs/02_Reference/ControlFlow/Loops.md b/docs/02_Reference/ControlFlow/Loops.md
new file mode 100644 (file)
index 0000000..4b787b4
--- /dev/null
@@ -0,0 +1 @@
+# Loops
diff --git a/docs/02_Reference/ControlFlow/forloop.md b/docs/02_Reference/ControlFlow/forloop.md
new file mode 100644 (file)
index 0000000..8510a1e
--- /dev/null
@@ -0,0 +1,111 @@
+# For Loops
+**For** loops in Gwion is pretty similar to classic **C** syntax
+
+## basic loops
+``` gw
+for(int i; i < 3; ++i)
+   <<<i>>>;
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+(int) 0<br/>
+(int) 1<br/>
+(int) 2<br/>
+&#10004;
+</p>
+
+Of course, it also works with a block of code.
+
+``` gw
+for(int i; i < 3; ++i) {
+   i/2 => float f1;
+   i/2. => float f2;
+   <<<i, " " , f1, " ", f2>>>;
+}
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+0 0.0000 0.0000<br/>
+1 0.0000 0.5000<br/>
+2 1.0000 1.0000<br/>
+&#10004;
+</p>
+
+## Nested Loops
+``` gw
+int array[3][4];
+
+for(int i; i < 3; ++i) {
+  for(int j; j < 4; ++j) {
+    <<<array[i][j]>>>;
+  }
+}
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+&#10004;
+</p>
+
+### Auto Loops
+
+#### Simple auto loop
+``` gw
+int array[2][3];
+for(auto a: array) {
+  <<<a>>>;
+  for(auto b: a)
+    <<<b>>>;
+}
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+(int[]) 0x4e0ff00<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int[]) 0x4e0ff20<br/>
+(int) 0<br/>
+(int) 0<br/>
+(int) 0<br/>
+&#10004;
+</p>
+
+### Auto Pointer loop
+With the simple auto loop, you only get the value in the array.  
+If you want to change it, you need a pointer 
+
+``` gw
+int array[2][3];
+int i;
+for(auto a: array) {
+  for(auto @b: a)
+    <<<++i => *b>>>;
+}
+for(auto a: array) {
+  for(auto @b: a)
+    <<<*b>>>;
+}
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+(int) 1<br/>
+(int) 2<br/>
+(int) 3<br/>
+(int) 4<br/>
+(int) 5<br/>
+(int) 6<br/>
+(int) 1<br/>
+(int) 2<br/>
+(int) 3<br/>
+(int) 4<br/>
+(int) 5<br/>
+(int) 6<br/>
+&#10004;
+</p>
diff --git a/docs/02_Reference/Extending/WIP_Driver.md b/docs/02_Reference/Extending/WIP_Driver.md
new file mode 100644 (file)
index 0000000..2047863
--- /dev/null
@@ -0,0 +1,9 @@
+# Giving gwion a new driver
+
+## basics
+
+> in order to use GWION_CTL ...
+
+# concept
+
+# upd driver
diff --git a/docs/02_Reference/Extending/WIP_Plugins.md b/docs/02_Reference/Extending/WIP_Plugins.md
new file mode 100644 (file)
index 0000000..cd1822f
--- /dev/null
@@ -0,0 +1,68 @@
+# Writing a Gwion plugin
+
+> THIS IS OUTDATED. please look at the source code in src/lib/ instead
+
+  * [getting started]
+
+## Getting started
+use the script
+
+### headers
+```
+#include "vm.h"
+#include "instr.h"
+#include "import.h
+```
+<!-- TODO: verify this -->
+
+### Class
+Define the type:
+```
+struct Type_ t_mytype = { "MyType", SZ_INT, &t_object};
+```
+> every type extending t_object should have SZ_INT
+
+### Handling Constructors and Destructors
+#### CTOR
+```
+CTOR(mytype_ctor) {
+  /* constructor code here */
+}
+```
+#### DTOR
+```
+DTOR(mytype_dtor) {
+  /* destructor code here */
+}
+```
+
+those macros provide two variables:
+  * `o`:     the *M_Object* for the (con/des)tructor
+  * `shred`: the *VM_Shred* for the (con/des)tructor
+
+```
+CHECK_BB(import_class_begin(env, &t_mytpe, env->global_nspc, mytype_ctor, mytype_dtor))
+```
+#### variable
+declare a `m_int`. coding convention require
+  * a leading *_o*
+  * a following *_type_*
+```c
+m_int o_mytype_myvaroffset;
+```
+#### function
+```c
+/* declare a member function */
+MFUN(mytype_memberfunction) {
+  /* code here */
+}
+
+SFUN(mtype_staticfunction) {
+  /* code here */
+}
+```
+
+#### operator
+
+### Import function
+
index fbafbfbd30056e254f2c183f5a9024efceb1de10..7a9c35b88c297c78ef79d6f348b49d3f34aef3e2 100644 (file)
@@ -41,7 +41,7 @@ You can now get back to [step 2](#2-Edit).
 
 ## Add to VCS
 
-It's now time to add your changes to the package :smile:
+It's now time to add your changes to the package
 
 ``` sh
 make translation-commit TRANSLATION_TARGET=<xxx>
diff --git a/docs/Extending/WIP_Driver.md b/docs/Extending/WIP_Driver.md
new file mode 100644 (file)
index 0000000..2047863
--- /dev/null
@@ -0,0 +1,9 @@
+# Giving gwion a new driver
+
+## basics
+
+> in order to use GWION_CTL ...
+
+# concept
+
+# upd driver
diff --git a/docs/Extending/WIP_Plugins.md b/docs/Extending/WIP_Plugins.md
new file mode 100644 (file)
index 0000000..cd1822f
--- /dev/null
@@ -0,0 +1,68 @@
+# Writing a Gwion plugin
+
+> THIS IS OUTDATED. please look at the source code in src/lib/ instead
+
+  * [getting started]
+
+## Getting started
+use the script
+
+### headers
+```
+#include "vm.h"
+#include "instr.h"
+#include "import.h
+```
+<!-- TODO: verify this -->
+
+### Class
+Define the type:
+```
+struct Type_ t_mytype = { "MyType", SZ_INT, &t_object};
+```
+> every type extending t_object should have SZ_INT
+
+### Handling Constructors and Destructors
+#### CTOR
+```
+CTOR(mytype_ctor) {
+  /* constructor code here */
+}
+```
+#### DTOR
+```
+DTOR(mytype_dtor) {
+  /* destructor code here */
+}
+```
+
+those macros provide two variables:
+  * `o`:     the *M_Object* for the (con/des)tructor
+  * `shred`: the *VM_Shred* for the (con/des)tructor
+
+```
+CHECK_BB(import_class_begin(env, &t_mytpe, env->global_nspc, mytype_ctor, mytype_dtor))
+```
+#### variable
+declare a `m_int`. coding convention require
+  * a leading *_o*
+  * a following *_type_*
+```c
+m_int o_mytype_myvaroffset;
+```
+#### function
+```c
+/* declare a member function */
+MFUN(mytype_memberfunction) {
+  /* code here */
+}
+
+SFUN(mtype_staticfunction) {
+  /* code here */
+}
+```
+
+#### operator
+
+### Import function
+
diff --git a/docs/index.md b/docs/index.md
new file mode 100644 (file)
index 0000000..dcc9457
--- /dev/null
@@ -0,0 +1,26 @@
+# Welcome to Gwion
+
+gwion is a easy yet powerful, strongly-timed programming language, 
+
+## And now for the hello world
+
+So, as it is mandatory, here is the piece of code you're waiting 
+for:
+
+``` gw
+<<<"Hello, World!", "">>>;
+```
+<p style="background-color:#e3e3e3; border: 5px solid #343131; padding: 10px; margin-right: 20%; margin-left: 20%; -moz-border-radius: 15px; -webkit-border-radius: 15px;">
+Hello, World!<br/>
+&#10004;
+</p>
+
+## (Bag of) Features
+  * horizontal inheritance
+  * typedef (function pointers and type aliases)
+  * enums and unions
+  * templates (both class and functions)
+  * easy concurrency/async
+  * [lambdas](Functions/Lambdas)
+  * memoization
+  * [variadic](Functions/Variadic) functions