parse/alias,command

This commit is contained in:
Marc Beninca 2025-08-02 17:15:23 +02:00
parent 20b5b095b2
commit fc19ff4cbe
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -94,8 +94,6 @@ RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END
RE_TASK = RE_BEGIN RE_SPACES "#" RE_SPACES RE_TSK RE_ANY RE_END
re["variable"] = RE_BEGIN RE_VAR RE_SET RE_END
match_alias = 0
match_command = 0
match_task = 0
doc_reset()
@ -121,6 +119,24 @@ function parse(string) {
sub("#!", "", shebang)
shebang = trim(shebang)
# alias
} else if (match(string, re["alias"])) {
current_match = "alias"
alias = string
sub("#=", "", alias)
alias = trim(alias)
aliases[alias] = ""
doc_append("= " alias)
# command
} else if (match(string, re["command"])) {
current_match = "command"
command = string
sub("#/", "", command)
command = trim(command)
commands[command] = ""
doc_append("/ " command)
# other
} else {
if (module == target) {
@ -145,18 +161,6 @@ if (action == "doc") {
} else {
doc_append(extract($0, "doc"))
}
} else if (match($0, re["alias"])) {
matched = extract($0, "alias")
doc_append("= " matched)
if (matched == target) {
match_alias = 1
}
} else if (match($0, re["command"])) {
matched = extract($0, "command")
doc_append("/ " matched)
if (matched == target) {
match_command = 1
}
# set
} else if (match($0, re["constant"])) {
matched = extract($0, "constant")