parse/tasks
This commit is contained in:
parent
8caa6e6795
commit
7d8e9a03e2
1 changed files with 32 additions and 21 deletions
|
@ -76,11 +76,15 @@ function strip_from(string, sep, tmp) {
|
||||||
return strip(tmp[1])
|
return strip(tmp[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
function strip_function(string, tmp) {
|
function strip_function(string) {
|
||||||
return strip_from(string, "(")
|
return strip_from(string, "(")
|
||||||
}
|
}
|
||||||
|
|
||||||
function strip_value(string, tmp) {
|
function strip_task(string) {
|
||||||
|
return strip_from(strip_first(string, "#"), " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
function strip_value(string) {
|
||||||
return strip_from(string, "=")
|
return strip_from(string, "=")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,17 +108,15 @@ re["alias"] = RE_BEGIN "#=" RE_SPACES RE_VAR RE_END
|
||||||
re["binary"] = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END
|
re["binary"] = RE_BEGIN "#\\|" RE_SPACES RE_VAR RE_END
|
||||||
RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END
|
RE_CLOSE = RE_BEGIN "}" RE_SPACES RE_END
|
||||||
re["command"] = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END
|
re["command"] = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END
|
||||||
RE_COMMENT = RE_BEGIN "#" RE_ANY RE_END
|
RE_COMMENT = RE_BEGIN RE_SPACES "# " RE_ANY RE_END
|
||||||
re["constant"] = RE_BEGIN RE_CONST RE_SET RE_END
|
re["constant"] = RE_BEGIN RE_CONST RE_SET RE_END
|
||||||
RE_DOC = RE_BEGIN RE_SPACES "#" RE_SPACE RE_ANY RE_END
|
RE_DOC = RE_BEGIN "# " RE_ANY RE_END
|
||||||
re["function"] = RE_BEGIN RE_VAR RE_FUNC RE_END
|
re["function"] = RE_BEGIN RE_VAR RE_FUNC RE_END
|
||||||
RE_MODULE = RE_BEGIN "#\\." RE_SPACES RE_ANY RE_END
|
RE_MODULE = RE_BEGIN "#\\." RE_SPACES RE_ANY RE_END
|
||||||
RE_SHEBANG = RE_BEGIN "#!" RE_SPACES RE_ANY RE_END
|
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
|
||||||
|
|
||||||
match_task = 0
|
|
||||||
|
|
||||||
# ← begin
|
# ← begin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,13 +165,20 @@ function parse(string) {
|
||||||
current_match = "function"
|
current_match = "function"
|
||||||
current_function = strip_function(string)
|
current_function = strip_function(string)
|
||||||
|
|
||||||
|
# task
|
||||||
|
} else if (match(string, RE_TASK)) {
|
||||||
|
current_match = "task"
|
||||||
|
task = strip_task(string)
|
||||||
|
tasks[task] = ""
|
||||||
|
doc_append(line ": " string)
|
||||||
|
|
||||||
# doc
|
# doc
|
||||||
} else if (match(string, RE_DOC)) {
|
} else if (match(string, RE_DOC)) {
|
||||||
if (current_function) {
|
doc_append(strip_first(string, "# "))
|
||||||
doc_append(string)
|
|
||||||
} else {
|
# comment
|
||||||
doc_append(strip_first(string, "# "))
|
} else if (match(string, RE_COMMENT)) {
|
||||||
}
|
doc_append(string)
|
||||||
|
|
||||||
# other
|
# other
|
||||||
} else {
|
} else {
|
||||||
|
@ -232,35 +241,37 @@ if (action == "doc") {
|
||||||
|
|
||||||
# tasks
|
# tasks
|
||||||
} else if (action == "tasks") {
|
} else if (action == "tasks") {
|
||||||
line++
|
parse($0)
|
||||||
if (match($0, RE_MODULE)) {
|
|
||||||
line = 1
|
# module
|
||||||
|
if (current_match == "module") {
|
||||||
if (output_tasks) {
|
if (output_tasks) {
|
||||||
print ""
|
print ""
|
||||||
print output_module
|
print ". " module
|
||||||
print output_tasks
|
print output_tasks
|
||||||
output_tasks = ""
|
output_tasks = ""
|
||||||
}
|
}
|
||||||
doc = ""
|
doc = ""
|
||||||
match_task = 0
|
match_task = 0
|
||||||
output_module = ". " extract($0, "module")
|
|
||||||
} else if (match($0, RE_TASK)) {
|
# task
|
||||||
|
} else if (current_match == "task") {
|
||||||
if (target) {
|
if (target) {
|
||||||
if (target == extract($0, "task")) {
|
if (target in tasks) {
|
||||||
match_task = 1
|
match_task = 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match_task = 1
|
match_task = 1
|
||||||
}
|
}
|
||||||
doc_append(line ": " $0)
|
|
||||||
} else if (match($0, RE_COMMENT)) {
|
# other
|
||||||
doc_append(line ": " $0)
|
|
||||||
} else {
|
} else {
|
||||||
if (match_task) {
|
if (match_task) {
|
||||||
output_tasks = output_tasks "\n" doc
|
output_tasks = output_tasks "\n" doc
|
||||||
}
|
}
|
||||||
doc = ""
|
doc = ""
|
||||||
match_task = 0
|
match_task = 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# function
|
# function
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue