Commits

camlspotter committed 23e21cc

3 colons

  • Participants
  • Parent commits acfcf0b
  • Branches dev

Comments (0)

Files changed (1)

-<!-- language: ocaml -->
 # ORakuda #
 
 Available at [http://bitbucket.org/camlspotter/orakuda/](http://bitbucket.org/camlspotter/orakuda/ .)
 
 * PCRE expression and matching of Perl like syntax `$/.../`:
 
+    :::ocaml
     let f x = fun x -> x + x (Foo (1,2))
     $/regexp/
     str |! $/regexp/ -> ... | _ -> ...
 
 * Variable and expression references in string `$"..."`:
 
+        :::ocaml
         $"Your are ${name} and %{age}02d years old."
 
 * Sub-shell call by back-quotes ``$`...``: 
 
+        :::ocaml
         let status = $`wc` ~f:handle_output in ...
 
 * Easy hashtbl access `tbl${key}`:
 
+    :::ocaml
     tbl${key} <- value for Hashtbl.replace tbl key value.
 
 Some are reimplementations of existing CamlP4 extensions. ORakuda's 
 
 * build the library and pa_* extensions:
 
+    :::sh
     $ ocaml setup.ml -configure
 	$ ocaml setup.ml -build
 	$ ocaml setup.ml -install
 
 ### Via OPAM ###
 
+    :::sh
     $ opam install orakuda
 
 ## How to use ##
 
 For easier access to functions, users are recommend to declare:
 
+    :::ocaml
     open Rakuda.Std
    
 at the begining of their source file.
 
 #### SYNTAX ####
 
+        :::ocaml
         $/regular expression/flags      (with patched P4)
         <:m<regular expression>> 
         <:m<regular expression/flags>>
 the type parameter ``'a`` encodes accessor information of the regexp's
 groups. See GROUP OBJECT METHODS for details:
 
+    :::ocaml
     # $/(hello)world(?P<name>[a-z]+)/;;
     - : < _0 : string; _1 : string; _2 : string; _group : int -> string;
           _groups : string array; _left : string;
 matching and return group objects if matches are successful. 
 The matched groups can be retrieved through them:
 
-  # let res = "123 + variable12;;" =~ $/([a-z_][_A-Za-z0-9]*)/;;
-  val res :
-  < _0 : string; _1 : string; _group : int -> string; _groups : string array;
-    _left : string; _named_group : string -> string;
-    _named_groups : (string * string) list; _right : string;
-    _unsafe_group : int -> string > =
-  <obj>
+    :::ocaml
+    # let res = "123 + variable12;;" =~ $/([a-z_][_A-Za-z0-9]*)/;;
+    val res :
+    < _0 : string; _1 : string; _group : int -> string; _groups : string array;
+      _left : string; _named_group : string -> string;
+      _named_groups : (string * string) list; _right : string;
+      _unsafe_group : int -> string > =
+    <obj>
     
 ##### GROUP OBJECT METHODS #####
     
 ### Perl like PCRE case match ``$/.../ -> ...`` ###
 
 #### SYNTAX ####
-    
+
+       :::ocaml
        $/regular expression/flags as var -> e
        | $/regular expression/flags as var -> e
        | ...
 PCRE case match expression is recommended to use with the pipe
 operator ``(|!)`` or ``(|>)`` (available Jane Street Core or OCaml Battries Included):
 
+     :::ocaml
      # "variable123" 
        |! $/^[0-9]+$/ as v -> `Int (int_of_string v#_0)
        |  $/^[a-z][A-Za-z0-9_]*$/ as v -> `Variable v#_0
 #### Perl like PCRE substitution ``$s/.../.../``  or  ``<:s<.../...>>`` ####
 
 ##### SYNTAX #####
-    
+
+        :::ocaml
         $s/regular expression/template/flags      with extended P4
         <:s<regular expression/template>>
         <:s<regular expression/template/flags>>
 ### Perl like sprintf. ``$"..."``  or ``<:qq<...>>`` ###
 
 #### SYNTAX ####
-    
+
+        ::ocaml
         $"..."         (with patched P4)
         <:qq<...>>
     
     
 ##### EXAMPLE #####
     
+        ::ocaml
         $"... $foo123 ..."     
             Equivalent to Printf.sprintf "... %s ..." foo123
       
 
 #### SYNTAX ####
   
+    ::ocaml
     tbl${key}             Hashtbl.find tbl key
     tbl${key} <- data     Hashtbl.replace tbl key data