This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
8
unikernel/duniverse/cppo/examples/Makefile
Normal file
8
unikernel/duniverse/cppo/examples/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
.PHONY: all clean
|
||||
all:
|
||||
../cppo debug.ml > debug.out
|
||||
../cppo french.ml > french.out
|
||||
ocamllex lexer.mll
|
||||
../cppo lexer.ml > lexer.out
|
||||
clean:
|
||||
rm -f *.out lexer.ml
|
||||
7
unikernel/duniverse/cppo/examples/debug.ml
Normal file
7
unikernel/duniverse/cppo/examples/debug.ml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#ifdef DEBUG
|
||||
#define debug(s) Printf.eprintf "[%S %i] %s\n%!" __FILE__ __LINE__ s
|
||||
#else
|
||||
#define debug(s) ()
|
||||
#endif
|
||||
|
||||
debug("test")
|
||||
32
unikernel/duniverse/cppo/examples/dune
Normal file
32
unikernel/duniverse/cppo/examples/dune
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
(ocamllex lexer)
|
||||
|
||||
(rule
|
||||
(deps
|
||||
(:< debug.ml))
|
||||
(targets debug.out)
|
||||
(action
|
||||
(with-stdout-to
|
||||
%{targets}
|
||||
(run %{bin:cppo} %{<}))))
|
||||
|
||||
(rule
|
||||
(deps
|
||||
(:< french.ml))
|
||||
(targets french.out)
|
||||
(action
|
||||
(with-stdout-to
|
||||
%{targets}
|
||||
(run %{bin:cppo} %{<}))))
|
||||
|
||||
(rule
|
||||
(deps
|
||||
(:< lexer.ml))
|
||||
(targets lexer.out)
|
||||
(action
|
||||
(with-stdout-to
|
||||
%{targets}
|
||||
(run %{bin:cppo} %{<}))))
|
||||
|
||||
(alias
|
||||
(name DEFAULT)
|
||||
(deps debug.out french.out lexer.out))
|
||||
34
unikernel/duniverse/cppo/examples/french.ml
Normal file
34
unikernel/duniverse/cppo/examples/french.ml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#define soit let
|
||||
#define fonction function
|
||||
#define fon fun
|
||||
#define dans in
|
||||
#define si if
|
||||
#define alors then
|
||||
#define sinon else
|
||||
|
||||
#define Liste List
|
||||
#define Affichef Printf
|
||||
#define affichef printf
|
||||
|
||||
#define separation split
|
||||
#define tri sort
|
||||
|
||||
soit rec separation x = fonction
|
||||
y :: l ->
|
||||
soit l1, l2 = separation x l dans
|
||||
si y < x alors (y :: l1), l2
|
||||
sinon l1, (y :: l2)
|
||||
| [] ->
|
||||
[], []
|
||||
|
||||
soit rec tri = fonction
|
||||
x :: l ->
|
||||
soit l1, l2 = separation x l dans
|
||||
tri l1 @ [x] @ tri l2
|
||||
| [] ->
|
||||
[]
|
||||
|
||||
soit () =
|
||||
soit l = tri [ 5; 3; 7; 1; 7; 4; 99; 22 ] dans
|
||||
Liste.iter (fon i -> Affichef.affichef "%i " i) l;
|
||||
Affichef.affichef "\n"
|
||||
9
unikernel/duniverse/cppo/examples/lexer.mll
Normal file
9
unikernel/duniverse/cppo/examples/lexer.mll
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(* Warning: ocamllex doesn't accept cppo directives
|
||||
within the rules section. *)
|
||||
rule token = parse
|
||||
['a'-'z']+ { `String (Lexing.lexeme lexbuf) }
|
||||
{
|
||||
#ifndef NOFOO
|
||||
let foo () = ()
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue