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
|
doc = doc line
|
||||||
}
|
}
|
||||||
|
|
||||||
function output(name) {
|
function output(name, type) {
|
||||||
print name
|
print name " ← " type
|
||||||
print doc
|
print doc
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
@ -57,26 +57,24 @@ BEGIN {
|
||||||
} else if (action == "doc") {
|
} else if (action == "doc") {
|
||||||
# doc
|
# doc
|
||||||
if (match($0, RE_SHEBANG, m)) {
|
if (match($0, RE_SHEBANG, m)) {
|
||||||
append("shebang: " m[1])
|
append("! " m[1])
|
||||||
} else if (match($0, RE_DOC, m)) {
|
} else if (match($0, RE_DOC, m)) {
|
||||||
append(m[1])
|
append(m[1])
|
||||||
} else if (match($0, RE_ALIAS, m)) {
|
} else if (match($0, RE_ALIAS, m)) {
|
||||||
append("alias: " m[1])
|
append("= " m[1])
|
||||||
if (m[1] == target) {
|
if (m[1] == target) {
|
||||||
alias = 1
|
alias = 1
|
||||||
}
|
}
|
||||||
# set
|
# set
|
||||||
} else if (match($0, RE_CONSTANT, m)) {
|
} else if (match($0, RE_CONSTANT, m)) {
|
||||||
if (m[1] == target) {
|
if (m[1] == target) {
|
||||||
printf "constant: "
|
output(m[1], "constant")
|
||||||
output(m[1])
|
|
||||||
} else {
|
} else {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
} else if (match($0, RE_VARIABLE, m)) {
|
} else if (match($0, RE_VARIABLE, m)) {
|
||||||
if (m[1] == target) {
|
if (m[1] == target) {
|
||||||
printf "variable: "
|
output(m[1], "variable")
|
||||||
output(m[1])
|
|
||||||
} else {
|
} else {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
|
@ -88,19 +86,16 @@ BEGIN {
|
||||||
}
|
}
|
||||||
} else if (match($0, RE_FUNCTION, m)) {
|
} else if (match($0, RE_FUNCTION, m)) {
|
||||||
if (alias) {
|
if (alias) {
|
||||||
print "alias: " target
|
print "= " target
|
||||||
printf "function: "
|
output(m[1], "function")
|
||||||
output(m[1])
|
|
||||||
} else if (m[1] == target) {
|
} else if (m[1] == target) {
|
||||||
printf "function: "
|
output(target, "function")
|
||||||
output(target)
|
|
||||||
} else {
|
} else {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (module) {
|
if (module) {
|
||||||
printf "module: "
|
output(target, "module")
|
||||||
output(target)
|
|
||||||
} else {
|
} else {
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue