Commit f77dbaf75740d3ec40cf7ac48becf0159d5d5e8e
1 parent
77553097
Exists in
master
fznslurp is now fzsem
Showing
1 changed file
with
0 additions
and
79 deletions
Show diff stats
fz/fznslurp.pl
... | ... | @@ -1,79 +0,0 @@ |
1 | -% == No, Emacs this is -*-Prolog-*- code, not what you thought... ============= | |
2 | - | |
3 | -:- initialization(main). | |
4 | - | |
5 | -main :- | |
6 | - argument_list(A), | |
7 | - main(A). | |
8 | - | |
9 | -main([ACTION_S|REST]) :- | |
10 | - read_term_from_atom(ACTION_S, ACTION, [end_of_term(eof)]), | |
11 | - action(ACTION), !, main(REST). | |
12 | -main([]). | |
13 | - | |
14 | -action(load(F)) :- !, see(F), action(load), seen. | |
15 | -action(load) :- !, load_ast(AST), g_assign(ast, AST). | |
16 | -action(dump(A)) :- !, dump_ast(A). | |
17 | -action(dump) :- !, g_read(ast, AST), dump_ast(AST). | |
18 | -action(name) :- !, | |
19 | - g_read(ast, AST), | |
20 | - sa_names(AST, NAST, ST), | |
21 | - g_assign(ast_n, NAST+ST). | |
22 | -action(type) :- !, | |
23 | - g_read(ast_n, AST+ST), | |
24 | - sa_types(AST, ST), | |
25 | - g_assign(ast_t, AST+ST). | |
26 | -action(halt) :- !, halt. | |
27 | -action(debug) :- g_read(ast_debug, true), !, g_assign(ast_debug, false). | |
28 | -action(debug) :- !, g_assign(ast_debug, true). | |
29 | -action(ACTION) :- format("%w: unknown action.\n", [ACTION]). | |
30 | - | |
31 | - | |
32 | -% ----------------------------------------------------------------------------- | |
33 | - | |
34 | -%% beware: fails if load_ast/3 does not finish with 3rd arg singular list | |
35 | - | |
36 | -load_ast(AST) :- g_read(ast_debug, true), !, load_ast_deb(_>[], [], [AST]). | |
37 | -load_ast(AST) :- load_ast(_>[], [], [AST]). | |
38 | - | |
39 | -load_ast(end_of_file, AST, AST). | |
40 | -load_ast((IN > INT :- MOD), IN, OUT) :- | |
41 | - call(MOD), | |
42 | - read(OP), !, | |
43 | - load_ast(OP, INT, OUT). | |
44 | -load_ast((IN > INT), IN, OUT) :- | |
45 | - read(OP), !, | |
46 | - load_ast(OP, INT, OUT). | |
47 | - | |
48 | -load_ast_deb(end_of_file, AST, AST). | |
49 | -load_ast_deb((IN > INT :- MOD), IN, OUT) :- | |
50 | - ( call(MOD) -> format("EXT OK ~q\n", [MOD]) ; | |
51 | - format("EXT FAIL ~q\n", [MOD]), fail ), | |
52 | - read(OP), !, | |
53 | - writeq(IN), write('.'), nl, | |
54 | - writeq(OP), nl, | |
55 | - load_ast_deb(OP, INT, OUT). | |
56 | -load_ast_deb(IN > INT, IN, OUT) :- | |
57 | - read(OP), !, | |
58 | - writeq(IN), write('.'), nl, | |
59 | - writeq(OP), nl, | |
60 | - load_ast_deb(OP, INT, OUT). | |
61 | - | |
62 | -% ----------------------------------------------------------------------------- | |
63 | - | |
64 | -dump_ast(fzn(PREDS, VARS, CONSTRS, SOLVE)) :- | |
65 | - !, | |
66 | - format("AST:\n", []), | |
67 | - format(" preds:\n", []), PREDS=preds(PS), dump_list(PS), | |
68 | - format(" vars:\n", []), VARS=vars(VS), dump_list(VS), | |
69 | - format(" constrs:\n", []), CONSTRS=constrs(CS), dump_list(CS), | |
70 | - format(" goal:\n ~w\n", [SOLVE]). | |
71 | - | |
72 | -dump_ast(AST) :- write(AST), nl. | |
73 | - | |
74 | -% ----------------------------------------------------------------------------- | |
75 | - | |
76 | -dump_list([]). | |
77 | -dump_list([I|Is]) :- format(" ~w\n", [I]), dump_list(Is). | |
78 | - | |
79 | -% ----------------------------------------------------------------------------- |