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 = ""
|
||||
match_alias = 0
|
||||
match_command = 0
|
||||
match_module = 0
|
||||
match_task = 0
|
||||
reset()
|
||||
|
||||
|
@ -105,19 +104,38 @@ reset()
|
|||
|
||||
# parse
|
||||
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
|
||||
{
|
||||
|
||||
# FIXME handle no action
|
||||
|
||||
# doc
|
||||
if (action == "doc") {
|
||||
parse($0)
|
||||
# doc
|
||||
if (match($0, RE_SHEBANG)) {
|
||||
append("! " extract($0, "shebang"))
|
||||
} else if (match($0, RE_DOC)) {
|
||||
if (match($0, RE_DOC)) {
|
||||
if (f) {
|
||||
append($0)
|
||||
} else {
|
||||
|
@ -151,11 +169,6 @@ if (action == "doc") {
|
|||
reset()
|
||||
}
|
||||
# others
|
||||
} else if (match($0, RE_MODULE)) {
|
||||
reset()
|
||||
if (extract($0, "module") == target) {
|
||||
match_module = 1
|
||||
}
|
||||
} else if (match($0, re["function"])) {
|
||||
f = extract($0, "function")
|
||||
} else if (match($0, RE_CLOSE)) {
|
||||
|
@ -171,12 +184,6 @@ if (action == "doc") {
|
|||
f = ""
|
||||
reset()
|
||||
}
|
||||
} else {
|
||||
if (match_module) {
|
||||
output(target, "module")
|
||||
} else {
|
||||
reset()
|
||||
}
|
||||
}
|
||||
|
||||
# tasks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue