parent
03d8b5f1e4
commit
bd4191513b
1 changed files with 57 additions and 31 deletions
|
@ -1,6 +1,10 @@
|
|||
# code
|
||||
# ╭──────╮
|
||||
# │ code │
|
||||
# ╰──────╯
|
||||
|
||||
# functions
|
||||
# ╭──────┬───────────╮
|
||||
# │ code │ functions │
|
||||
# ╰──────┴───────────╯
|
||||
|
||||
function alias_eval(new, name, type) {
|
||||
text = new "() { "
|
||||
|
@ -12,26 +16,6 @@ function alias_eval(new, name, type) {
|
|||
print text "; }"
|
||||
}
|
||||
|
||||
function doc_append(string) {
|
||||
if (doc) {
|
||||
doc = doc "\n"
|
||||
}
|
||||
doc = doc string
|
||||
}
|
||||
|
||||
function doc_output(name, type) {
|
||||
print "↙ " type
|
||||
print name
|
||||
print doc
|
||||
exit
|
||||
}
|
||||
|
||||
function doc_reset() {
|
||||
if (current_function == "") {
|
||||
doc = ""
|
||||
}
|
||||
}
|
||||
|
||||
# TODO delete when useless
|
||||
function extract(string, type) {
|
||||
if (type == "alias") {
|
||||
|
@ -58,6 +42,34 @@ function extract(string, type) {
|
|||
}
|
||||
}
|
||||
|
||||
# ╭──────┬───────────┬─────╮
|
||||
# │ code │ functions │ doc │
|
||||
# ╰──────┴───────────┴─────╯
|
||||
|
||||
function doc_append(string) {
|
||||
if (doc) {
|
||||
doc = doc "\n"
|
||||
}
|
||||
doc = doc string
|
||||
}
|
||||
|
||||
function doc_output(name, type) {
|
||||
print "↙ " type
|
||||
print name
|
||||
print doc
|
||||
exit
|
||||
}
|
||||
|
||||
function doc_reset() {
|
||||
if (current_function == "") {
|
||||
doc = ""
|
||||
}
|
||||
}
|
||||
|
||||
# ╭──────┬───────────┬───────╮
|
||||
# │ code │ functions │ strip │
|
||||
# ╰──────┴───────────┴───────╯
|
||||
|
||||
function strip(string, tmp) {
|
||||
tmp = string
|
||||
sub("^[\t ]*", "", tmp)
|
||||
|
@ -88,7 +100,10 @@ function strip_value(string) {
|
|||
return strip_from(string, "=")
|
||||
}
|
||||
|
||||
# → begin
|
||||
# ╭──────┬───────╮
|
||||
# │ code │ begin │
|
||||
# ╰──────┴───────╯
|
||||
|
||||
BEGIN {
|
||||
|
||||
RE_ANY = "(.*)"
|
||||
|
@ -117,10 +132,12 @@ RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END
|
|||
RE_TASK = RE_BEGIN RE_SPACES "#" RE_SPACES RE_TSK RE_ANY RE_END
|
||||
re["variable"] = RE_BEGIN RE_VAR RE_SET RE_END
|
||||
|
||||
# ← begin
|
||||
}
|
||||
|
||||
# parse
|
||||
# ╭──────┬───────╮
|
||||
# │ code │ parse │
|
||||
# ╰──────┴───────╯
|
||||
|
||||
function parse(string) {
|
||||
|
||||
# module
|
||||
|
@ -190,13 +207,17 @@ function parse(string) {
|
|||
|
||||
}
|
||||
|
||||
# close
|
||||
if (match(string, RE_CLOSE)) {
|
||||
current_match = "close"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# → main
|
||||
# ╭──────┬──────╮
|
||||
# │ code │ main │
|
||||
# ╰──────┴──────╯
|
||||
|
||||
{
|
||||
|
||||
# doc
|
||||
|
@ -221,6 +242,7 @@ if (action == "doc") {
|
|||
variable = ""
|
||||
}
|
||||
|
||||
# match
|
||||
}
|
||||
|
||||
# function
|
||||
|
@ -272,6 +294,7 @@ if (action == "doc") {
|
|||
doc = ""
|
||||
match_task = 0
|
||||
|
||||
# match
|
||||
}
|
||||
|
||||
# function
|
||||
|
@ -316,14 +339,17 @@ if (action == "doc") {
|
|||
print "unknown action: " action
|
||||
exit 1
|
||||
|
||||
# ← action
|
||||
# action
|
||||
}
|
||||
|
||||
# ← main
|
||||
# main
|
||||
line++
|
||||
}
|
||||
|
||||
# → end
|
||||
# ╭──────┬─────╮
|
||||
# │ code │ end │
|
||||
# ╰──────┴─────╯
|
||||
|
||||
END {
|
||||
|
||||
# filter
|
||||
|
@ -332,8 +358,8 @@ if (action == "filter") {
|
|||
print item
|
||||
}
|
||||
|
||||
# ← end / action
|
||||
# action
|
||||
}
|
||||
|
||||
# ← end
|
||||
# end
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue