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) {
|
function alias_eval(new, name, type) {
|
||||||
text = new "() { "
|
text = new "() { "
|
||||||
|
@ -12,26 +16,6 @@ function alias_eval(new, name, type) {
|
||||||
print text "; }"
|
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
|
# TODO delete when useless
|
||||||
function extract(string, type) {
|
function extract(string, type) {
|
||||||
if (type == "alias") {
|
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) {
|
function strip(string, tmp) {
|
||||||
tmp = string
|
tmp = string
|
||||||
sub("^[\t ]*", "", tmp)
|
sub("^[\t ]*", "", tmp)
|
||||||
|
@ -88,7 +100,10 @@ function strip_value(string) {
|
||||||
return strip_from(string, "=")
|
return strip_from(string, "=")
|
||||||
}
|
}
|
||||||
|
|
||||||
# → begin
|
# ╭──────┬───────╮
|
||||||
|
# │ code │ begin │
|
||||||
|
# ╰──────┴───────╯
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|
||||||
RE_ANY = "(.*)"
|
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_TASK = RE_BEGIN RE_SPACES "#" RE_SPACES RE_TSK RE_ANY RE_END
|
||||||
re["variable"] = RE_BEGIN RE_VAR RE_SET RE_END
|
re["variable"] = RE_BEGIN RE_VAR RE_SET RE_END
|
||||||
|
|
||||||
# ← begin
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# parse
|
# ╭──────┬───────╮
|
||||||
|
# │ code │ parse │
|
||||||
|
# ╰──────┴───────╯
|
||||||
|
|
||||||
function parse(string) {
|
function parse(string) {
|
||||||
|
|
||||||
# module
|
# module
|
||||||
|
@ -190,13 +207,17 @@ function parse(string) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# close
|
||||||
if (match(string, RE_CLOSE)) {
|
if (match(string, RE_CLOSE)) {
|
||||||
current_match = "close"
|
current_match = "close"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# → main
|
# ╭──────┬──────╮
|
||||||
|
# │ code │ main │
|
||||||
|
# ╰──────┴──────╯
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
# doc
|
# doc
|
||||||
|
@ -221,6 +242,7 @@ if (action == "doc") {
|
||||||
variable = ""
|
variable = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# match
|
||||||
}
|
}
|
||||||
|
|
||||||
# function
|
# function
|
||||||
|
@ -272,6 +294,7 @@ if (action == "doc") {
|
||||||
doc = ""
|
doc = ""
|
||||||
match_task = 0
|
match_task = 0
|
||||||
|
|
||||||
|
# match
|
||||||
}
|
}
|
||||||
|
|
||||||
# function
|
# function
|
||||||
|
@ -316,14 +339,17 @@ if (action == "doc") {
|
||||||
print "unknown action: " action
|
print "unknown action: " action
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
# ← action
|
# action
|
||||||
}
|
}
|
||||||
|
|
||||||
# ← main
|
# main
|
||||||
line++
|
line++
|
||||||
}
|
}
|
||||||
|
|
||||||
# → end
|
# ╭──────┬─────╮
|
||||||
|
# │ code │ end │
|
||||||
|
# ╰──────┴─────╯
|
||||||
|
|
||||||
END {
|
END {
|
||||||
|
|
||||||
# filter
|
# filter
|
||||||
|
@ -332,8 +358,8 @@ if (action == "filter") {
|
||||||
print item
|
print item
|
||||||
}
|
}
|
||||||
|
|
||||||
# ← end / action
|
# action
|
||||||
}
|
}
|
||||||
|
|
||||||
# ← end
|
# end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue