remove_first
This commit is contained in:
parent
fc19ff4cbe
commit
1e1a2f1c6e
1 changed files with 10 additions and 12 deletions
|
@ -58,6 +58,12 @@ function extract(string, type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove_first(string, target, tmp) {
|
||||||
|
tmp = string
|
||||||
|
sub(target, "", tmp)
|
||||||
|
return trim(tmp)
|
||||||
|
}
|
||||||
|
|
||||||
function trim(string) {
|
function trim(string) {
|
||||||
text = string
|
text = string
|
||||||
sub("^[\t ]*", "", text)
|
sub("^[\t ]*", "", text)
|
||||||
|
@ -106,34 +112,26 @@ function parse(string) {
|
||||||
# module
|
# module
|
||||||
if (match(string, RE_MODULE)) {
|
if (match(string, RE_MODULE)) {
|
||||||
current_match = "module"
|
current_match = "module"
|
||||||
module = string
|
module = remove_first(string, "#\\.")
|
||||||
sub("#\\.", "", module)
|
|
||||||
doc_reset()
|
doc_reset()
|
||||||
module = trim(module)
|
|
||||||
shebang = ""
|
shebang = ""
|
||||||
|
|
||||||
# shebang
|
# shebang
|
||||||
} else if (match(string, RE_SHEBANG)) {
|
} else if (match(string, RE_SHEBANG)) {
|
||||||
current_match = "shebang"
|
current_match = "shebang"
|
||||||
shebang = string
|
shebang = remove_first(string, "#!")
|
||||||
sub("#!", "", shebang)
|
|
||||||
shebang = trim(shebang)
|
|
||||||
|
|
||||||
# alias
|
# alias
|
||||||
} else if (match(string, re["alias"])) {
|
} else if (match(string, re["alias"])) {
|
||||||
current_match = "alias"
|
current_match = "alias"
|
||||||
alias = string
|
alias = remove_first(string, "#=")
|
||||||
sub("#=", "", alias)
|
|
||||||
alias = trim(alias)
|
|
||||||
aliases[alias] = ""
|
aliases[alias] = ""
|
||||||
doc_append("= " alias)
|
doc_append("= " alias)
|
||||||
|
|
||||||
# command
|
# command
|
||||||
} else if (match(string, re["command"])) {
|
} else if (match(string, re["command"])) {
|
||||||
current_match = "command"
|
current_match = "command"
|
||||||
command = string
|
command = remove_first(string, "#/")
|
||||||
sub("#/", "", command)
|
|
||||||
command = trim(command)
|
|
||||||
commands[command] = ""
|
commands[command] = ""
|
||||||
doc_append("/ " command)
|
doc_append("/ " command)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue