@jpoly1219/context-extractor 0.2.4 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/ocaml-utils/_build/.filesystem-clock +1 -0
- package/dist/src/ocaml-utils/_build/.lock +0 -0
- package/dist/src/ocaml-utils/_build/default/.dune/configurator +2 -0
- package/dist/src/ocaml-utils/_build/default/.dune/configurator.v2 +1 -0
- package/dist/src/ocaml-utils/_build/default/.js/default/compiler-libs.common/ocamlcommon.cma.js +160991 -0
- package/dist/src/ocaml-utils/_build/default/.js/default/js_of_ocaml/js_of_ocaml.cma.js +7195 -0
- package/dist/src/ocaml-utils/_build/default/.js/default/js_of_ocaml-compiler.runtime/jsoo_runtime.cma.js +73 -0
- package/dist/src/ocaml-utils/_build/default/.js/default/stdlib/std_exit.cmo.js +25 -0
- package/dist/src/ocaml-utils/_build/default/.js/default/stdlib/stdlib.cma.js +28451 -0
- package/dist/src/ocaml-utils/_build/default/.merlin-conf/exe-test_parser +0 -0
- package/dist/src/ocaml-utils/_build/default/.ppx/7b799aed44581cc79b02033532c5f775/_ppx.ml-gen +1 -0
- package/dist/src/ocaml-utils/_build/default/.ppx/7b799aed44581cc79b02033532c5f775/dune__exe___ppx.cmi +0 -0
- package/dist/src/ocaml-utils/_build/default/.ppx/7b799aed44581cc79b02033532c5f775/dune__exe___ppx.cmo +0 -0
- package/dist/src/ocaml-utils/_build/default/.ppx/7b799aed44581cc79b02033532c5f775/dune__exe___ppx.cmx +0 -0
- package/dist/src/ocaml-utils/_build/default/.ppx/7b799aed44581cc79b02033532c5f775/dune__exe___ppx.o +0 -0
- package/dist/src/ocaml-utils/_build/default/.ppx/7b799aed44581cc79b02033532c5f775/ppx.exe +0 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/byte/dune__exe__Test_parser.cmi +0 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/byte/dune__exe__Test_parser.cmo +0 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/byte/dune__exe__Test_parser.cmt +0 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/byte/dune__exe__Test_parser.cmti +0 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/jsoo/dune__exe__Test_parser.cmo.js +215 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/jsoo/test_parser.bc.runtime.js +8894 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/native/dune__exe__Test_parser.cmx +0 -0
- package/dist/src/ocaml-utils/_build/default/.test_parser.eobjs/native/dune__exe__Test_parser.o +0 -0
- package/dist/src/ocaml-utils/_build/default/test_parser.bc-for-jsoo +0 -0
- package/dist/src/ocaml-utils/_build/default/test_parser.bc.d.ts +3 -0
- package/dist/src/ocaml-utils/_build/default/test_parser.bc.js +194658 -0
- package/dist/src/ocaml-utils/_build/default/test_parser.ml +315 -0
- package/dist/src/ocaml-utils/_build/default/test_parser.pp.ml +0 -0
- package/dist/src/ocaml-utils/_build/default/test_parser.pp.mli +1 -0
- package/dist/src/ocaml-utils/_build/log +22 -0
- package/package.json +9 -6
- /package/dist/{app.d.ts → src/app.d.ts} +0 -0
- /package/dist/{app.js → src/app.js} +0 -0
- /package/dist/{codeql.d.ts → src/codeql.d.ts} +0 -0
- /package/dist/{codeql.js → src/codeql.js} +0 -0
- /package/dist/{constants.d.ts → src/constants.d.ts} +0 -0
- /package/dist/{constants.js → src/constants.js} +0 -0
- /package/dist/{core.d.ts → src/core.d.ts} +0 -0
- /package/dist/{core.js → src/core.js} +0 -0
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{index.js → src/index.js} +0 -0
- /package/dist/{main.d.ts → src/main.d.ts} +0 -0
- /package/dist/{main.js → src/main.js} +0 -0
- /package/dist/{ocaml-driver.d.ts → src/ocaml-driver.d.ts} +0 -0
- /package/dist/{ocaml-driver.js → src/ocaml-driver.js} +0 -0
- /package/dist/{ocaml-type-checker.d.ts → src/ocaml-type-checker.d.ts} +0 -0
- /package/dist/{ocaml-type-checker.js → src/ocaml-type-checker.js} +0 -0
- /package/dist/{runner.d.ts → src/runner.d.ts} +0 -0
- /package/dist/{runner.js → src/runner.js} +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
- /package/dist/{typescript-driver.d.ts → src/typescript-driver.d.ts} +0 -0
- /package/dist/{typescript-driver.js → src/typescript-driver.js} +0 -0
- /package/dist/{typescript-type-checker.d.ts → src/typescript-type-checker.d.ts} +0 -0
- /package/dist/{typescript-type-checker.js → src/typescript-type-checker.js} +0 -0
- /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
- /package/dist/{utils.js → src/utils.js} +0 -0
@@ -0,0 +1,315 @@
|
|
1
|
+
open Js_of_ocaml
|
2
|
+
|
3
|
+
(* Parse some stringified OCaml code. *)
|
4
|
+
(* let parse_from_string str = *)
|
5
|
+
(* let lexbuf = Lexing.from_string str in *)
|
6
|
+
(* try *)
|
7
|
+
(* let parsed_str = Parse.implementation lexbuf in *)
|
8
|
+
(* Some parsed_str *)
|
9
|
+
(* with *)
|
10
|
+
(* | Syntaxerr.Error _ -> *)
|
11
|
+
(* prerr_endline "Syntax error!"; *)
|
12
|
+
(* None *)
|
13
|
+
(* | _ -> *)
|
14
|
+
(* prerr_endline "An error occurred!"; *)
|
15
|
+
(* None *)
|
16
|
+
(**)
|
17
|
+
(* let rec print_core_type (core_type : Parsetree.core_type) indent print_desc = *)
|
18
|
+
(* let indent_str = String.make indent ' ' in *)
|
19
|
+
(* match core_type.ptyp_desc with *)
|
20
|
+
(* | Ptyp_tuple elements -> *)
|
21
|
+
(* if print_desc then Printf.printf "%sTuple core types: " indent_str; *)
|
22
|
+
(* Printf.printf "%s\n" (Format.asprintf "%a" Pprintast.core_type core_type); *)
|
23
|
+
(* List.iter (fun el -> print_core_type el (indent + 2) false) elements; *)
|
24
|
+
(* if print_desc then Printf.printf "\n" *)
|
25
|
+
(* (* | Ptyp_constr (loc, []) -> *) *)
|
26
|
+
(* (* Printf.printf "%sIdentifier: %s\n" indent_str *) *)
|
27
|
+
(* (* (match loc.txt with Longident.Lident li -> li | _ -> "Other constr") *) *)
|
28
|
+
(* | Ptyp_constr (loc, core_types) -> *)
|
29
|
+
(* if print_desc then Printf.printf "%sConstr core types: " indent_str; *)
|
30
|
+
(* List.iter *)
|
31
|
+
(* (fun ctyp -> *)
|
32
|
+
(* print_core_type ctyp indent false; *)
|
33
|
+
(* Printf.printf " ") *)
|
34
|
+
(* core_types; *)
|
35
|
+
(* Printf.printf "%s" *)
|
36
|
+
(* (match loc.txt with Longident.Lident li -> li | _ -> "Other constr"); *)
|
37
|
+
(* if print_desc then Printf.printf "\n" *)
|
38
|
+
(* | Ptyp_arrow (_, t1, t2) -> *)
|
39
|
+
(* if print_desc then Printf.printf "%sArrow core type: " indent_str; *)
|
40
|
+
(* print_core_type t1 (indent + 2) false; *)
|
41
|
+
(* Printf.printf " -> "; *)
|
42
|
+
(* print_core_type t2 (indent + 2) false; *)
|
43
|
+
(* if print_desc then Printf.printf "\n" *)
|
44
|
+
(* | _ -> Printf.printf "%sOther core_type\n" indent_str *)
|
45
|
+
(**)
|
46
|
+
(* let rec print_pattern (pattern : Parsetree.pattern) indent = *)
|
47
|
+
(* let indent_str = String.make indent ' ' in *)
|
48
|
+
(* match pattern.ppat_desc with *)
|
49
|
+
(* | Parsetree.Ppat_var loc -> Printf.printf "%sVar: %s\n" indent_str loc.txt *)
|
50
|
+
(* | Parsetree.Ppat_tuple pats -> *)
|
51
|
+
(* Printf.printf "%sTuple:\n" indent_str; *)
|
52
|
+
(* List.iter (fun pat -> print_pattern pat (indent + 2)) pats *)
|
53
|
+
(* | Parsetree.Ppat_constraint (pat, core_type) -> *)
|
54
|
+
(* Printf.printf "%sConstraint:\n" indent_str; *)
|
55
|
+
(* print_pattern pat (indent + 2); *)
|
56
|
+
(* print_core_type core_type (indent + 2) true *)
|
57
|
+
(* | _ -> Printf.printf "%sOther pattern\n" indent_str *)
|
58
|
+
(**)
|
59
|
+
(* (* Print the expression tree. *) *)
|
60
|
+
(* let rec print_expression (expr : Parsetree.expression) indent = *)
|
61
|
+
(* let indent_str = String.make indent ' ' in *)
|
62
|
+
(* match expr.pexp_desc with *)
|
63
|
+
(* | Pexp_ident { txt = Longident.Lident id; _ } -> *)
|
64
|
+
(* Printf.printf "%sIdentifier: %s\n" indent_str id *)
|
65
|
+
(* | Pexp_constant const -> *)
|
66
|
+
(* Printf.printf "%sConstant: %s\n" indent_str *)
|
67
|
+
(* (match const with *)
|
68
|
+
(* | Pconst_integer (n, _) -> n *)
|
69
|
+
(* | Pconst_string (s, _, _) -> "\"" ^ s ^ "\"" *)
|
70
|
+
(* | Pconst_float (f, _) -> f *)
|
71
|
+
(* | Pconst_char c -> String.make 1 c) *)
|
72
|
+
(* | Pexp_apply (func, args) -> *)
|
73
|
+
(* Printf.printf "%sApply:\n" indent_str; *)
|
74
|
+
(* print_expression func (indent + 2); *)
|
75
|
+
(* List.iter (fun (_, arg) -> print_expression arg (indent + 2)) args *)
|
76
|
+
(* | Pexp_tuple elements -> *)
|
77
|
+
(* Printf.printf "%sTuple:\n" indent_str; *)
|
78
|
+
(* List.iter (fun el -> print_expression el (indent + 2)) elements *)
|
79
|
+
(* | Pexp_function (params, rettype, _) -> ( *)
|
80
|
+
(* Printf.printf "%sFunction:\n" indent_str; *)
|
81
|
+
(* List.iter *)
|
82
|
+
(* (fun (param : Parsetree.function_param) -> *)
|
83
|
+
(* match param.pparam_desc with *)
|
84
|
+
(* | Pparam_val (Nolabel, None, pat) -> *)
|
85
|
+
(* Printf.printf "%s Params:\n" indent_str; *)
|
86
|
+
(* print_pattern pat (indent + 4) *)
|
87
|
+
(* | Pparam_newtype loc -> *)
|
88
|
+
(* Printf.printf "%sNewtype Param: %s\n" indent_str loc.txt *)
|
89
|
+
(* | _ -> Printf.printf "%sOther params\n" indent_str) *)
|
90
|
+
(* params; *)
|
91
|
+
(* match rettype with *)
|
92
|
+
(* | Some pcon -> ( *)
|
93
|
+
(* match pcon with *)
|
94
|
+
(* | Pconstraint ret -> *)
|
95
|
+
(* Printf.printf "%s Return:\n" indent_str; *)
|
96
|
+
(* print_core_type ret (indent + 4) true *)
|
97
|
+
(* | _ -> Printf.printf "%sOther rettype" indent_str) *)
|
98
|
+
(* | _ -> Printf.printf "%sOther type_constraint\n" indent_str) *)
|
99
|
+
(* | _ -> Printf.printf "%sOther expression\n" indent_str *)
|
100
|
+
(**)
|
101
|
+
(* (* Print the parsed structure. *) *)
|
102
|
+
(* let print_structure_item (item : Parsetree.structure_item) indent = *)
|
103
|
+
(* let indent_str = String.make indent ' ' in *)
|
104
|
+
(* match item.pstr_desc with *)
|
105
|
+
(* | Pstr_value (rec_flag, bindings) -> *)
|
106
|
+
(* Printf.printf "%sValue binding%s:\n" indent_str *)
|
107
|
+
(* (if rec_flag = Recursive then " (recursive)" else ""); *)
|
108
|
+
(* List.iter *)
|
109
|
+
(* (fun (vb : Parsetree.value_binding) -> *)
|
110
|
+
(* Printf.printf "%s Pattern: %s\n" indent_str *)
|
111
|
+
(* (Format.asprintf "%a" Pprintast.pattern vb.pvb_pat); *)
|
112
|
+
(* Printf.printf "%s Expression:\n" indent_str; *)
|
113
|
+
(* print_expression vb.pvb_expr (indent + 4)) *)
|
114
|
+
(* bindings *)
|
115
|
+
(* | Pstr_type (_, type_decls) -> *)
|
116
|
+
(* Printf.printf "%sType declarations:\n" indent_str; *)
|
117
|
+
(* List.iter *)
|
118
|
+
(* (fun (td : Parsetree.type_declaration) -> *)
|
119
|
+
(* Printf.printf "%s Type name: %s\n" indent_str td.ptype_name.txt; *)
|
120
|
+
(* match td.ptype_kind with *)
|
121
|
+
(* | Ptype_variant ctor_decls -> *)
|
122
|
+
(* List.iter *)
|
123
|
+
(* (fun (ctor : Parsetree.constructor_declaration) -> *)
|
124
|
+
(* Printf.printf "%s Constructor name: %s" indent_str *)
|
125
|
+
(* ctor.pcd_name.txt; *)
|
126
|
+
(* match ctor.pcd_args with *)
|
127
|
+
(* | Parsetree.Pcstr_tuple core_types -> *)
|
128
|
+
(* if List.length core_types = 0 then print_string "\n" *)
|
129
|
+
(* else *)
|
130
|
+
(* List.iter *)
|
131
|
+
(* (fun (core_type : Parsetree.core_type) -> *)
|
132
|
+
(* match core_type.ptyp_desc with *)
|
133
|
+
(* | Ptyp_constr ({ txt = Longident.Lident id; _ }, _) *)
|
134
|
+
(* -> *)
|
135
|
+
(* Printf.printf "%s of %s\n" indent_str id *)
|
136
|
+
(* | _ -> *)
|
137
|
+
(* Printf.printf "%sOther structure item\n" *)
|
138
|
+
(* indent_str) *)
|
139
|
+
(* core_types *)
|
140
|
+
(* | _ -> Printf.printf "%sOther structure item\n" indent_str) *)
|
141
|
+
(* ctor_decls *)
|
142
|
+
(* | _ -> Printf.printf "%sOther structure item\n" indent_str) *)
|
143
|
+
(* type_decls *)
|
144
|
+
(* | _ -> Printf.printf "%sOther structure item\n" indent_str *)
|
145
|
+
(**)
|
146
|
+
(* (* Print the structure. *) *)
|
147
|
+
(* let print_structure structure = *)
|
148
|
+
(* List.iter (fun item -> print_structure_item item 0) structure *)
|
149
|
+
|
150
|
+
(* Function to print the parsed structure *)
|
151
|
+
(* let print_typedecl_tree (typedecl : Parsetree.type_declaration) (indent : int) = *)
|
152
|
+
(* let indent_str = String.make indent ' ' in *)
|
153
|
+
(* match typedecl.ptype_kind with *)
|
154
|
+
(* | Ptype_variant ctor_decls -> *)
|
155
|
+
(* print_int (List.length ctor_decls); *)
|
156
|
+
(* print_string indent_str *)
|
157
|
+
(* | _ -> Printf.printf "%sOther expression type\n" indent_str *)
|
158
|
+
(**)
|
159
|
+
(* let print_typedecl typedecl = print_typedecl_tree typedecl 0 *)
|
160
|
+
|
161
|
+
(* Function to print the parsed expression *)
|
162
|
+
(* let print_expression expr = print_expression_tree expr 0 *)
|
163
|
+
|
164
|
+
(* let read_file filename = *)
|
165
|
+
(* let ch = open_in_bin filename in *)
|
166
|
+
(* let s = really_input_string ch (in_channel_length ch) in *)
|
167
|
+
(* close_in ch; *)
|
168
|
+
(* s *)
|
169
|
+
let rec string_of_type (typ : Parsetree.core_type) : string =
|
170
|
+
match typ.ptyp_desc with
|
171
|
+
| Ptyp_arrow (_, t1, t2) ->
|
172
|
+
let arg1 = string_of_type t1 in
|
173
|
+
let arg2 = string_of_type t2 in
|
174
|
+
arg1 ^ " -> " ^ arg2
|
175
|
+
| Ptyp_tuple types ->
|
176
|
+
let type_strings = List.map string_of_type types in
|
177
|
+
String.concat " * " type_strings
|
178
|
+
| Ptyp_constr ({ txt = Lident s; _ }, []) -> s
|
179
|
+
| Ptyp_constr ({ txt = Lident s; _ }, ctyp_list) ->
|
180
|
+
let args_str = List.map string_of_type ctyp_list |> String.concat ", " in
|
181
|
+
args_str ^ " " ^ s
|
182
|
+
| _ -> "unknown"
|
183
|
+
|
184
|
+
let rec extract_core_type (ctyp : Parsetree.core_type) (components_only : bool)
|
185
|
+
=
|
186
|
+
if components_only then (
|
187
|
+
match ctyp.ptyp_desc with
|
188
|
+
| Ptyp_arrow (_, argtyp, rettyp) ->
|
189
|
+
[ "Ptyp_arrow"; string_of_type argtyp; string_of_type rettyp ]
|
190
|
+
| Ptyp_tuple types ->
|
191
|
+
"Ptyp_tuple"
|
192
|
+
:: List.fold_right (fun curr acc -> string_of_type curr :: acc) types []
|
193
|
+
| Ptyp_constr ({ txt = Lident id; _ }, []) -> [ "Ptyp_constr"; id ]
|
194
|
+
| Ptyp_constr ({ txt = Lident id; _ }, [ ctyps ]) ->
|
195
|
+
[ "Ptyp_constr"; string_of_type ctyps; id ]
|
196
|
+
| _ ->
|
197
|
+
Printf.printf "Other core type";
|
198
|
+
[ "Other core type" ])
|
199
|
+
else
|
200
|
+
match ctyp.ptyp_desc with
|
201
|
+
| Ptyp_arrow (_, _, rettyp) ->
|
202
|
+
string_of_type ctyp :: extract_core_type rettyp components_only
|
203
|
+
| Ptyp_tuple types ->
|
204
|
+
List.fold_left
|
205
|
+
(fun acc curr ->
|
206
|
+
List.append (extract_core_type curr components_only) acc)
|
207
|
+
[] types
|
208
|
+
| Ptyp_constr ({ txt = Lident id; _ }, []) -> id :: []
|
209
|
+
| Ptyp_constr ({ txt = Lident id; _ }, [ ctyps ]) ->
|
210
|
+
[ string_of_type ctyps ^ " " ^ id ]
|
211
|
+
| _ ->
|
212
|
+
Printf.printf "Other core type";
|
213
|
+
[]
|
214
|
+
|
215
|
+
(* Save this for later when we actually need to get the constructors *)
|
216
|
+
(* let analyze_structure (structure : Parsetree.structure) = *)
|
217
|
+
(* List.iter *)
|
218
|
+
(* (fun (item : Parsetree.structure_item) -> *)
|
219
|
+
(* match item.pstr_desc with *)
|
220
|
+
(* | Pstr_type (_, type_decls) -> *)
|
221
|
+
(* List.iter *)
|
222
|
+
(* (fun (td : Parsetree.type_declaration) -> *)
|
223
|
+
(* (* Printf.printf "Type: %s\n" td.ptype_name.txt; *) *)
|
224
|
+
(* match td.ptype_kind with *)
|
225
|
+
(* | Ptype_variant ctors -> *)
|
226
|
+
(* List.iter *)
|
227
|
+
(* (fun (ctor : Parsetree.constructor_declaration) -> *)
|
228
|
+
(* Printf.printf " Constructor: %s\n" ctor.pcd_name.txt) *)
|
229
|
+
(* ctors *)
|
230
|
+
(* | _ -> Printf.printf "Other type kind\n") *)
|
231
|
+
(* type_decls *)
|
232
|
+
(* | _ -> Printf.printf "Not a type declaration\n") *)
|
233
|
+
(* structure; *)
|
234
|
+
|
235
|
+
let parse_core_type_from_type_span s =
|
236
|
+
let lexbuf = Lexing.from_string s in
|
237
|
+
try Some (Parse.core_type lexbuf) with _ -> None
|
238
|
+
|
239
|
+
let parse_implementation_from_type_span s =
|
240
|
+
let lexbuf = Lexing.from_string ("type tmp = " ^ s) in
|
241
|
+
try Some (Parse.implementation lexbuf) with _ -> None
|
242
|
+
|
243
|
+
(* Walk the AST and extrac]]t target types. *)
|
244
|
+
let extract_target_types (type_span : string) =
|
245
|
+
let parsed = parse_core_type_from_type_span type_span in
|
246
|
+
match parsed with
|
247
|
+
| Some ctyp -> extract_core_type ctyp false
|
248
|
+
| None -> (
|
249
|
+
let parsed2 = parse_implementation_from_type_span type_span in
|
250
|
+
match parsed2 with
|
251
|
+
(* | Some impl -> analyze_structure impl *)
|
252
|
+
| Some _ -> [ type_span ]
|
253
|
+
| None -> failwith "Failed to parse type span")
|
254
|
+
|
255
|
+
(* print_endline "Structure parsed successfully!"; *)
|
256
|
+
(* extract_core_type parsed false *)
|
257
|
+
|
258
|
+
let extract_component_types (type_span : string) =
|
259
|
+
let parsed = parse_core_type_from_type_span type_span in
|
260
|
+
match parsed with
|
261
|
+
| Some ctyp -> extract_core_type ctyp true
|
262
|
+
| None -> (
|
263
|
+
let parsed2 = parse_implementation_from_type_span type_span in
|
264
|
+
match parsed2 with
|
265
|
+
(* | Some impl -> analyze_structure impl *)
|
266
|
+
| Some _ -> [ type_span ]
|
267
|
+
| None -> failwith "Failed to parse type span")
|
268
|
+
|
269
|
+
let js_extract_target_types (type_span : string) =
|
270
|
+
let extracted = extract_target_types type_span in
|
271
|
+
Js.array (Array.of_list extracted)
|
272
|
+
|
273
|
+
(* What do we want? todo -> model * int would yield todo, model * int *)
|
274
|
+
(* model * int * string would yield model, int, string *)
|
275
|
+
let js_extract_component_types (type_span : string) =
|
276
|
+
let extracted = extract_component_types type_span in
|
277
|
+
Js.array (Array.of_list extracted)
|
278
|
+
|
279
|
+
(* Example usage *)
|
280
|
+
(* let () = *)
|
281
|
+
(* (* TODO: How do we extract this type span string? *) *)
|
282
|
+
(* let strs = *)
|
283
|
+
(* [ *)
|
284
|
+
(* "todo * todo -> bool"; *)
|
285
|
+
(* "model * model -> bool"; *)
|
286
|
+
(* "model"; *)
|
287
|
+
(* "model -> todo list"; *)
|
288
|
+
(* "int * todo list -> todo list"; *)
|
289
|
+
(* "int * todo list -> todo list * bool"; *)
|
290
|
+
(* "int * todo list -> ((todo * action) * (string -> bool))"; *)
|
291
|
+
(* "id list * playlist_state"; *)
|
292
|
+
(* "Playing of id | PausedOn of id | NoSongSelected"; *)
|
293
|
+
(* ] *)
|
294
|
+
(* in *)
|
295
|
+
(* (* let str = *) *)
|
296
|
+
(* (* read_file *) *)
|
297
|
+
(* (* "/home/jacob/projects/context-extractor/targets/ocaml/todo/prelude.ml" *) *)
|
298
|
+
(* (* in *) *)
|
299
|
+
(* List.iter *)
|
300
|
+
(* (fun str -> *)
|
301
|
+
(* List.iter *)
|
302
|
+
(* (fun el -> *)
|
303
|
+
(* print_string el; *)
|
304
|
+
(* print_endline " ; ") *)
|
305
|
+
(* (extract_target_types str)) *)
|
306
|
+
(* strs *)
|
307
|
+
|
308
|
+
let _ = Js.export "parse" (Js.wrap_callback js_extract_target_types)
|
309
|
+
let _ = Js.export "getComponents" (Js.wrap_callback js_extract_component_types)
|
310
|
+
|
311
|
+
(* match parse_from_string str with *)
|
312
|
+
(* | Some parsed_str -> *)
|
313
|
+
(* print_endline "Structure parsed successfully!"; *)
|
314
|
+
(* print_structure parsed_str *)
|
315
|
+
(* | None -> print_endline "Failed to parse structure." *)
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
(* Auto-generated by Dune *)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# dune build
|
2
|
+
# OCAMLPARAM: unset
|
3
|
+
# Shared cache: disabled
|
4
|
+
# Shared cache location: /home/jacob/.cache/dune/db
|
5
|
+
# Workspace root: /home/jacob/projects/context-extractor/src/ocaml-utils
|
6
|
+
# Auto-detected concurrency: 28
|
7
|
+
# Dune context:
|
8
|
+
# { name = "default"
|
9
|
+
# ; kind = "default"
|
10
|
+
# ; profile = Dev
|
11
|
+
# ; merlin = true
|
12
|
+
# ; fdo_target_exe = None
|
13
|
+
# ; build_dir = In_build_dir "default"
|
14
|
+
# ; instrument_with = []
|
15
|
+
# }
|
16
|
+
$ /home/jacob/projects/context-extractor/_opam/bin/ocamlc.opt -config > /tmp/dune_373e9c_output
|
17
|
+
$ /home/jacob/projects/context-extractor/_opam/bin/js_of_ocaml --version > /tmp/dune_b2583a_output
|
18
|
+
$ (cd _build/.sandbox/9e8f0b7dd6ddb28d97b155423158163d/default && .ppx/7b799aed44581cc79b02033532c5f775/ppx.exe -o test_parser.pp.ml --impl test_parser.ml -corrected-suffix .ppx-corrected -diff-cmd - -dump-ast)
|
19
|
+
$ (cd _build/default && /home/jacob/projects/context-extractor/_opam/bin/ocamlc.opt -w @1..3@5..28@31..39@43@46..47@49..57@61..62@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -bin-annot-occurrences -I .test_parser.eobjs/byte -I /home/jacob/projects/context-extractor/_opam/lib/js_of_ocaml -I /home/jacob/projects/context-extractor/_opam/lib/js_of_ocaml-compiler/runtime -I /home/jacob/projects/context-extractor/_opam/lib/ocaml/compiler-libs -intf-suffix .ml -no-alias-deps -opaque -o .test_parser.eobjs/byte/dune__exe__Test_parser.cmo -c -impl test_parser.pp.ml)
|
20
|
+
$ (cd _build/default && /home/jacob/projects/context-extractor/_opam/bin/js_of_ocaml --pretty --source-map-inline -o .test_parser.eobjs/jsoo/dune__exe__Test_parser.cmo.js .test_parser.eobjs/byte/dune__exe__Test_parser.cmo)
|
21
|
+
$ (cd _build/default && /home/jacob/projects/context-extractor/_opam/bin/js_of_ocaml link --source-map-inline -o test_parser.bc.js .test_parser.eobjs/jsoo/test_parser.bc.runtime.js .js/default/stdlib/stdlib.cma.js .js/default/compiler-libs.common/ocamlcommon.cma.js .js/default/js_of_ocaml-compiler.runtime/jsoo_runtime.cma.js .js/default/js_of_ocaml/js_of_ocaml.cma.js .test_parser.eobjs/jsoo/dune__exe__Test_parser.cmo.js .js/default/stdlib/std_exit.cmo.js)
|
22
|
+
$ (cd _build/default && /home/jacob/projects/context-extractor/_opam/bin/ocamlc.opt -w @1..3@5..28@31..39@43@46..47@49..57@61..62@67@69-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -o test_parser.bc-for-jsoo -no-check-prims -noautolink /home/jacob/projects/context-extractor/_opam/lib/ocaml/compiler-libs/ocamlcommon.cma /home/jacob/projects/context-extractor/_opam/lib/js_of_ocaml-compiler/runtime/jsoo_runtime.cma /home/jacob/projects/context-extractor/_opam/lib/js_of_ocaml/js_of_ocaml.cma .test_parser.eobjs/byte/dune__exe__Test_parser.cmo)
|
package/package.json
CHANGED
@@ -1,19 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jpoly1219/context-extractor",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.6",
|
4
4
|
"description": "Extract relevant context from an incomplete program sketch.",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
7
7
|
"url": "https://github.com/jpoly1219/context-extractor.git"
|
8
8
|
},
|
9
|
-
"main": "dist/index.js",
|
10
|
-
"types": "dist/index.d.ts",
|
9
|
+
"main": "dist/src/index.js",
|
10
|
+
"types": "dist/src/index.d.ts",
|
11
11
|
"files": [
|
12
|
-
"dist"
|
13
|
-
"dist/ts-lsp-client-dist"
|
12
|
+
"dist/"
|
14
13
|
],
|
15
14
|
"scripts": {
|
16
|
-
"build": "
|
15
|
+
"build": "npx tsc && npm run copy-deps",
|
16
|
+
"copy-deps": "npm run copy-lsp-client && npm run copy-ocaml",
|
17
|
+
"copy-lsp-client": "shx cp -r ts-lsp-client-dist dist/",
|
18
|
+
"copy-ocaml": "shx mkdir -p dist/src/ocaml-utils/ && shx cp -r src/ocaml-utils/_build dist/src/ocaml-utils/_build/",
|
17
19
|
"test": "echo \"Error: no test specified\" && exit 1"
|
18
20
|
},
|
19
21
|
"author": "",
|
@@ -22,6 +24,7 @@
|
|
22
24
|
"json-rpc-2.0": "^1.7.0",
|
23
25
|
"openai": "^4.30.0",
|
24
26
|
"pino": "^9.3.1",
|
27
|
+
"shx": "^0.3.4",
|
25
28
|
"ts-node": "^10.9.2",
|
26
29
|
"tslib": "^2.6.3"
|
27
30
|
},
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|