Commit 1f10fb42e84f3477935ad8fc972be6a2cc306df0
1 parent
38932fea
Exists in
master
decode action term from atom
new action load(FILE)
Showing
1 changed file
with
14 additions
and
11 deletions
Show diff stats
fzn-parser/fznslurp.pl
... | ... | @@ -6,19 +6,22 @@ main :- |
6 | 6 | argument_list(A), |
7 | 7 | main(A). |
8 | 8 | |
9 | -main([ACTION|REST]) :- action(ACTION), !, main(REST). | |
9 | +main([ACTION_S|REST]) :- | |
10 | + read_term_from_atom(ACTION_S, ACTION, [end_of_term(eof)]), | |
11 | + action(ACTION), !, main(REST). | |
10 | 12 | main([]). |
11 | 13 | |
12 | -action(load) :- !, load_ast(AST), g_assign(ast, AST). | |
13 | -action(dump) :- !, g_read(ast, AST), dump_ast(AST). | |
14 | -action(name) :- !, | |
15 | - g_read(ast, AST), | |
16 | - sa_names(AST, NAST), | |
17 | - g_assign(ast, NAST). | |
18 | -action(halt) :- !, halt. | |
19 | -action(debug) :- g_read(ast_debug, true), !, g_assign(ast_debug, false). | |
20 | -action(debug) :- !, g_assign(ast_debug, true). | |
21 | -action(ACTION) :- format("%w: unknown action.\n", [ACTION]). | |
14 | +action(load(F)) :- !, see(F), action(load), seen. | |
15 | +action(load) :- !, load_ast(AST), g_assign(ast, AST). | |
16 | +action(dump) :- !, g_read(ast, AST), dump_ast(AST). | |
17 | +action(name) :- !, | |
18 | + g_read(ast, AST), | |
19 | + sa_names(AST, NAST), | |
20 | + g_assign(ast, NAST). | |
21 | +action(halt) :- !, halt. | |
22 | +action(debug) :- g_read(ast_debug, true), !, g_assign(ast_debug, false). | |
23 | +action(debug) :- !, g_assign(ast_debug, true). | |
24 | +action(ACTION) :- format("%w: unknown action.\n", [ACTION]). | |
22 | 25 | |
23 | 26 | |
24 | 27 | % ----------------------------------------------------------------------------- | ... | ... |