aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-14 22:26:50 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-14 22:26:50 -0400
commit6b63cb402144af4838577cb4b227939d0d49a830 (patch)
tree40512e79adbe252e4891e9000e141f7a81c7aba7
parent1eb57393bbc14506c5d2f50acd16d070675ab56c (diff)
Better parsing and error printing (just show first messed up place)HEADmain
-rwxr-xr-xnowopen6
1 files changed, 3 insertions, 3 deletions
diff --git a/nowopen b/nowopen
index c6d7b2d..9100127 100755
--- a/nowopen
+++ b/nowopen
@@ -76,7 +76,7 @@ end
local re = require('re')
local dsl = re.compile([=[
- file <- {| (place / ws? comment? %nl)* |} {.+}?
+ file <- {| (place / ws? comment? %nl)* |} {[^%nl]+ (!(%nl %nl) .)*}? .*
place <- {|
{:name: {word (ws word)*} :}
ws? ("(" ws? {:tags: {| {tag} (ws? "," ws? {tag})* ws? |} :} ")")? ws? ":"
@@ -97,14 +97,14 @@ local dsl = re.compile([=[
/ ({:hour: {~"midnight"->'12'~} :} {:ampm: {~''->'am'~} :})
|}
tag <- word (ws word)*
- word <- [^%nl%tab (),:#-]+
+ word <- [^%nl%tab (),:#]+
ws <- [ %tab]+
]=], {tab="\t"})
local places,err = dsl:match(place_text)
if err then
print("Failed to parse config file:")
- print(place_text:sub(1,#place_text-#err).."\x1b[31;7m"..err.."\x1b[0m")
+ print("\x1b[31;7m"..err.."\x1b[0m")
os.exit(1)
end