=== modified file 'aattest' --- aattest 2015-09-10 11:06:23 +0000 +++ aattest 2015-09-09 16:23:54 +0000 @@ -19,7 +19,7 @@ awk -f test.qawk DEBUG=\$(DEBUG) test.data >test.out test.qawk: test.awk - $bin:h/query.pl test.awk >test.qawk + swipl -q -g main -s $bin:h/query.pl test.awk >test.qawk # test.qawk: test.awk # awk -f $bin/query.awk test.qawk === modified file 'query.pl' --- query.pl 2015-09-10 11:06:23 +0000 +++ query.pl 2015-09-10 07:58:55 +0000 @@ -1,12 +1,9 @@ -#!/usr/bin/env swipl +#!/usr/bin/swipl -q -g main -s % vim: ft=prolog textwidth=80 tabstop=4 softtabstop=4 shiftwidth=4 expandtab :- use_module(library(pure_input)). %%% :- use_module(library(dcg/basics)). -:- initialization main. -:- multifile prolog:message//1. - query_name([H|T]) --> [H], { code_type(H, csymf) }, query_name_next(T). @@ -154,33 +151,13 @@ %%% -parse_file(InFile) :- - ( phrase_from_file(query_awk(Awk), InFile) - -> true - ; throw(parsing_failed(InFile)) - ), - ( phrase(out_awk(Awk), Out) - -> true - ; throw(formatting_failed(InFile,Awk)) - ), +main([InFile]) :- !, + (phrase_from_file(query_awk(Awk), InFile) -> true ; throw(parsing_failed)), + (phrase(out_awk(Awk), Out) -> true ; throw(formatting_failed(Awk))), format('~s', [Out]). -main :- current_prolog_flag(argv, Argv), main(Argv). - -main(Args) :- - set_prolog_flag(verbose, false), - ( (Args=[] -> InFile='/dev/stdin' ; Args=[InFile]) - -> catch(parse_file(InFile), E, (print_message(error, E), halt(1))) - ; write('usage: query.pl: [filename]\n'), halt(2) - ), - halt. - +main([]) :- main(["/dev/stdin"]). % current_input(In), set_stream(In, tty(false)), % (phrase_from_stream(query_awk(Awk), In) -> true ; throw(parsing_failed)), % (phrase(out_awk(Awk), Out) -> true ; throw(formatting_failed(Awk))), % format('~s', [Out]). - -prolog:message(parsing_failed(File)) --> - ['Unable to parse AWK/query file: ~w'-[File]]. -prolog:message(formatting_failed(File,_)) --> - ['Failed generating AWK code from file: ~w'-[File]]. === modified file 'querytest' --- querytest 2015-09-10 11:06:23 +0000 +++ querytest 2015-09-09 16:23:54 +0000 @@ -6,4 +6,4 @@ cat >$dst/test.qawk || exit $? -exec $query $dst/test.qawk +exec swipl -q -g main -s $query $dst/test.qawk