Compare commits
2 commits
101fd21ce1
...
aeff5a62f2
Author | SHA1 | Date | |
---|---|---|---|
aeff5a62f2 | |||
1c39fb31a1 |
1 changed files with 10 additions and 15 deletions
25
sh/main.awk
25
sh/main.awk
|
@ -5,8 +5,8 @@ function append(line) {
|
|||
doc = doc line
|
||||
}
|
||||
|
||||
function output(name) {
|
||||
print name
|
||||
function output(name, type) {
|
||||
print name " ← " type
|
||||
print doc
|
||||
exit
|
||||
}
|
||||
|
@ -57,26 +57,24 @@ BEGIN {
|
|||
} else if (action == "doc") {
|
||||
# doc
|
||||
if (match($0, RE_SHEBANG, m)) {
|
||||
append("shebang: " m[1])
|
||||
append("! " m[1])
|
||||
} else if (match($0, RE_DOC, m)) {
|
||||
append(m[1])
|
||||
} else if (match($0, RE_ALIAS, m)) {
|
||||
append("alias: " m[1])
|
||||
append("= " m[1])
|
||||
if (m[1] == target) {
|
||||
alias = 1
|
||||
}
|
||||
# set
|
||||
} else if (match($0, RE_CONSTANT, m)) {
|
||||
if (m[1] == target) {
|
||||
printf "constant: "
|
||||
output(m[1])
|
||||
output(m[1], "constant")
|
||||
} else {
|
||||
reset()
|
||||
}
|
||||
} else if (match($0, RE_VARIABLE, m)) {
|
||||
if (m[1] == target) {
|
||||
printf "variable: "
|
||||
output(m[1])
|
||||
output(m[1], "variable")
|
||||
} else {
|
||||
reset()
|
||||
}
|
||||
|
@ -88,19 +86,16 @@ BEGIN {
|
|||
}
|
||||
} else if (match($0, RE_FUNCTION, m)) {
|
||||
if (alias) {
|
||||
print "alias: " target
|
||||
printf "function: "
|
||||
output(m[1])
|
||||
print "= " target
|
||||
output(m[1], "function")
|
||||
} else if (m[1] == target) {
|
||||
printf "function: "
|
||||
output(target)
|
||||
output(target, "function")
|
||||
} else {
|
||||
reset()
|
||||
}
|
||||
} else {
|
||||
if (module) {
|
||||
printf "module: "
|
||||
output(target)
|
||||
output(target, "module")
|
||||
} else {
|
||||
reset()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue