From 1f10fb42e84f3477935ad8fc972be6a2cc306df0 Mon Sep 17 00:00:00 2001 From: Salvador Abreu Date: Fri, 3 Jul 2015 19:14:14 +0900 Subject: [PATCH] decode action term from atom --- fzn-parser/fznslurp.pl | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/fzn-parser/fznslurp.pl b/fzn-parser/fznslurp.pl index 77c519c..4157f42 100644 --- a/fzn-parser/fznslurp.pl +++ b/fzn-parser/fznslurp.pl @@ -6,19 +6,22 @@ main :- argument_list(A), main(A). -main([ACTION|REST]) :- action(ACTION), !, main(REST). +main([ACTION_S|REST]) :- + read_term_from_atom(ACTION_S, ACTION, [end_of_term(eof)]), + action(ACTION), !, main(REST). main([]). -action(load) :- !, load_ast(AST), g_assign(ast, AST). -action(dump) :- !, g_read(ast, AST), dump_ast(AST). -action(name) :- !, - g_read(ast, AST), - sa_names(AST, NAST), - g_assign(ast, NAST). -action(halt) :- !, halt. -action(debug) :- g_read(ast_debug, true), !, g_assign(ast_debug, false). -action(debug) :- !, g_assign(ast_debug, true). -action(ACTION) :- format("%w: unknown action.\n", [ACTION]). +action(load(F)) :- !, see(F), action(load), seen. +action(load) :- !, load_ast(AST), g_assign(ast, AST). +action(dump) :- !, g_read(ast, AST), dump_ast(AST). +action(name) :- !, + g_read(ast, AST), + sa_names(AST, NAST), + g_assign(ast, NAST). +action(halt) :- !, halt. +action(debug) :- g_read(ast_debug, true), !, g_assign(ast_debug, false). +action(debug) :- !, g_assign(ast_debug, true). +action(ACTION) :- format("%w: unknown action.\n", [ACTION]). % ----------------------------------------------------------------------------- -- libgit2 0.21.2