=== modified file 'query.pl' --- query.pl 2015-09-03 13:53:24 +0000 +++ query.pl 2015-08-20 11:26:21 +0000 @@ -5,19 +5,16 @@ %%% :- use_module(library(dcg/basics)). query_name([H|T]) --> - [H], { code_type(H, csymf) }, + [H], + { code_type(H, csymf) }, query_name_next(T). query_name_next([H|T]) --> - [H], { H = 0'.; code_type(H, csym) }, - !, + [H], + { H = 0'.; code_type(H, csym) }, query_name_next(T). query_name_next([]) --> []. -query_default_text([H|T]) --> - [H], - {\+memberchk(H,`'<>`)}, - !, - query_default_text(T). +query_default_text([H|T]) --> [H], {\+memberchk(H,`'<>`)}, query_default_text(T). query_default_text([]) --> []. query_content([name(Name)|T]) --> query_name(Name), query_content(T). @@ -50,30 +47,21 @@ awk_string(String) --> `"`, awk_string_content(String), `"`. awk_string_content([0'\\,H|T],R) --> - [0'\\,H], - !, - awk_string_content(T,R). + [0'\\,H], !, awk_string_content(T,R). awk_string_content([H|T],R) --> - [H], { H\=0'\\, H\=0'" }, - !, - awk_string_content(T,R). + [H], { H \= 0'/ }, awk_string_content(T,R). awk_string_content(R,R) --> []. awk_string_content(L) --> awk_string_content(L,[]). awk_regex_content([0'\\,H|T],R) --> [0'\\,H], !, awk_regex_content(T,R). awk_regex_content([H|T],R) --> - [H], { H \= 0'" }, - !, - awk_regex_content(T,R). + [H], { H \= 0'" }, awk_regex_content(T,R). awk_regex_content(R,R) --> []. awk_regex_content(L) --> awk_regex_content(L,[]). awk_comment([0'\n|R],R) --> `\n`, !. -awk_comment([H|T],R) --> - [H], {assertion(H \= 0'\n)}, - !, - awk_comment(T,R). +awk_comment([H|T],R) --> [H], {assertion(H \= 0'\n)}, awk_comment(T,R). awk_comment(L) --> awk_comment(L,[]). awk_code([0'"|T0],R,_,F) --> @@ -92,10 +80,7 @@ % awk_code([0'<|T],R,Prev,F) --> % `<`, !, { Prev \= delim }, awk_code(T,R,op,F). awk_code([H|T],R,Prev,F) --> - [H], - { H \= 0'', H \= 0'@, (H \= 0'< ; Prev \= delim ) }, - !, - awk_code(T,R,expr,F). +[H], { H \= 0'', H \= 0'@, (H \= 0'< ; Prev \= delim ) }, awk_code(T,R,expr,F). awk_code(R,R,L,L) --> []. % awk_code(L) --> awk_code(L,[],delim,_). @@ -134,7 +119,7 @@ out_query_content([name(Name)|T]) --> `"`, Name, `"`, out_query_content(T). out_query_content([expr(Expr)|T]) --> `(`, out_awk(Expr), `)`, out_query_content(T). -out_query_content([query(Query, Filters, Default)|T]) --> +out_query_content([query(Query, Filters, Default)|T]) --> out_query(Query, Filters, Default), out_query_content(T). out_query_content([]) --> []. @@ -148,14 +133,9 @@ %%% - 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([]) :- 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]).