parse/module,shebang,other
This commit is contained in:
parent
a6b29e3c4b
commit
1c0a1b5b32
1 changed files with 24 additions and 17 deletions
|
@ -96,7 +96,6 @@ re["variable"] = RE_BEGIN RE_VAR RE_SET RE_END
|
||||||
f = ""
|
f = ""
|
||||||
match_alias = 0
|
match_alias = 0
|
||||||
match_command = 0
|
match_command = 0
|
||||||
match_module = 0
|
|
||||||
match_task = 0
|
match_task = 0
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
|
@ -105,19 +104,38 @@ reset()
|
||||||
|
|
||||||
# parse
|
# parse
|
||||||
function parse(string) {
|
function parse(string) {
|
||||||
|
# module
|
||||||
|
if (match(string, RE_MODULE)) {
|
||||||
|
current_match = "module"
|
||||||
|
module = string
|
||||||
|
sub("#\\.", "", module)
|
||||||
|
reset()
|
||||||
|
module = trim(module)
|
||||||
|
shebang = ""
|
||||||
|
# shebang
|
||||||
|
} else if (match(string, RE_SHEBANG)) {
|
||||||
|
current_match = "shebang"
|
||||||
|
shebang = string
|
||||||
|
sub("#!", "", shebang)
|
||||||
|
shebang = trim(shebang)
|
||||||
|
# other
|
||||||
|
} else {
|
||||||
|
if (module = target) {
|
||||||
|
output(target, "module")
|
||||||
|
} else {
|
||||||
|
reset()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# → main
|
# → main
|
||||||
{
|
{
|
||||||
|
|
||||||
# FIXME handle no action
|
|
||||||
|
|
||||||
# doc
|
# doc
|
||||||
if (action == "doc") {
|
if (action == "doc") {
|
||||||
|
parse($0)
|
||||||
# doc
|
# doc
|
||||||
if (match($0, RE_SHEBANG)) {
|
if (match($0, RE_DOC)) {
|
||||||
append("! " extract($0, "shebang"))
|
|
||||||
} else if (match($0, RE_DOC)) {
|
|
||||||
if (f) {
|
if (f) {
|
||||||
append($0)
|
append($0)
|
||||||
} else {
|
} else {
|
||||||
|
@ -151,11 +169,6 @@ if (action == "doc") {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
# others
|
# others
|
||||||
} else if (match($0, RE_MODULE)) {
|
|
||||||
reset()
|
|
||||||
if (extract($0, "module") == target) {
|
|
||||||
match_module = 1
|
|
||||||
}
|
|
||||||
} else if (match($0, re["function"])) {
|
} else if (match($0, re["function"])) {
|
||||||
f = extract($0, "function")
|
f = extract($0, "function")
|
||||||
} else if (match($0, RE_CLOSE)) {
|
} else if (match($0, RE_CLOSE)) {
|
||||||
|
@ -171,12 +184,6 @@ if (action == "doc") {
|
||||||
f = ""
|
f = ""
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (match_module) {
|
|
||||||
output(target, "module")
|
|
||||||
} else {
|
|
||||||
reset()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# tasks
|
# tasks
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue