Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
1 files changed, 26 insertions, 0 deletions
-rw-r--r--awk-edits/MEL-parser.awk26
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>)?&#38;[{[()\]}:.]/ {
# 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>)?&#38;[{[()\]}:.]/ {
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>)?&#38;[{[()\]}:.]/ {
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>)?&#38;[{[()\]}:.]/ {
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>)?&#38;[{[()\]}:.]/ {
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)