awk/actions,comments

This commit is contained in:
Marc Beninca 2025-08-02 10:45:32 +02:00
parent 037c64674e
commit 845065a374
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -64,8 +64,7 @@ function trim(string) {
return text return text
} }
# begin # → begin
BEGIN { BEGIN {
RE_ANY = "(.*)" RE_ANY = "(.*)"
@ -101,23 +100,20 @@ match_module = 0
match_task = 0 match_task = 0
reset() reset()
# ← begin
} }
# parse # parse
function parse(string) { function parse(string) {
} }
# main # → main
{ {
if (action == "filter") { # FIXME handle no action
if (match($0, re[target])) {
unique[extract($0, target)] = ""
}
} else if (action == "tasks") { # tasks
if (action == "tasks") {
line++ line++
if (match($0, RE_MODULE)) { if (match($0, RE_MODULE)) {
line = 1 line = 1
@ -149,6 +145,7 @@ if (action == "filter") {
match_task = 0 match_task = 0
} }
# eval
} else if (action == "eval") { } else if (action == "eval") {
if (match($0, re[target])) { if (match($0, re[target])) {
append(extract($0, target)) append(extract($0, target))
@ -162,6 +159,7 @@ if (action == "filter") {
reset() reset()
} }
# function
} else if (action == "function") { } else if (action == "function") {
if (match($0, re["command"])) { if (match($0, re["command"])) {
append(extract($0, "command")) append(extract($0, "command"))
@ -178,6 +176,7 @@ if (action == "filter") {
reset() reset()
} }
# doc
} else if (action == "doc") { } else if (action == "doc") {
# doc # doc
if (match($0, RE_SHEBANG)) { if (match($0, RE_SHEBANG)) {
@ -243,18 +242,30 @@ if (action == "filter") {
reset() reset()
} }
} }
# filter
} else if (action == "filter") {
if (match($0, re[target])) {
unique[extract($0, target)] = ""
}
# ← action
} }
# ← main
} }
# end # → end
END { END {
# filter
if (action == "filter") { if (action == "filter") {
for (item in unique) { for (item in unique) {
print item print item
} }
# ← end / action
} }
# ← end
} }