=== modified file 'bin/aat.awk' --- bin/aat.awk 2013-10-08 18:28:24 +0000 +++ bin/aat.awk 2013-09-16 23:15:18 +0000 @@ -6,7 +6,6 @@ T_TEXT = 1; type_names[1] = "text" T_EXPR = 2; type_names[2] = "expr" T_AWK = 3; type_names[3] = "awk" - T_FUNC = 4; type_names[4] = "func" tok_type = T_TEXT } @@ -91,35 +90,19 @@ eat_nl = 0 if(tok_type == T_TEXT) { # all text until a start of expression "{{", or start of awk code "{%" - m = match(line, /\{[{%<]/) + m = match(line, /\{[{%]/) if(m) { token(substr(line, 1, m-1)) if (substr(line, m, RLENGTH) == "{{") tok_type = T_EXPR - else if (substr(line, m, RLENGTH) == "{%") + else tok_type = T_AWK - else if (substr(line, m, RLENGTH) == "{<") - tok_type = T_FUNC - else { print "internal error" >"/dev/stderr"; exit 1 } line = substr(line, m+RLENGTH) } else { # no delimiter found, whole line is text token(line) line = "" } - } else if(tok_type == T_FUNC) { - m = match(line, />}/) - if(m) { - if(DEBUG) printf "expr match: \"%s\"\n", substr(line, m, RLENGTH) >"/dev/stderr" - token(substr(line, 1, RSTART-1)) - tok_finished[tok_n] = 1 - line = substr(line, RSTART+RLENGTH) - tok_type = T_TEXT - } else { - # did not match whole expression because of end of line - token(line) - line = "" - } } else if(tok_type == T_EXPR || tok_type == T_AWK) { # match text inside awk code or expression # code stops on "%}" and expression on "}}" @@ -171,43 +154,6 @@ } } -# TODO make this pluggable -# called for expanding {< >} -function expand_query( expanded) { - expanded = "" - while(match(expand_remaining, "['<>]")) { - if(RSTART > 1) - expanded = expanded "\"" substr(expand_remaining, 1, RSTART-1) "\"" - char = substr(expand_remaining, RSTART, 1) - expand_remaining = substr(expand_remaining, RSTART+1) - if(char == ">") - return "get("expanded")" - else if(char == "<") { - expanded = expanded expand_query() - } else if(char == "'") { - if(match(expand_remaining, "'")) { - expanded = expanded substr(expand_remaining, 1, RSTART-1) - expand_remaining = substr(expand_remaining, RSTART+1) - } else { - expanded = expand_remaining - expand_remaining = "" - } - } else { - print "ERROR: internal error in expand_query()" >"/dev/stderr" - exit 1 - } - } - if(expand_remaining) { - expanded = "\"" expand_remaining "\"" - expand_remaining = "" - } - return "get("expanded")" -} -function aat_process(str) { - expand_remaining = str - return expand_query() -} - { parse_line($0) } END { @@ -231,9 +177,6 @@ nl = 1 } else if(tok_type == T_EXPR) { printf " (%s)", c - } else if(tok_type == T_FUNC) { - # TODO - printf " (%s)", aat_process(c) } else { print "ERROR: unknown tok_type: " tok_type >"/dev/stderr" exit 1