diff options
| Commit | 6d437b04c4517783e682e2309cc9e0056883c488 (patch) | |
|---|---|---|
| Author | 2024-02-25 15:48:19 +0200 | |
| Committer | 2024-02-25 15:48:19 +0200 | |
| Files | 36c5755c16a9515e3ea8780cbdf5205fa73387fe | |
| syndamia.com-6d437b04c4517783e682e2309cc9e0056883c488.tar syndamia.com-6d437b04c4517783e682e2309cc9e0056883c488.tar.gz syndamia.com-6d437b04c4517783e682e2309cc9e0056883c488.zip | ||
| Parent | 71ecd6d8d554ff23f0161b1c0e447bede9d41377 (diff) | |
(awk-edits/MEL) Added error messages
1 files changed, 26 insertions, 0 deletions
| -rw-r--r-- | awk-edits/MEL-parser.awk | 26 |
diff --git a/awk-edits/MEL-parser.awk b/awk-edits/MEL-parser.awk index 6cf0514..af1e26d 100644 --- a/awk-edits/MEL-parser.awk +++ b/awk-edits/MEL-parser.awk @@ -42,6 +42,11 @@ function usesMEL() { MELLINE = "l" } +function printErr(message) { + print "ERROR by MEL-parser.awk: " message " | Found in " FILENAME " at line " FNR " & column " RSTART + length(newLine) - 5 ":\n" $0 > "/dev/stderr" + print > "/dev/stderr" +} + /<code>/ { melInsideCode = 1 } @@ -62,6 +67,10 @@ melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&[{[()\]}:.]/ { # Inside closing tag if (RLENGTH == 1) { replaceWith = MEL[topStack("mel"), MELCLOSE] + + if (replaceWith == "") + printErr("Missing closing tag for \"" topStack("mel") "\"") + popStack("mel") } # Inside insert @@ -69,6 +78,9 @@ melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&[{[()\]}:.]/ { name = substr(lineCopy, RSTART + 1, RLENGTH - 1) replaceWith = MEL[name, MELINSERT] + + if (replaceWith == "") + printErr("Unknown insertion tag \"" name "\"") } # Inside one line else if (substr(lineCopy, RSTART, 2) == "::") { @@ -76,6 +88,14 @@ melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&[{[()\]}:.]/ { replaceWith = MEL[name, MELLINEOPEN] append = append MEL[name, MELLINECLOSE] + + + if (replaceWith == "" && append == "") + printErr("Unknown single line tag \"" name "\"") + else if (replaceWith == "") + printErr("Missing beginning for line tag \"" name "\"") + else + printErr("Missing ending for line tag \"" name "\"") } # Inside paragraph else if (substr(lineCopy, RSTART, 1) == ":") { @@ -85,6 +105,9 @@ melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&[{[()\]}:.]/ { RSTART -= 1 RLENGTH += 1 paragraphed = 1 + + if (replaceWith == "") + printErr("Unknown paragraph tag \"" name "\"") } # Inside opening tag else { @@ -92,6 +115,9 @@ melInsideCode == 0 && /^[ \t]*(<p>|<dt>)?&[{[()\]}:.]/ { replaceWith = MEL[name, MELOPEN] pushStack("mel", name) + + if (replaceWith == "") + printErr("Unknown opening tag \"" name "\"") } newLine = newLine substr(lineCopy, 0, RSTART - 6) replaceWith lineCopy = substr(lineCopy, RSTART + RLENGTH) |