Commits

Pierre Surply committed 11c044c

website : redac ref

Comments (2)

Files changed (22)

         for i <- 0 to self.length - 1 do
                 self.set(i, x)
         done
-end
+end

website/cgi-bin/url.ml

         begin
           match Env.get_url_arg 1 with
           | "setup"     -> "setup.html"
+          | "loop"	-> "loop.html"
+          | "vardecl"   -> "vardecl.html"
+          | "assign"    -> "assign.html"
+          | "compound"  -> "compound.html"
+          | "alt"  	-> "alt.html"
+          | "while"  	-> "while.html"
+          | "waitfor"  	-> "waitfor.html"
+          | "for"  	-> "for.html"
           | "arith"     -> "arith.html"
           | "comp"      -> "comp.html"
           | "boolop"    -> "boolop.html"
           | "asm"       -> "asm.html"
           | "tern"      -> "tern.html"
           | "mcall"     -> "mcall.html"
+	  | "type"	->
+	    begin
+	      match Env.get_url_arg 2 with
+		| "integer"	-> "types/integer.html"
+		| "cstring"	-> "types/cstring.html"
+		| _     	-> "summary.html"
+	    end
+	  | "std"	->
+	    begin
+	      match Env.get_url_arg 2 with
+		| "vect"	-> "std/vect.html"
+		| "string"	-> "std/string.html"
+		| "list"	-> "std/list.html"
+		| _     	-> "summary.html"
+	    end
+	  | "oop"	->
+	    begin
+	      match Env.get_url_arg 2 with
+		| "attr"	-> "oop/attr.html"
+		| "methods"	-> "oop/methods.html"
+		| "init"	-> "oop/init.html"
+		| "static"	-> "oop/static.html"
+		| _     	-> "summary.html"
+	    end
           | _           -> "summary.html"
         end
     | "faq"             -> "faq.html"

website/templates/base.html

           </ul>
           <div class='fl'>Documentation</div>
           <ul>
-            <li><a href="?gettingstarted/">Getting started</a></li>
+            <!-- <li><a href="?gettingstarted/">Getting started</a></li> -->
             <li><a href="?ref/">Reference</a></li>
           </ul>
           <div class='fl'>Download</div>

website/templates/ref/alt.html

+{@ ref/ref.html @}
+
+[begin tref]Alternative[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+if <em>condition</em> then
+   <em>instructions</em>
+endif
+</code>
+</pre>
+<pre>
+<code>
+if <em>condition</em> then
+   <em>instructions_1</em>
+else
+   <em>instructions_2</em>
+endif
+</code>
+</pre>
+<pre>
+<code>
+if <em>condition_1</em> then
+   <em>instructions_1</em>
+elif <em>condition_2</em>
+   <em>instructions_2</em>
+elif <em>condition_3</em>
+   <em>instructions_3</em>
+<em>...</em>
+else
+   <em>instructions_n</em>
+endif
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a <- 42
+        var b <- 0
+
+        if a = 1 then
+          b <- 21
+        elif a <> 2 then
+          b <- 1337
+        else
+          b <- 0
+        endif
+
+        # Here, b = 1337
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/arith.html

     <tr><th><code>%</code></th><th>modulo</th></tr>
   </tbody>
 </table>
-<h3>Example</h3>b
+<h3>Example</h3>
 <pre>
 <code>
   begin setup

website/templates/ref/assign.html

+{@ ref/ref.html @}
+
+[begin tref]Assignment[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+<em>var_name</em> <- <em>expression</em>
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a <- 0
+
+        a <- 6
+        a <- a * 7 # a = 42
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/compound.html

+{@ ref/ref.html @}
+
+[begin tref]Compound operator[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<table>
+  <thead>
+    <tr>
+      <th>Syntax</th>
+      <th>Operation</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr><th><code><em>var_name</em>++</code></th><th>Increment <em>var_name</em></th></tr>
+    <tr><th><code><em>var_name</em>--</code></th><th>Decrement <em>var_name</em></th></tr>
+  </tbody>
+</table>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a <- 0
+
+        a++ 	# a = 1
+        a-- 	# a = 0
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/for.html

+{@ ref/ref.html @}
+
+[begin tref]<em>For</em> loop[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+for <em>var_name</em> <- <expression1> to <expression2> do
+  <em>instructions</em>
+done
+</code>
+</pre>
+<h4>Syntactic sugar</h4>
+<pre>
+<code>
+<em>expression</em>::   <em>instruction</em>
+</code>
+</pre>
+<p>is equivalent to</p>
+<pre>
+<code>
+for <em>var_name</em> <- 0 to <em>expression</em> do
+  <em>instruction</em>
+done
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a <- 0
+
+        for i <- 0 to 42 do
+          a++
+        done
+
+        # Here, a = 42
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/loop.html

+{@ ref/ref.html @}
+
+[begin tref]Main loop[end]
+
+[begin ref]
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+    PORTB.set_pin_in(0)
+    PORTD.set_mode(0xFF)
+    var a <- 0
+  end
+
+  begin loop
+    waitfor not PORTB.read_pin(0)
+    a++
+    PORTD.write(a)
+    waitfor PORTB.read_pin(0)
+  end
+</code>
+</pre>
+<h3>Assembler equivalent</h3>
+<pre>
+  <code>
+    loop: /* ...
+             ...
+             ... */
+	  rjmp loop
+  </code>
+</pre>
+[end]

website/templates/ref/oop/attr.html

+{@ ref/ref.html @}
+
+[begin tref]Classe attributes[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+<em>type</em> <em>attribut_name</em>
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+#point.mr
+
+integer	x
+integer y
+
+# ...
+</code>
+</pre>
+[end]

website/templates/ref/oop/init.html

+{@ ref/ref.html @}
+
+[begin tref]Methods declaration[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+func init(<em>arguments</em>)
+  <em>instructions</em>
+  return self
+end
+</code>
+</pre>
+<pre>
+<code>
+func destr()
+  <em>instructions</em>
+  return self
+end
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+# character.mr
+
+string first_name
+string last_name
+
+func init(fname, lname)
+	self.first_name <- new string(32)
+	self.last_name <- new string(32)
+
+      	self.first_name.write(fname)
+      	self.last_name.write(lname)
+
+	return self
+end
+
+func destr()
+	del self.first_name
+	del self.last_name
+
+	return self
+end
+</code>
+</pre>
+[end]

website/templates/ref/oop/methods.html

+{@ ref/ref.html @}
+
+[begin tref]Methods declaration[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+func <em>func_name</em>(<em>arguments</em>)
+  <em>instructions</em>
+end
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+func fact(n)
+       return n = 0 ? 1 :          \
+              (n * fact(n - 1))
+end
+</code>
+</pre>
+[end]

website/templates/ref/oop/static.html

+{@ ref/ref.html @}
+
+[begin tref]Static class[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+static
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+# acker.mr
+
+static
+
+func acker(m, n)
+        return m ?                              \
+                (n ?                            \
+                  acker(m - 1,                  \
+                        acker(m, n - 1)) :      \
+                  acker(m - 1, 1)) :            \
+                (n + 1)
+end
+
+# main.mr
+
+using acker
+
+begin setup
+	var a <- acker(2, 3)	# a = 9
+end
+
+begin loop
+end
+</code>
+</pre>
+[end]

website/templates/ref/std/list.html

+{@ ref/ref.html @}
+
+[begin tref]List[end]
+
+[begin ref]
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var l <- &#91;21; 1337&#93;
+	var a <- 0
+	var b <- 0
+
+	l.push(0)
+	l.push(12)
+	l.set(1, l&#91;2&#93; << 1)
+
+        a <- l.pop()	# a = 12
+	b <- l&#91;1&#93;	# b = 42
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/std/string.html

+{@ ref/ref.html @}
+
+[begin tref]String[end]
+
+[begin ref]
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var s <- new string(32)
+	var a <- 0
+
+	s.write("Hello World !")
+	a <- s&#91;4&#93;			# a = 'o'
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/std/vect.html

+{@ ref/ref.html @}
+
+[begin tref]Vect[end]
+
+[begin ref]
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var v <- new vect(32)
+	var a <- 0
+
+	v.fill(0)
+	v.set(4, 42)
+
+	a <- v&#91;4&#93;	# a = 42
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/summary.html

       <li>
         <h3>Instructions</h3>
         <ul>
-          <li>Variable declaration</li>
-          <li>Assignment</li>
-          <li>Compound operator</li>
+          <li><a href="?ref/vardecl/">Variable declaration</a></li>
+          <li><a href="?ref/assign/">Assignement</a></li>
+          <li><a href="?ref/compound/">Compound operator</a></li>
         </ul>
       </li>
       <li>
         <h3>Control structure</h3>
         <ul>
-          <li>Alternative</li>
-          <li><em>While</em> loop</li>
-          <li><em>Waitfor</em> loop</li>
-          <li><em>For</em> loop</li>
+          <li><a href="?ref/alt/">Alternative</a></li>
+          <li><a href="?ref/while/"><em>While</em> loop</a></li>
+          <li><a href="?ref/waitfor/"><em>Waitfor</em> loop</a></li>
+          <li><a href="?ref/for/"><em>For</em> loop</a></li>
         </ul>
       </li>
     </ul>
       <li>
         <h3>Native types</h3>
         <ul>
-          <li>integer</li>
-          <li>cstring</li>
-          <li>object</li>
+          <li><a href="?ref/type/integer/">integer</a></li>
+          <li><a href="?ref/type/cstring/">cstring</a></li>
         </ul>
       </li>
       <li>
         <h3>Standard classes</h3>
         <ul>
-          <li>vect</li>
-          <li>string</li>
-          <li>list</li>
+          <li><a href="?ref/std/vect/">vect</a></li>
+          <li><a href="?ref/std/string/">string</a></li>
+          <li><a href="?ref/std/list/">list</a></li>
         </ul>
       </li>
       <li>
         <h3>Class definition</h3>
         <ul>
-          <li>Attributes</li>
-          <li>Methods</li>
-          <li>Initializer/destructor</li>
-          <li>Static class</li>
+          <li><a href="?ref/oop/attr/">Attributes</a></li>
+          <li><a href="?ref/oop/methods/">Methods</a></li>
+          <li><a href="?ref/oop/init/">Initializer/destructor</a></li>
+          <li><a href="?ref/oop/static/">Static class</a></li>
         </ul>
       </li>
     </ul>

website/templates/ref/types/cstring.html

+{@ ref/ref.html @}
+
+[begin tref]CString type[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+"<em>string_content</em>"
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var s <- "foo"
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/types/integer.html

+{@ ref/ref.html @}
+
+[begin tref]Integer[end]
+
+[begin ref]
+<table>
+  <thead>
+    <tr>
+      <th>Size</th>
+      <th>Sign</th>
+      <th>Range</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr><th>16 bits</th>
+	<th>Signed</th>
+	<th>-(2<sup>15</sup>) to 2<sup>15</sup>-1</th></tr>
+  </tbody>
+</table>
+<h3>Syntax</h3>
+<table>
+  <thead>
+    <tr>
+      <th>Regular expression</th>
+      <th>Base</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr><th><code>&#91;0-9&#93;+</code></th><th>Decimal</th></tr>
+    <tr><th><code>0x&#91;0-9A-Fa-F&#93;+</code></th><th>Hexadecimal</th></tr>
+    <tr><th><code>0b&#91;01&#93;+</code></th><th>Binary</th></tr>
+  </tbody>
+</table>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a <- 42
+	var b <- 0b101010
+	var c <- 0x2A
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/vardecl.html

+{@ ref/ref.html @}
+
+[begin tref]Variable declaration[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+var <em>var_name</em> <- <em>expression</em>
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a <- 42
+        var b <- "Hello World !"
+        var c <- &#91;a; b&#93;
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/waitfor.html

+{@ ref/ref.html @}
+
+[begin tref]<em>Waitfor</em> loop[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+waitfor <em>condition</em>
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        PORTB.set_pin_in(0)
+        PORTD.set_mode(0xFF)
+
+        waitfor PORTB.read(0)
+        PORTD.write(42)
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

website/templates/ref/while.html

+{@ ref/ref.html @}
+
+[begin tref]<em>While</em> loop[end]
+
+[begin ref]
+<h3>Syntax</h3>
+<pre>
+<code>
+while <em>condition</em> do
+   <em>instructions</em>
+done
+</code>
+</pre>
+<pre>
+<code>
+while <em>condition</em> do <em>instruction</em> done
+</code>
+</pre>
+<h3>Example</h3>
+<pre>
+<code>
+  begin setup
+        var a <- 43
+        var b <- 0
+
+        while a > 1 do
+          b++
+          a--
+        done
+
+        # Here, b = 42
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]