This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
5
unikernel/duniverse/ppxlib/astlib/pp/dune
Normal file
5
unikernel/duniverse/ppxlib/astlib/pp/dune
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(executables
|
||||
(names pp)
|
||||
(flags :standard -w -3))
|
||||
|
||||
(ocamllex pp_rewrite)
|
||||
12
unikernel/duniverse/ppxlib/astlib/pp/pp.ml
Normal file
12
unikernel/duniverse/ppxlib/astlib/pp/pp.ml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
let () =
|
||||
match Sys.argv with
|
||||
| [| _; ocaml_version; fname |] ->
|
||||
let is_current =
|
||||
Filename.basename fname = Printf.sprintf "ast_%s.ml" ocaml_version
|
||||
in
|
||||
let ic = open_in_bin fname in
|
||||
Printf.printf "# 1 %S\n" fname;
|
||||
Pp_rewrite.rewrite is_current ocaml_version (Lexing.from_channel ic)
|
||||
| _ ->
|
||||
Printf.eprintf "%s: <ocaml-version> <file-name>\n" Sys.executable_name;
|
||||
exit 2
|
||||
1
unikernel/duniverse/ppxlib/astlib/pp/pp.mli
Normal file
1
unikernel/duniverse/ppxlib/astlib/pp/pp.mli
Normal file
|
|
@ -0,0 +1 @@
|
|||
(* empty *)
|
||||
1
unikernel/duniverse/ppxlib/astlib/pp/pp_rewrite.mli
Normal file
1
unikernel/duniverse/ppxlib/astlib/pp/pp_rewrite.mli
Normal file
|
|
@ -0,0 +1 @@
|
|||
val rewrite : bool -> string -> Lexing.lexbuf -> unit
|
||||
31
unikernel/duniverse/ppxlib/astlib/pp/pp_rewrite.mll
Normal file
31
unikernel/duniverse/ppxlib/astlib/pp/pp_rewrite.mll
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
rule rewrite is_current ocaml_version = parse
|
||||
| "(*IF_CURRENT " ([^'*']* as s) "*)"
|
||||
{ let chunk = if is_current
|
||||
then " " ^ s ^ " "
|
||||
else Lexing.lexeme lexbuf
|
||||
in
|
||||
print_string chunk;
|
||||
rewrite is_current ocaml_version lexbuf
|
||||
}
|
||||
| "(*IF_AT_LEAST " ([^'*' ' ']* as v) " " (([^'*'] | '*' [^')'])* as s) "*)"
|
||||
{ let chunk = if (v <= ocaml_version)
|
||||
then " " ^ String.make (String.length v + 1) ' ' ^ s ^ " "
|
||||
else Lexing.lexeme lexbuf
|
||||
in
|
||||
print_string chunk;
|
||||
rewrite is_current ocaml_version lexbuf
|
||||
}
|
||||
| "(*IF_NOT_AT_LEAST " ([^'*' ' ']* as v) " " (([^'*'] | '*' [^')'])* as s) "*)"
|
||||
{ let chunk = if not (v <= ocaml_version)
|
||||
then " " ^ String.make (String.length v + 1) ' ' ^ s ^ " "
|
||||
else Lexing.lexeme lexbuf
|
||||
in
|
||||
print_string chunk;
|
||||
rewrite is_current ocaml_version lexbuf
|
||||
}
|
||||
| _ as c
|
||||
{ print_char c;
|
||||
rewrite is_current ocaml_version lexbuf
|
||||
}
|
||||
| eof { () }
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue