Project

General

Profile

Revision 19a1e66b

View differences:

src/backends/Horn/horn_backend.ml
85 85
  List.iter
86 86
    (fun dep ->
87 87
      let (local, s) = Corelang.dependency_of_top dep in
88
      let basename = (Options_management.name_dependency (local, s)) ^ ".smt2" in
88
      let basename = (Options_management.name_dependency (local, s) ".lusic") ^ ".smt2" in
89 89
      Log.report ~level:1 (fun fmt -> Format.fprintf fmt "@[<v 0> Horn Library %s@," basename);
90 90
      let horn = load_file basename in
91 91
      fprintf fmt "@.%s@." (horn);
src/clock_calculus.ml
754 754
  | Const c ->
755 755
    clock_top_const env c
756 756
  | TypeDef _ -> List.fold_left clock_top_decl env (consts_of_enum_type decl)
757
  | Open _    -> env
757
  | Include _ | Open _    -> env
758 758

  
759 759
let clock_prog env decls =
760 760
  List.fold_left clock_top_decl env decls
......
786 786
  | ImportedNode nd ->
787 787
      uneval_node_generics (nd.nodei_inputs @ nd.nodei_outputs)
788 788
  | Const _
789
  | Open _
789
  | Include _ | Open _
790 790
  | TypeDef _ -> ()
791 791

  
792 792
let uneval_prog_generics prog =
src/corelang.ml
642 642
    fun nodes decl ->
643 643
      match decl.top_decl_desc with
644 644
	| Node _ -> decl::nodes
645
	| Const _ | ImportedNode _ | Open _ | TypeDef _ -> nodes  
645
	| Const _ | ImportedNode _ | Include _ | Open _ | TypeDef _ -> nodes  
646 646
  ) [] prog
647 647

  
648 648
let get_imported_nodes prog = 
......
650 650
    fun nodes decl ->
651 651
      match decl.top_decl_desc with
652 652
	| ImportedNode _ -> decl::nodes
653
	| Const _ | Node _ | Open _ | TypeDef _-> nodes  
653
	| Const _ | Node _ | Include _ | Open _ | TypeDef _-> nodes  
654 654
  ) [] prog
655 655

  
656 656
let get_consts prog = 
......
658 658
    fun decl consts ->
659 659
      match decl.top_decl_desc with
660 660
	| Const _ -> decl::consts
661
	| Node _ | ImportedNode _ | Open _ | TypeDef _ -> consts  
661
	| Node _ | ImportedNode _ | Include _ | Open _ | TypeDef _ -> consts  
662 662
  ) prog []
663 663

  
664 664
let get_typedefs prog = 
......
666 666
    fun decl types ->
667 667
      match decl.top_decl_desc with
668 668
	| TypeDef _ -> decl::types
669
	| Node _ | ImportedNode _ | Open _ | Const _ -> types  
669
	| Node _ | ImportedNode _ | Include _ | Open _ | Const _ -> types  
670 670
  ) prog []
671 671

  
672 672
let get_dependencies prog =
......
674 674
    fun decl deps ->
675 675
      match decl.top_decl_desc with
676 676
	| Open _ -> decl::deps
677
	| Node _ | ImportedNode _ | TypeDef _ | Const _ -> deps  
677
	| Node _ | ImportedNode _ | TypeDef _ | Include _ | Const _ -> deps  
678 678
  ) prog []
679 679

  
680 680
let get_node_interface nd =
......
878 878
      | TypeDef tdef ->
879 879
	 { top with top_decl_desc = TypeDef (rename_typedef f_var tdef) }
880 880
      | ImportedNode _
881
      | Open _       -> top)
881
        | Include _ | Open _       -> top)
882 882
      ::accu
883 883
) [] prog
884 884
		   )
......
934 934
    fprintf fmt "%s: " ind.nodei_id;
935 935
    Utils.reset_names ();
936 936
    fprintf fmt "%a@ " Types.print_ty ind.nodei_type
937
  | Const _ | Open _ | TypeDef _ -> ()
937
  | Const _ | Include _ | Open _ | TypeDef _ -> ()
938 938

  
939 939
let pp_prog_type fmt tdecl_list =
940 940
  Utils.fprintf_list ~sep:"" pp_decl_type fmt tdecl_list
......
949 949
    fprintf fmt "%s: " ind.nodei_id;
950 950
    Utils.reset_names ();
951 951
    fprintf fmt "%a@ " Clocks.print_ck ind.nodei_clock
952
  | Const _ | Open _ | TypeDef _ -> ()
952
  | Const _ | Include _ | Open _ | TypeDef _ -> ()
953 953

  
954 954
let pp_prog_clock fmt prog =
955 955
  Utils.fprintf_list ~sep:"" pp_decl_clock fmt prog
src/lusic.ml
40 40
	| ImportedNode _ -> header
41 41
	| Const _
42 42
	| TypeDef _
43
	| Open _         -> decl :: header)
43
	| Include _ | Open _         -> decl :: header)
44 44
    prog []
45 45

  
46 46
let check_obsolete lusic basename =
src/lustre_types.ml
218 218
| ImportedNode of imported_node_desc
219 219
| Open of bool * string (* the boolean set to true denotes a local
220 220
			   lusi vs a lusi installed at system level *)
221
| Include of string (* the boolean set to true denotes a local
222
			   lus vs a lus installed at system level *)
221 223
| TypeDef of typedef_desc
222 224
    
223 225
type top_decl =
src/modules.ml
114 114
    | _       -> assert false
115 115
  with Not_found -> Hashtbl.add consts_table name value
116 116

  
117
let import_dependency_aux loc (local, dep) =
118
  let basename = Options_management.name_dependency (local, dep) in
119
  let extension = ".lusic" in 
120
  try
121
    let lusic = Lusic.read_lusic basename extension in
122
    Lusic.check_obsolete lusic basename;
123
    lusic
124
  with
125
  | Sys_error msg ->
126
      raise (Error (loc, Error.Unknown_library basename))
127
    
128
let import_dependency loc (local, dep) =
129
  try
130
    import_dependency_aux loc (local, dep)
131
  with
132
  | Corelang.Error (_, err) as exc -> (
133
    Format.eprintf "Import error: %a%a@."
134
      Error.pp_error_msg err
135
      Location.pp_loc loc;
136
    raise exc
137
  )
117
(* let import_dependency_aux loc (local, dep) =
118
 *   let basename = Options_management.name_dependency (local, dep) in
119
 *   let extension = ".lusic" in 
120
 *   try
121
 *     let lusic = Lusic.read_lusic basename extension in
122
 *     Lusic.check_obsolete lusic basename;
123
 *     lusic
124
 *   with
125
 *   | Sys_error msg ->
126
 *       raise (Error (loc, Error.Unknown_library basename))
127
 *     
128
 * let import_dependency loc (local, dep) =
129
 *   try
130
 *     import_dependency_aux loc (local, dep)
131
 *   with
132
 *   | Corelang.Error (_, err) as exc -> (
133
 *     Format.eprintf "Import error: %a%a@."
134
 *       Error.pp_error_msg err
135
 *       Location.pp_loc loc;
136
 *     raise exc
137
 *   ) *)
138 138

  
139 139
let get_lusic decl =
140 140
  match decl.top_decl_desc with
141 141
  | Open (local, dep) -> (
142 142
    let loc = decl.top_decl_loc in
143
    let basename = Options_management.name_dependency (local, dep) in
144 143
    let extension = ".lusic" in 
144
    let basename = Options_management.name_dependency (local, dep) extension in
145 145
    try
146 146
      let lusic = Lusic.read_lusic basename extension in
147 147
      Lusic.check_obsolete lusic basename;
......
168 168
			 Env.add_value ck_env ind.nodei_id ind.nodei_clock)
169 169
  | Const c          -> get_envs_from_const c (ty_env, ck_env)
170 170
  | TypeDef _        -> List.fold_left get_envs_from_top_decl (ty_env, ck_env) (consts_of_enum_type top_decl)
171
  | Open _           -> (ty_env, ck_env)
171
  | Include _ | Open _           -> (ty_env, ck_env)
172 172

  
173 173
(* get type and clock environments from a header *)
174 174
let get_envs_from_top_decls header =
......
187 187
      match decl.top_decl_desc with
188 188
      | Open (local, dep) ->
189 189
         (* loading the dep *)
190
         let basename = Options_management.name_dependency (local, dep) in
190
         let basename = Options_management.name_dependency (local, dep) ".lusic" in
191 191
         if List.exists
192
              (fun dep -> basename = Options_management.name_dependency (dep.local, dep.name))
192
              (fun dep -> basename = Options_management.name_dependency (dep.local, dep.name) ".lusic")
193 193
              accu_dep
194 194
         then
195 195
           (* Library already imported. Just skip *)
196 196
           accu
197 197
         else (
198
           Log.report ~level:1 (fun fmt -> Format.fprintf fmt "@ Library %s@ " basename);
198
           Log.report ~level:1 (fun fmt -> Format.fprintf fmt "@ .. Library %s@ " basename);
199 199
           let lusic = get_lusic decl in
200 200
           (* Recursive call with accumulator on lusic *)
201 201
           let (accu_prog, accu_dep, typ_env, clk_env) =
......
211 211
            one and the updated envs *)
212 212
           accu_prog, (new_dep::accu_dep), typ_env, clk_env
213 213
         )
214
      (*    | Include xxx -> TODO
215
                     load the lus file
216
                     call load_rec ~is_header:false accu on the luscontent
217
       *)                     
214
      | Include name ->
215
         let basename = Options_management.name_dependency (true, name) "" in
216
         let include_src = Compiler_common.parse_source basename in
217
         load_rec ~is_header:false accu include_src
218
                         
218 219

  
219 220
      | Node nd ->
220 221
         if is_header then
src/normalization.ml
630 630
    let decl' = {decl with top_decl_desc = Node (normalize_node decls nd)} in
631 631
    Hashtbl.replace Corelang.node_table nd.node_id decl';
632 632
    decl'
633
  | Open _ | ImportedNode _ | Const _ | TypeDef _ -> decl
633
    | Include _| Open _ | ImportedNode _ | Const _ | TypeDef _ -> decl
634 634

  
635 635
let normalize_prog p decls =
636 636
  (* Backend specific configurations for normalization *)
src/options_management.ml
58 58
let core_dependency lib_name =
59 59
  search_lib_path (false, lib_name ^ ".h")
60 60
    
61
let name_dependency (local, dep) =
62
  let dir = search_lib_path (false, dep ^ ".lusic") in
61
let name_dependency (local, dep) ext =
62
  let dir = search_lib_path (false, dep ^ ext) in
63 63
  dir ^ "/" ^ dep
64 64
  
65 65
let set_mpfr prec =
src/parsers/lexer_lustre.mll
126 126
| "tel." {TEL}
127 127
| "tel;" {TEL}
128 128
| "#open" { OPEN }
129
| "include" { INCLUDE }
129 130
| ['_' 'a'-'z'] [ '_' 'a'-'z' 'A'-'Z' '0'-'9']*
130 131
    {let s = Lexing.lexeme lexbuf in
131 132
    try
......
137 138
    try
138 139
      Hashtbl.find keyword_table s
139 140
    with Not_found ->
140
      UIDENT s}
141
      UIDENT s}     
141 142
| "->" {ARROW}
142 143
| "=>" {IMPL}
143 144
| "<=" {LTE}
......
161 162
| ':' {COL}
162 163
| ',' {COMMA}
163 164
| '=' {EQ}
164
| '/' {DIV}
165 165
| "&&" {AMPERAMPER}
166 166
| "||" {BARBAR}
167 167
| "::" {COLCOL}
168 168
| "^" {POWER}
169 169
| '"' {QUOTE}
170
| '.' {POINT}
170 171
| eof { EOF }
171 172
| _ { raise (Parse.Error (Location.curr lexbuf, Parse.Undefined_token (Lexing.lexeme lexbuf))) }
172 173

  
src/parsers/parser_lustre.mly
57 57

  
58 58
%token <string> STRING
59 59
%token AUTOMATON STATE UNTIL UNLESS RESTART RESUME 
60
%token ASSERT OPEN QUOTE FUNCTION
60
%token ASSERT OPEN INCLUDE QUOTE POINT FUNCTION
61 61
%token <string> IDENT
62 62
%token <string> UIDENT
63 63
%token TRUE FALSE
......
128 128
%type <Lustre_types.var_decl list> vdecl_list
129 129
%%
130 130

  
131

  
131 132
module_ident:
132 133
  UIDENT { $1 }
133 134
| IDENT  { $1 }
134 135

  
136
file_ident:
137
module_ident { $1 } 
138
| module_ident POINT file_ident { $1 ^ "." ^ $3 } 
139

  
140
path_ident:
141
POINT DIV path_ident { "./" ^ $3 }
142
| file_ident DIV path_ident { $1 ^ "/" ^ $3 }
143
| DIV path_ident { "/" ^ $2 }
144
| file_ident { $1 }
145

  
135 146
tag_ident:
136 147
  UIDENT  { $1 }
137 148
| TRUE    { tag_true }
......
172 183
| open_lusi open_list { $1 :: $2 }
173 184

  
174 185
open_lusi:
175
| OPEN QUOTE module_ident QUOTE { mktop_decl false (Open (true, $3))}
176
| OPEN LT module_ident GT { mktop_decl false (Open (false, $3)) }
186
  | OPEN QUOTE path_ident QUOTE { mktop_decl false (Open (true, $3)) }
187
  | INCLUDE QUOTE path_ident QUOTE { mktop_decl false (Include ($3)) }
188
  | OPEN LT path_ident GT { mktop_decl false (Open (false, $3))  }
177 189

  
178 190
top_decl_list:
179 191
   {[]}
src/plugins/mpfr/mpfr.ml
315 315
  match decl.top_decl_desc with
316 316
  | Node nd ->
317 317
    {decl with top_decl_desc = Node (inject_node nd)}
318
  | Open _ | ImportedNode _ | Const _ | TypeDef _ -> decl
318
  | Include _ | Open _ | ImportedNode _ | Const _ | TypeDef _ -> decl
319 319
  
320 320
let inject_prog decls = 
321 321
  List.map inject_decl decls
src/printers.ml
382 382
     fprintf fmt "imported %a;" pp_imported_node ind
383 383
  | Const c -> fprintf fmt "const %a" pp_const_decl c
384 384
  | Open (local, s) -> if local then fprintf fmt "#open \"%s\"" s else fprintf fmt "#open <%s>" s
385
  | Include s -> fprintf fmt "include \"%s\"" s
385 386
  | TypeDef tdef -> fprintf fmt "%a" pp_typedef tdef
386 387
  
387 388
let pp_prog fmt prog =
......
402 403
  | Node nd -> fprintf fmt "node %s@ " nd.node_id
403 404
  | ImportedNode ind -> fprintf fmt "imported node %s" ind.nodei_id
404 405
  | Const c -> fprintf fmt "const %a@ " pp_const_decl c
406
  | Include s -> fprintf fmt "include \"%s\"" s
405 407
  | Open (local, s) -> if local then fprintf fmt "#open \"%s\"@ " s else fprintf fmt "#open <%s>@ " s
406 408
  | TypeDef tdef -> fprintf fmt "type %s;@ " tdef.tydef_id
407 409
  
......
409 411
  match decl.top_decl_desc with
410 412
  | ImportedNode ind -> fprintf fmt "%a;@ " pp_imported_node ind
411 413
  | Const c -> fprintf fmt "const %a@ " pp_const_decl c
414
  | Include s -> fprintf fmt "include \"%s\"" s
412 415
  | Open (local, s) -> if local then fprintf fmt "#open \"%s\"@ " s else fprintf fmt "#open <%s>@ " s
413 416
  | TypeDef tdef -> fprintf fmt "%a@ " pp_typedef tdef
414 417
  | Node _ -> assert false
src/typing.ml
766 766
      | Const c ->
767 767
         type_top_const env c
768 768
      | TypeDef _ -> List.fold_left type_top_decl env (consts_of_enum_type decl)
769
      | Open _  -> env
769
      | Include _ | Open _  -> env
770 770
    
771 771
    let get_type_of_call decl =
772 772
      match decl.top_decl_desc with
......
811 811
         uneval_node_generics (nd.node_inputs @ nd.node_outputs)
812 812
      | ImportedNode nd ->
813 813
         uneval_node_generics (nd.nodei_inputs @ nd.nodei_outputs)
814
      | Const _
815
        | TypeDef _
816
        | Open _
814
      | Const _ | TypeDef _ | Open _ | Include _ 
817 815
        -> ()
818 816

  
819 817
    let uneval_prog_generics prog =

Also available in: Unified diff