X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/cd475ab947ddc0338bd54406234f9cbfa5abe2fd..8cda0a6cc9cc31edf0fe94c470038f12c8dcc905:/scripts/gen-tree.awk diff --git a/scripts/gen-tree.awk b/scripts/gen-tree.awk index d04378a..c461e5d 100755 --- a/scripts/gen-tree.awk +++ b/scripts/gen-tree.awk @@ -5,9 +5,11 @@ # Generate one or more C array initializers to encode simple tree structures # in a compact format. # -# Each nonempty line of the input file is either an option specification -# or # a tree specification. An option specification (described later) -# begins with an @ character. Other lines specify tree nodes. +# Each nonempty line of the input file is either a comment, an option +# specification or a tree specification. Each line is distinguished by +# its first character. A # character introduces a comment, an @ character +# introduces an option specification (described later), and all other +# nonempty lines are tree nodes. # # The first field of a tree specification must be a valid C identifier, # optionally followed by a comma. The identifiers used on non-leaf nodes @@ -102,6 +104,10 @@ BEGIN { indent_stack[0] = 0; } +# Comments +NF == 0 { next } +$0 ~ /^#/ { next } + # Options sub(/^@/, "", $0) { if (NF == 1) { @@ -118,7 +124,6 @@ sub(/^@/, "", $0) { next } -NF == 0 { next } { indent = index($0, $1) - 1 } indent > 0 {