aat

git mirror of https://ccx.te2000.cz/bzr/aat
git clone https://ccx.te2000.cz/git/aat
Log | Files | Refs | README

commit ddd812e2cd969630a91df67dd05344c0e910d06a
parent 02f55b81110d1dcf21acfefcb41136037227a363
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Sat, 28 Sep 2013 21:59:05 +0200

allow dot in variable names, allow empty lines and comments
Diffstat:
Mbin/aat_macros.sed | 1+
Mdata.awk | 13++++++++++---
2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/bin/aat_macros.sed b/bin/aat_macros.sed @@ -7,6 +7,7 @@ s/^[[:space:]]*ELSE[[:space:]]*$/} else {/ s/^[[:space:]]*ENDIF[[:space:]]*$/}/ s/^[[:space:]]*@for[[:space:]]\+\([[:alnum:]]\+\)[[:space:]]\+in[[:space:]]\+\(.\+\)$/for(_loop_\1=loop_start("\2", "\1."); loop_iter(_loop_\1);) {/ +s/^[[:space:]]*@for[[:space:]]\+\([[:alnum:]]\+\)[[:space:]]\+var[[:space:]]\+\(.\+\)$/for(_loop_\1=loop_start(\2, "\1."); loop_iter(_loop_\1);) {/ s/^[[:space:]]*@endfor[[:space:]]*$/} loop_end()/ s/^[[:space:]]*@if[[:space:]]\+\(.\+\)$/if(\1) {\n/ s/^[[:space:]]*@elif[[:space:]]\+\(.\+\)$/} else if(\1) {\n/ diff --git a/data.awk b/data.awk @@ -27,7 +27,7 @@ state == 1 { next } -/^[a-zA-Z_][a-zA-Z0-9_]*=\[$/ { +/^[a-zA-Z_][a-zA-Z0-9_.]*=\[$/ { # start of field list state = 1 m = match($0, ident_re) @@ -35,7 +35,7 @@ state == 1 { next } -/^[a-zA-Z_][a-zA-Z0-9_]*=/ { +/^[a-zA-Z_][a-zA-Z0-9_.]*=/ { m = match($0, ident_re) varname = substr($0, m, RLENGTH) V[varname] = substr($0, m+1+RLENGTH) @@ -48,9 +48,12 @@ state == 1 { next } +/^#/ { next } +/^$/ { next } + { # TODO posix compliance - print "unparseable line: " $0 >"/dev/stderr" + print "data.awk: unparseable line: '"$0"'" >"/dev/stderr" exit 1 } @@ -112,6 +115,10 @@ function get(varname, i, n, names, values, loopvar, looprow, prefix) { return V[varname] } +function or_(a, b) { + return a ? a : b +} + # for testing it out, set TEST=1 on commandline END { if(TEST) {