=== modified file 'bin/aat.awk' --- bin/aat.awk 2013-10-08 20:55:30 +0000 +++ bin/aat.awk 2013-10-08 18:28:24 +0000 @@ -203,56 +203,9 @@ } return "get("expanded")" } -function match_dbg(type, str) { - if(DEBUG) printf "<%s match: \"%s\">", type, \ - substr(str, RSTART, RLENGTH) >"/dev/stderr" -} function aat_process(str) { - processed = "" - while(str) { - if(match(str, /^[0-9]x?[0-9a-fA-F.]+(e[-+][0-9]+)?/)) { - # number literal - match_dbg("number", str) - processed = processed "("substr(str, 1, RLENGTH)")" - str = substr(str, RLENGTH+1) - } else if(match(str, /^[a-zA-Z_.<>'][a-zA-Z0-9_.<>']*/)) { - # a query - match_dbg("query", str) - expand_remaining=substr(str, 1, RLENGTH) - str = substr(str, RLENGTH+1) - processed = processed expand_query() - } else if(match(str, /^\|[a-zA-Z]/)) { - # filters ahead - match_dbg("filter", str) - break - } else if(match(str, /^"/)) { - # literal string - match_dbg("string", str) - match(str, /^"([^"\\]|\\[^"])*"/) - processed = processed substr(str, 1, RLENGTH) - str = substr(str, RLENGTH+1) - } else if(match(str, /^ /)) { - # spaces are passed verbatim - match_dbg("space", str) - processed = processed " " - str = substr(str, 2) - } else { - # anything else is passed verbatim up to space or quote - if(match(str, /[ "]/)) { - if(DEBUG) printf "<* match: \"%s\">", \ - substr(str, 1, RSTART-1) >"/dev/stderr" - processed = processed substr(str, 1, RSTART-1) - str = substr(str, RSTART) - } else { - if(DEBUG) printf "<* non-match: \"%s\">", \ - str >"/dev/stderr" - processed = processed str - str = "" - } - } - } - # TODO filters - return processed + expand_remaining = str + return expand_query() } { parse_line($0) }