1. Pierre Surply
  2. Mara

Commits

Pierre Surply  committed d755468

Added website

  • Participants
  • Parent commits e99bb03
  • Branches master

Comments (0)

Files changed (34)

File .gitignore

View file
 *_build/
 *_mbuild/
 *.native
-marac
+marac
+mara.cgi

File compiler/backend/gen.ml

View file
 **    along with Mara.  If not, see <http://www.gnu.org/licenses/>.
 **
 ** Started on  Thu Dec 27 19:13:52 2012 Pierre Surply
-** Last update Tue Jan 22 12:14:09 2013 Pierre Surply
+** Last update Sun Feb 10 12:43:50 2013 Pierre Surply
 *)
 
 open Ast
 		      Instr ("ldi", RegInt (25, 0));
 		      Label "2"
 		     ]
-	    | "<>" -> [Instr ("cp", RegReg(24, 18));
+	    | "!=" -> [Instr ("cp", RegReg(24, 18));
 		       Instr ("cpc", RegReg(25, 19));
-		       Instr ("brne", String "1f");
-		       Instr ("ldi", RegInt (24, 0));
+		       Instr ("breq", String "1f");
+		       Instr ("ldi", RegInt (24, 1));
 		       Instr ("ldi", RegInt (25, 0));
 		       Instr ("rjmp", String "2f");
 		       Label "1";
-		       Instr ("ldi", RegInt (24, 1));
+		       Instr ("ldi", RegInt (24, 0));
 		       Instr ("ldi", RegInt (25, 0));
 		       Label "2"
 		     ]

File compiler/parser/lexer.mll

View file
 **    along with Mara.  If not, see <http://www.gnu.org/licenses/>.
 **
 ** Started on  Fri Nov  9 15:58:41 2012 Pierre Surply
-** Last update Sun Jan 20 12:09:04 2013 Pierre Surply
+** Last update Sun Feb 10 18:41:28 2013 Pierre Surply
 *)
 
 {
      ("<",	LT);
      ("<=",	LE);
      ("<>",	NEQ);
+     ("!=",	NEQ);
      ("=",	DEQ);
      (".",	DOT);
      (":",	COLON);

File samples/Makefile

View file
 ## <pierre.surply@gmail.com>
 ## 
 ## Started on  Sun Jan 20 12:24:46 2013 Pierre Surply
-## Last update Mon Jan 21 12:13:52 2013 Pierre Surply
+## Last update Sun Feb 10 12:39:12 2013 Pierre Surply
 ##
 
-MCU		= 8
+MCU		= 1280
 
 MARAC		= marac
 MFLAGS		= -mmcu atmega$(MCU) -v

File samples/main.mr

View file
 begin setup
-        PORTB.set_pin_in(0)
-        var uart <- new uart(23)
+        PORTB.set_pin_out(7)
+        PORTB.pin_low(7)
 end
 
 begin loop
-        waitfor not PORTB.read_pin(0)
-        uart.write("Hello World !\n\r")
-        waitfor PORTB.read_pin(0)
 end

File stdlib/uart.mr

View file
 
 func init(rate)
         self.rate <- rate
-        asm<rate> "out UBRRL, r24
-                   out UBRRH, r25
-                   sbi UCSRB, TXEN
-                   sbi UCSRB, RXEN"
+        asm<rate> "sts UBRR0L, r24
+                   sts UBRR0H, r25
+                   ldi r24, (1 << TXEN0) | (1 << RXEN0)
+                   sts UCSR0B, r24
+                   ldi r24, 3 << UCSZ00
+                   sts UCSR0C, r24"
         return self
 end
 
 
 func send(x)
         waitfor not \
-                (((asm "in   r24, UCSRA
+                (((asm "lds   r24, UCSR0A
                         ldi  r25, 0") >> 5) & 1)
-        asm<x> "out UDR, r24"
+        asm<x> "sts UDR0, r24"
 end
 
 func available()
-        return (((asm "in   r24, UCSRA
+        return (((asm "lds   r24, UCSR0A
                        ldi  r25, 0") >> 7) & 1)
 end
 
 func recv()
-        return asm "in  r24, UDR
+        return asm "lds r24, UDR0
                     ldi r25, 0"
 end
 

File term/Makefile

View file
 ## <pierre.surply@gmail.com>
 ## 
 ## Started on  Sun Jan 20 12:24:46 2013 Pierre Surply
-## Last update Fri Jan 25 18:25:48 2013 Pierre Surply
+## Last update Sun Feb  3 19:34:29 2013 Pierre Surply
 ##
 
-MCU		= 8
+MCU		= 328p
 
 MARAC		= marac
 MFLAGS		= -mmcu atmega$(MCU) -v

File term/main.mr

View file
 ## <pierre.surply@gmail.com>
 ## 
 ## Started on  Fri Jan 25 17:56:51 2013 Pierre Surply
-## Last update Fri Jan 25 19:37:06 2013 Pierre Surply
+## Last update Tue Feb  5 13:09:49 2013 Pierre Surply
 ##
 
 begin setup
+        PORTC.set_mode(0xFF)
+        PORTC.write(42)
         var term <- new term(23)
         term.wait_start()
 end

File term/term.mr

View file
 ## <pierre.surply@gmail.com>
 ## 
 ## Started on  Fri Jan 25 17:57:37 2013 Pierre Surply
-## Last update Sat Jan 26 09:58:15 2013 Pierre Surply
+## Last update Tue Feb  5 13:49:34 2013 Pierre Surply
 ##
 
 uart    com
 func wait_start()
         waitfor not self.com.available()
         self.com.recv()
-        self.com.write("### Mara Terminal ###
-\r(C) Pierre Surply\n\r")
+        self.com.write("### Mara Terminal ###\n\r(C) Pierre Surply\n\r")
 end
 
 func prompt()
         var c <- 0
-        self.in.set(0, 0)
+        self.in.set(1, 0)
         self.com.write("> ")
         while not (c = 13) do
                 waitfor not self.com.available()
                 c <- self.com.recv()
                 if not (c = 13) then
                         self.com.send(c)
-                        self.in.append_char(c)
+                        self.in.set(0, c)
                 endif
         done
         self.com.write("\n\r")

File website/.htaccess

View file
+AddHandler cgi-script .cgi
+Options +ExecCGI
+DirectoryIndex cgi-bin/mara.cgi

File website/Makefile

View file
+##
+## Makefile for OCaml-WebFramework
+## 
+## Copyright (C) 2012 Pierre Surply
+## <pierre.surply@gmail.com>
+##
+## This file is part of OCaml-WebFramework.
+##
+##    OCaml-WebFramework is free software: you can redistribute it and/or modify
+##    it under the terms of the GNU General Public License as published by
+##    the Free Software Foundation, either version 3 of the License, or
+##    (at your option) any later version.
+##
+##    OCaml-WebFramework is distributed in the hope that it will be useful,
+##    but WITHOUT ANY WARRANTY; without even the implied warranty of
+##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+##    GNU General Public License for more details.
+##
+##    You should have received a copy of the GNU General Public License
+##    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+## 
+## Started on  Fri Sep 14 20:30:24 2012 Pierre Surply
+## Last update Sun Feb 10 14:31:17 2013 Pierre Surply
+##
+
+EXEC = mara.cgi
+export EXEC
+
+all: cgi-bin
+
+clean: COMMAND=clean
+clean: cgi-bin
+
+test: COMMAND=test
+test: cgi-bin
+
+cgi-bin::
+	@$(MAKE) -C $@ $(COMMAND)

File website/cgi-bin/Makefile

View file
+##
+## Makefile for OCaml-WebFramework in /cgi-bin
+##  
+## Copyright (C) 2012 Pierre Surply
+## <pierre.surply@gmail.com>
+##
+## This file is part of OCaml-WebFramework.
+##
+##    OCaml-WebFramework is free software: you can redistribute it and/or modify
+##    it under the terms of the GNU General Public License as published by
+##    the Free Software Foundation, either version 3 of the License, or
+##    (at your option) any later version.
+##
+##    OCaml-WebFramework is distributed in the hope that it will be useful,
+##    but WITHOUT ANY WARRANTY; without even the implied warranty of
+##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+##    GNU General Public License for more details.
+##
+##    You should have received a copy of the GNU General Public License
+##    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+##
+## Started on  Sat Sep 15 11:14:39 2012 Pierre Surply
+## Last update Thu Oct 11 15:51:22 2012 pierre surply
+##
+
+OCAMLBUILD = ocamlbuild
+BUILDFLAGS = -lflags unix.cmxa,str.cmxa -verbose 1
+BUILDTYPE  = native
+
+MAIN	   = main.$(BUILDTYPE)
+URL_TEST   = index/
+
+all: $(MAIN)
+
+$(MAIN):
+	@$(OCAMLBUILD) $(BUILDFLAGS) $@
+	@mv $(MAIN) $(EXEC)
+
+test: REQUEST_METHOD=GET
+test: QUERY_STRING=$(URL_TEST)
+test: $(MAIN)
+	./$(EXEC)
+
+clean:
+	@$(OCAMLBUILD) -clean

File website/cgi-bin/cgi_functions.ml

View file
+(*
+** cgi_functions.ml for OCaml-WebFramework
+** 
+** Copyright (C) 2012 Pierre Surply
+** <pierre.surply@gmail.com>
+**
+** This file is part of OCaml-WebFramework.
+**
+**    OCaml-WebFramework is free software: you can redistribute it and/or modify
+**    it under the terms of the GNU General Public License as published by
+**    the Free Software Foundation, either version 3 of the License, or
+**    (at your option) any later version.
+**
+**    OCaml-WebFramework is distributed in the hope that it will be useful,
+**    but WITHOUT ANY WARRANTY; without even the implied warranty of
+**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**    GNU General Public License for more details.
+**
+**    You should have received a copy of the GNU General Public License
+**    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+** 
+** Started on  Sat Sep 15 21:11:04 2012 Pierre Surply
+Last update Thu Oct 11 15:34:58 2012 pierre surply
+*)
+
+let get_function = function
+  | "get_time" -> Date.get_date ()
+  | f -> "Cannot find function : " ^ f

File website/cgi-bin/date.ml

View file
+(*
+** date.ml for OCaml-WebFramework
+** 
+** Copyright (C) 2012 Pierre Surply
+** <pierre.surply@gmail.com>
+**
+** This file is part of OCaml-WebFramework.
+**
+**    OCaml-WebFramework is free software: you can redistribute it and/or modify
+**    it under the terms of the GNU General Public License as published by
+**    the Free Software Foundation, either version 3 of the License, or
+**    (at your option) any later version.
+**
+**    OCaml-WebFramework is distributed in the hope that it will be useful,
+**    but WITHOUT ANY WARRANTY; without even the implied warranty of
+**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**    GNU General Public License for more details.
+**
+**    You should have received a copy of the GNU General Public License
+**    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+** 
+** Started on  Sat Sep 15 21:11:47 2012 Pierre Surply
+Last update Thu Oct 11 15:34:41 2012 pierre surply
+*)
+
+let get_date () =
+  let time = Unix.localtime (Unix.time ()) in
+  string_of_int (time.Unix.tm_hour) ^ ":" ^
+    string_of_int (time.Unix.tm_min) ^ ":" ^
+    string_of_int (time.Unix.tm_sec)

File website/cgi-bin/env.ml

View file
+(*
+** env.ml for OCaml-WebFramework
+** 
+** Copyright (C) 2012 Pierre Surply
+** <pierre.surply@gmail.com>
+**
+** This file is part of OCaml-WebFramework.
+**
+**    OCaml-WebFramework is free software: you can redistribute it and/or modify
+**    it under the terms of the GNU General Public License as published by
+**    the Free Software Foundation, either version 3 of the License, or
+**    (at your option) any later version.
+**
+**    OCaml-WebFramework is distributed in the hope that it will be useful,
+**    but WITHOUT ANY WARRANTY; without even the implied warranty of
+**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**    GNU General Public License for more details.
+**
+**    You should have received a copy of the GNU General Public License
+**    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+** 
+** Started on  Sun Sep 16 13:57:47 2012 Pierre Surply
+** Last update Sun Feb 10 14:44:08 2013 Pierre Surply
+*)
+
+let get_env str =
+  try
+    Sys.getenv str
+  with Not_found -> ""
+
+let url =
+  let req_method = get_env "REQUEST_METHOD" in
+  match req_method with
+    | "GET" | "HEAD" -> get_env "QUERY_STRING"
+    | _ -> ""
+
+let url_arg =
+  let regex = Str.regexp "\\([^/]*\\)/" in
+  let rec build_url_arg s start =
+    if (try Str.search_forward regex s start
+      with Not_found -> -1) > -1 then
+      begin
+	let start = Str.match_end () in
+	let arg = Str.matched_group 1 s in
+	arg::build_url_arg s start
+      end
+    else []
+  in
+  build_url_arg url 0
+
+let get_url_arg n =
+  let rec r_get n = function
+    | [] -> ""
+    | h::t ->
+      if n = 0 then h
+      else r_get (n-1) t
+  in
+  r_get n url_arg

File website/cgi-bin/main.ml

View file
+(*
+** main.ml for OCaml-WebFramework
+**  
+** Copyright (C) 2012 Pierre Surply
+** <pierre.surply@gmail.com>
+**
+** This file is part of OCaml-WebFramework.
+**
+**    OCaml-WebFramework is free software: you can redistribute it and/or modify
+**    it under the terms of the GNU General Public License as published by
+**    the Free Software Foundation, either version 3 of the License, or
+**    (at your option) any later version.
+**
+**    OCaml-WebFramework is distributed in the hope that it will be useful,
+**    but WITHOUT ANY WARRANTY; without even the implied warranty of
+**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**    GNU General Public License for more details.
+**
+**    You should have received a copy of the GNU General Public License
+**    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+**
+** Started on  Sat Sep 15 11:14:18 2012 Pierre Surply
+** Last update Sun Feb 10 14:44:12 2013 Pierre Surply
+*)
+
+let content_type = "Content-Type: text/html;\n\n"
+
+let main () =
+  print_string (content_type ^ 
+		  Url.make_page_from_url ());
+  exit 0
+
+let _ = main ()

File website/cgi-bin/template.ml

View file
+(*
+** template.ml for OCaml-WebFramework
+**
+** Copyright (C) 2012 Pierre Surply
+** <pierre.surply@gmail.com>
+**
+** This file is part of OCaml-WebFramework.
+**
+**    OCaml-WebFramework is free software: you can redistribute it and/or modify
+**    it under the terms of the GNU General Public License as published by
+**    the Free Software Foundation, either version 3 of the License, or
+**    (at your option) any later version.
+**
+**    OCaml-WebFramework is distributed in the hope that it will be useful,
+**    but WITHOUT ANY WARRANTY; without even the implied warranty of
+**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**    GNU General Public License for more details.
+**
+**    You should have received a copy of the GNU General Public License
+**    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+**
+** Started on  Sat Sep 15 13:45:19 2012 Pierre Surply
+** Last update Sun Feb 10 14:44:17 2013 Pierre Surply
+*)
+
+let template_dir = "../templates/"
+let base = "base"
+
+let regex_link = Str.regexp "{@ \\(.*\\) @}"
+let regex_fun = Str.regexp "{% \\(.*\\) %}"
+let regex_include = Str.regexp "{ \\([^{}]*\\) }"
+let regex_part = Str.regexp
+  "\\[begin \\(.*\\)\\]\\(\\([^][]\\|\n\\)*\\)\\[end\\]"
+
+let apply_function s =
+  Cgi_functions.get_function (Str.matched_group 1 s)
+
+let rec extract_part s start org_list=
+  if (try Str.search_forward regex_part s start
+    with Not_found -> -1) > -1 then
+    begin
+      let start = Str.match_end () in
+      let label = Str.matched_group 1 s in
+      let content = Str.matched_group 2 s in
+      (label, content)::extract_part s start org_list
+    end
+  else org_list
+
+let rec get_part label = function
+  | [] -> "<!-- " ^ label ^ " -->"
+  | (l, c)::t ->
+    if l = label then c
+    else get_part label t
+
+let fill_part part s =
+  get_part (Str.matched_group 1 s) part
+
+let make_page file =
+  let rec r_load_template f =
+    try
+      let line = input_line f in
+      line ^ "\n" ^ r_load_template f
+    with End_of_file -> close_in f; ""
+  in
+  let rec r_load file part=
+    let s = r_load_template (open_in (template_dir ^ file)) in
+    let s_applied_fun = Str.global_substitute regex_fun
+      apply_function s in
+    let s_filled = Str.global_substitute regex_include
+      (fill_part part) s_applied_fun in
+    let part = extract_part s_filled 0 part in
+    if (try Str.search_forward regex_link s_filled 0
+      with Not_found -> -1) > -1 then
+      r_load (Str.matched_group 1 s_filled) part
+    else
+      get_part base part
+  in
+  r_load file []

File website/cgi-bin/url.ml

View file
+(*
+** url.ml for OCaml-WebFramework
+**
+** Copyright (C) 2012 Pierre Surply
+** <pierre.surply@gmail.com>
+**
+** This file is part of OCaml-WebFramework.
+**
+**    OCaml-WebFramework is free software: you can redistribute it and/or modify
+**    it under the terms of the GNU General Public License as published by
+**    the Free Software Foundation, either version 3 of the License, or
+**    (at your option) any later version.
+**
+**    OCaml-WebFramework is distributed in the hope that it will be useful,
+**    but WITHOUT ANY WARRANTY; without even the implied warranty of
+**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+**    GNU General Public License for more details.
+**
+**    You should have received a copy of the GNU General Public License
+**    along with OCaml-WebFramework.  If not, see <http://www.gnu.org/licenses/>.
+**
+** Started on  Sun Sep 16 11:31:15 2012 Pierre Surply
+** Last update Sun Feb 10 22:29:31 2013 Pierre Surply
+*)
+
+let get_page_from_url () =
+  match Env.get_url_arg 0 with
+    | "ref"             ->
+      "ref/" ^
+        begin
+          match Env.get_url_arg 1 with
+          | "setup"     -> "setup.html"
+          | "arith"     -> "arith.html"
+          | "comp"      -> "comp.html"
+          | "boolop"    -> "boolop.html"
+          | "bitop"     -> "bitop.html"
+          | _           -> "summary.html"
+        end
+    | "faq"             -> "faq.html"
+    | "examples"        -> "examples.html"
+    | "gettingstarted"  -> "gettingstarted.html"
+    | _                 -> "index.html"
+
+let make_page_from_url () =
+  Template.make_page (get_page_from_url ())

File website/res/design/style.css

View file
+/*
+** style.css for Mara
+**
+** Made by Pierre Surply
+** <pierre.surply@gmail.com>
+**
+** Started on  Sun Feb 10 15:09:01 2013 Pierre Surply
+** Last update Sun Feb 10 20:17:24 2013 Pierre Surply
+*/
+
+body
+{
+    margin:             0;
+    padding:            0;
+    background:         white;
+}
+
+a
+{
+    text-decoration:    none;
+    border-bottom:      1px dotted #444444;
+    color:              black;
+}
+
+a:hover
+{
+    color:              #ff4c4d;
+}
+
+nav
+{
+    padding:            10px;
+    width:              220px;
+    float:              left;
+    line-height:        1em;
+}
+
+nav ul
+{
+    margin:             0;
+    padding:            0 10px;
+    list-style:         none;
+}
+
+nav .fl {
+    border-bottom:      1px solid #444444;
+    margin-top:         15px;
+    margin-bottom:      5px;
+}
+
+nav a
+{
+    border-bottom:      none;
+    display:            block;
+    padding:            2px 6px 2px 0px;
+    text-decoration:    none;
+    color:              #444444;
+}
+
+#content
+{
+    margin-left:        250px;
+    padding:            10px;
+}
+
+header {
+    height:             80px;
+    margin-bottom:      2px;
+    background-color:   #EEEEEE;
+    border-bottom:      solid #aaa 1px;
+    display:            block;
+    position:           relative;
+}
+
+header #logo
+{
+    position:           absolute;
+    top:                8px;
+    left:               8px;
+}
+
+header a
+{
+    border-bottom:      none;
+}
+
+pre
+{
+    padding:            5px;
+    background-color:   #EEEEEE;
+}
+
+footer
+{
+    font-size:          .8em;
+    border-top:         dotted #aaa 1px;
+    text-align:         right;
+    clear:              both;
+}
+
+li#ref
+{
+    display:            block;
+    float:              left;
+    margin-right:       50px;
+}

File website/res/img/favicon.png

Added
New image

File website/res/img/logo.png

Added
New image

File website/templates/about.html

View file
+{@ base.html @}
+
+[begin title] About [end]
+
+[begin body]
+<h1>About</h1>
+[end]

File website/templates/base.html

View file
+[begin base]<!DOCTYPE html>
+<html>
+  <head>
+    <title>Mara programming language - { title }</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <link rel="icon" type="image/png" href="res/img/favicon.png" />
+    <link rel="stylesheet" href="res/design/style.css" />
+  </head>
+  <body>
+    <header>
+      <div id="logo">
+        <a href="?index/"><img alt="Mara" src="res/img/logo.png" /></a>
+      </div>
+    </header>
+    <nav>
+      <ul>
+        <li>
+          <div class='fl'>About</div>
+          <ul>
+            <li><a href="?index/">Home</a></li>
+            <li><a href="?examples/">Examples</a></li>
+            <li><a href="?faq/">FAQ</a></li>
+          </ul>
+          <div class='fl'>Documentation</div>
+          <ul>
+            <li><a href="?gettingstarted/">Getting started</a></li>
+            <li><a href="?ref/">Reference</a></li>
+          </ul>
+          <div class='fl'>Download</div>
+          <ul>
+            <li><a href="http://git.psurply.com/mara/get/3.zip">Source code</a></li>
+            <li><a href="http://git.psurply.com/mara/">Git repository</a></li>
+          </ul>
+          <div class='fl'>Links</div>
+          <ul>
+            <li><a href="http://www.psurply.com/">Personal website</a></li>
+            <li><a href="http://www.atmel.com/">Atmel website</a></li>
+            <li><a href="http://www.nongnu.org/avr-libc/">avr-libc</a></li>
+            <li><a href="http://www.engbedded.com/fusecalc">AVR fuse calculator</a></li>
+          </ul>
+        </li>
+      </ul>
+    </nav>
+    <div id="content">
+      { body }
+      <footer>
+        <p>
+          &copy; 2013 Pierre Surply -
+          <script type="text/javascript">
+            document.write('<a href="mailto:'+String.fromCharCode(112,105,101,114,114,101,46,115,117,114,112,108,121,64,103,109,97,105,108,46,99,111,109)+'">Contact</a>');
+          </script>
+        </p>
+      </footer>
+    </div>
+  </body>
+</html>
+[end]

File website/templates/examples.html

View file
+{@ base.html @}
+
+[begin title]Examples[end]
+
+[begin body]
+<h1>Examples</h1>
+<h2>Factorial</h2>
+
+<pre>
+<code>
+    # fact.mr
+    
+    static
+
+    func fact(n)
+            return n = 0 ? 1 :          \
+                   (n * fact(n - 1))
+    end
+
+    # main.mr
+    
+    using fact
+
+    begin setup
+            PORTD.set_mode(0xFF)
+            PORTD.write(fact(3)) # print 6
+    end
+
+    begin loop
+    end
+</code>
+</pre>
+<h2>USART</h2>
+<pre>
+<code>
+    begin setup
+            PORTB.set_pin_in(0)
+            var uart <- new uart(23)
+    end
+
+    begin loop
+            waitfor not PORTB.read_pin(0)
+            uart.write("Hello World !\n\r")
+            waitfor PORTB.read_pin(0)
+    end
+</code>
+</pre>
+<h2>List</h2>
+<pre>
+<code>
+    begin setup
+            PORTD.set_mode(0xFF)
+
+            var l <- &#91;1; 1337; 21; 4&#93;
+            l.insert(1, 42)
+            l.push(0)
+        
+            PORTD.write(l&#91;2&#93;) # print 42
+            
+            del l
+    end
+
+    begin loop
+    end
+</code>
+</pre>
+
+<h2>Classes</h2>
+<pre>
+<code>
+    # point.mr
+
+    integer x
+    integer y
+
+    func init(nx, ny)
+            self.x <- nx
+	        self.y <- ny
+	        return self
+    end
+
+    func squared_dist()
+            return (self.x * self.x) + \
+                   (self.y * self.y)
+    end
+    
+    # main.mr
+    
+    begin setup
+            PORTD.set_mode(0xFF)
+    
+            var p <- new point(2, 3)
+
+            PORTD.write(p.squared_dist()) # print 13
+            
+            del p
+    end
+
+    begin loop
+    end
+</code>
+</pre>
+[end]

File website/templates/faq.html

View file
+{@ base.html @}
+
+[begin title]FAQ[end]
+
+[begin body]
+<h1>FAQ</h1>
+[end]

File website/templates/gettingstarted.html

View file
+{@ base.html @}
+
+[begin title]Getting started[end]
+
+[begin body]
+<h1>Getting started</h1>
+<h2>Edit Mara code with Emacs</h2>
+<p>
+First, copy the file <samp>utils/mara-mode.el</samp> in your <samp>~/.emacs.d/</samp> directory.<br/>
+Then, add the following lines to your <samp>~/.emacs</samp> file :
+</p>
+
+<pre>
+<code>
+  (autoload 'mara-mode "~/.emacs.d/mara-mode.el" "" t)
+  (setq auto-mode-alist (cons '("\\.mr\\w?" . mara-mode) auto-mode-alist))
+</code>
+</pre>
+[end]

File website/templates/index.html

View file
+{@ base.html @}
+
+[begin title]Home[end]
+
+[begin body]
+<h1>What is Mara ?</h1>
+<p>
+<strong>Mara</strong> is a programming language dedicated to <a href="http://www.atmel.com/products/microcontrollers/avr/default.aspx">8bit ATMEL AVR</a> microcontrollers with a focus on simplicity and productivity.
+<br/>
+The goal of this project is to simplify the programming of these microcontrollers for all those who do not wish to use (or learn) the <strong>C</strong> or <strong>assembly language</strong>.
+<br/>
+The core language is still under development. Although stable version is not available, <strong>Mara</strong> can be used experimentally.
+</p>
+<p>A simple Mara syntax example:</p>
+<pre>
+<code>
+    # fact.mr
+    
+    static
+    
+    func fact(n)
+            return n = 0 ? 1 :          \
+                   (n * fact(n - 1))
+    end
+    
+    # main.mr
+    
+    using fact
+    
+    begin setup
+            PORTD.set_mode(0xFF)
+            PORTD.write(fact(3)) # print 6
+    end
+    
+    begin loop
+    end
+</code>
+</pre>
+[end]

File website/templates/ref/arith.html

View file
+{@ ref/ref.html @}
+
+[begin tref]Arithmetic operators[end]
+
+[begin ref]
+<ul>
+  <li>+ <em>(addition)</em></li>
+  <li>- <em>(substraction)</em></li>
+  <li>* <em>(multiplication)</em></li>
+  <li>/ <em>(division)</em></li>
+  <li>% <em>(modulo)</em></li>
+</ul>
+<h2>Example</h2>
+<pre>
+<code>
+  begin setup
+        var a <- 7
+        var b <- 3
+        var c <- 0
+
+        c <- a + b      # c = 10
+        c <- a - b      # c = 4
+        c <- a * b * 2  # c = 42
+        c <- a / b      # c = 2
+        c <- a % b      # c = 1
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

File website/templates/ref/bitop.html

View file
+{@ ref/ref.html @}
+
+[begin tref]Bitwise operators[end]
+
+[begin ref]
+<ul>
+  <li>& <em>(bitwise and)</em></li>
+  <li>| <em>(bitwise or)</em></li>
+  <li>~ <em>(bitwise not)</em></li>
+  <li><< <em>(bitshift left)</em></li>
+  <li>>> <em>(bitshift right)</em></li>
+</ul>
+<h2>Example</h2>
+<pre>
+<code>
+  begin setup
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

File website/templates/ref/boolop.html

View file
+{@ ref/ref.html @}
+
+[begin tref]Boolean operators[end]
+
+[begin ref]
+<ul>
+  <li>and</li>
+  <li>or</li>
+  <li>not</li>
+</ul>
+<h2>Example</h2>
+<pre>
+<code>
+  begin setup
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

File website/templates/ref/comp.html

View file
+{@ ref/ref.html @}
+
+[begin tref]Comparison operators[end]
+
+[begin ref]
+<ul>
+  <li>= <em>(equal to)</em></li>
+  <li>!= | <> <em>(not equal to)</em></li>
+  <li>&#60; <em>(less than)</em></li>
+  <li>&#62; <em>(greater than)</em></li>
+  <li>&#60;= <em>(less than or equal to)</em></li>
+  <li>&#62;= <em>(greater than or equal to)</em></li>
+</ul>
+<h2>Example</h2>
+<pre>
+<code>
+  begin setup
+  end
+  
+  begin loop
+  end
+</code>
+</pre>
+[end]

File website/templates/ref/ref.html

View file
+{@ base.html @}
+
+[begin title]Reference - { tref }[end]
+
+[begin body]
+<h1>Language reference</h1>
+<h2>{ tref }</h2>
+{ ref }
+[end]

File website/templates/ref/setup.html

View file
+{@ ref/ref.html @}
+
+[begin tref]Entry point[end]
+
+[begin ref]
+<pre>
+<code>
+  begin setup
+        PORTB.set_pin_out(7)
+        PORTB.pin_high(7)
+  end
+
+  begin loop
+        # ...
+  end
+</code>
+</pre>
+[end]

File website/templates/ref/summary.html

View file
+{@ ref/ref.html @}
+
+[begin tref]Summary[end]
+
+[begin ref]
+<ul>
+  <li id="ref">
+    <h2>Structure</h2>
+    <ul>
+      <li>
+        <h3>Main structure</h3>
+        <ul>
+          <li><a href="?ref/setup/">setup <em>(Entry point)</em></a></li>
+          <li><a href="?ref/loop/">loop <em>(Main loop)</em></a></li>
+        </ul>
+      </li>
+      <li>
+        <h3>Instructions</h3>
+        <ul>
+          <li>Variable declaration</li>
+          <li>Assignment</li>
+          <li>Compound operator</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>
+        </ul>
+      </li>
+    </ul>
+  </li>
+  <li id="ref">
+    <h2>Expressions</h2>
+    <ul>
+      <li>
+        <h3>Basic operators</h3>
+        <ul>
+          <li><a href="?ref/arith/">Arithmetic operators</a></li>
+          <li><a href="?ref/comp/">Comparison operators</a></li>
+          <li><a href="?ref/boolop/">Boolean operators</a></li>
+          <li><a href="?ref/bitop/">Bitwise operators</a></li>
+        </ul>
+      </li>
+      <li>
+        <h3>Advanced operators</h3>
+        <ul>
+          <li>Object creation/destruction</li>
+          <li>Method call</li>
+          <li>Ternary operation</li>
+          <li>Inline Assembler</li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+  <li id="ref">
+    <h2>Objects</h2>
+    <ul>
+      <li>
+        <h3>Native types</h3>
+        <ul>
+          <li>integer</li>
+          <li>cstring</li>
+          <li>object</li>
+        </ul>
+      </li>
+      <li>
+        <h3>Standard classes</h3>
+        <ul>
+          <li>vect</li>
+          <li>string</li>
+          <li>list</li>
+        </ul>
+      </li>
+      <li>
+        <h3>Class definition</h3>
+        <ul>
+          <li>Attributes</li>
+          <li>Methods</li>
+          <li>Initializer/destructor</li>
+          <li>Static class</li>
+        </ul>
+      </li>
+    </ul>
+  </li>
+</ul>
+[end]