parse_next
This commit is contained in:
parent
49f87fd992
commit
e63edb0c7b
1 changed files with 26 additions and 11 deletions
|
@ -121,7 +121,7 @@ RE_FUNC = RE_SPACES "\\(" RE_SPACES "\\)" RE_SPACES "{"
|
|||
|
||||
re["alias"] = 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_ANY "}" RE_SPACES RE_END
|
||||
re["command"] = RE_BEGIN "#/" RE_SPACES RE_VAR RE_END
|
||||
RE_COMMENT = RE_BEGIN RE_SPACES "#" RE_ANY RE_END
|
||||
re["constant"] = RE_BEGIN RE_CONST RE_SET RE_END
|
||||
|
@ -225,6 +225,30 @@ function parse(string) {
|
|||
|
||||
}
|
||||
|
||||
function parse_next(string) {
|
||||
|
||||
# constant
|
||||
if (current_match == "constant") {
|
||||
doc_reset()
|
||||
constant = ""
|
||||
|
||||
# variable
|
||||
if (current_match == "variable") {
|
||||
doc_reset()
|
||||
variable = ""
|
||||
|
||||
# function
|
||||
if (current_match == "close") {
|
||||
doc_reset()
|
||||
current_function = ""
|
||||
|
||||
# match
|
||||
}
|
||||
|
||||
# next
|
||||
line++
|
||||
}
|
||||
|
||||
# ╭──────┬──────╮
|
||||
# │ code │ main │
|
||||
# ╰──────┴──────╯
|
||||
|
@ -239,18 +263,12 @@ if (action == "doc") {
|
|||
if (current_match == "constant") {
|
||||
if (constant == target) {
|
||||
doc_output(constant, "constant")
|
||||
} else {
|
||||
doc_reset()
|
||||
constant = ""
|
||||
}
|
||||
|
||||
# variable
|
||||
} else if (current_match == "variable") {
|
||||
if (variable == target) {
|
||||
doc_output(variable, "variable")
|
||||
} else {
|
||||
doc_reset()
|
||||
variable = ""
|
||||
}
|
||||
|
||||
# match
|
||||
|
@ -266,9 +284,6 @@ if (action == "doc") {
|
|||
} else if (target in commands) {
|
||||
print "/ " target
|
||||
doc_output(current_function, "function")
|
||||
} else {
|
||||
current_function = ""
|
||||
doc_reset()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,7 +386,7 @@ if (action == "doc") {
|
|||
}
|
||||
|
||||
# main
|
||||
line++
|
||||
parse_next($0)
|
||||
}
|
||||
|
||||
# ╭──────┬─────╮
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue