ADT generator: add support for open and include
This commit is contained in:
parent
516a3a85ff
commit
58fc08b6a7
@ -1,3 +1,5 @@
|
||||
(* open Amodule_utils *)
|
||||
|
||||
type root =
|
||||
| A of rootA
|
||||
| B of rootB
|
||||
|
@ -10,8 +10,13 @@ sub poly { $^type_name }
|
||||
|
||||
my $l = @*ARGS[0].IO.lines;
|
||||
$l = $l.map(*.subst: /^\s+/, "");
|
||||
$l = $l.list.cache;
|
||||
my $statement_re = /^((\(\*\s+)?(open|include)\s|\[\@\@\@warning\s)/;
|
||||
my $statements = $l.grep($statement_re);
|
||||
$l = $l.grep(none $statement_re);
|
||||
$statements = $statements.map(*.subst(/^\(\*\s+/, '').subst(/\s+\*\)$/, ''));
|
||||
$l = $l.cache.map(*.subst: /^type\s+/, "\nand ");
|
||||
$l = $l.join("\n").split(/\nand\s+/).grep(/./);
|
||||
$l = $l.join("\n").subst(/\n+/, "\n").split(/\nand\s+/).grep(/./);
|
||||
$l = $l.map(*.split("\n"));
|
||||
$l = $l.map: {
|
||||
my $ll = $_;
|
||||
@ -131,8 +136,10 @@ my $adts = (map -> (:$name , :$kind, :@ctorsOrFields) {
|
||||
say "(* This is an auto-generated file. Do not edit. *)";
|
||||
|
||||
say "";
|
||||
for $statements -> $statement {
|
||||
say "$statement"
|
||||
}
|
||||
say "open $moduleName";
|
||||
say "open {$moduleName}_utils";
|
||||
say "module Adt_info = Generic.Adt_info";
|
||||
|
||||
say "";
|
||||
|
Loading…
Reference in New Issue
Block a user