From 4d3eabb6098be217f7dee0015f708d9264b69243 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 14 Dec 2023 01:21:29 +0100 Subject: Lossened assumed requirements regarding format, added comments, newlines --- srcinfo.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'srcinfo.lua') diff --git a/srcinfo.lua b/srcinfo.lua index bc1900c..2612fd4 100644 --- a/srcinfo.lua +++ b/srcinfo.lua @@ -1,13 +1,14 @@ local lpeg = require "lpeg" local identifier = lpeg.R"az" + lpeg.R"09" + lpeg.S"@+_" identifier = identifier * (identifier + lpeg.S".-")^0 -local whitespace = lpeg.S" \t"^1 -local rest = (1 - lpeg.S"\n")^0 -local definition = lpeg.C(identifier) * whitespace * "=" * whitespace * lpeg.C(rest) * "\n" -local subdefinition = whitespace * definition -local emptylines = (whitespace * "\n")^1 -local block = lpeg.Ct(lpeg.Ct(definition) * lpeg.Ct(subdefinition)^0) -local thing = block * (emptylines * block)^0 +local whitespace = lpeg.S" \t"^0 +local newline = lpeg.P"\r\n" + "\n" +local rest = (1 - newline)^0 +local definition = whitespace * lpeg.C(identifier) * whitespace * "=" * whitespace * lpeg.C(rest) * newline +local emptylines = (whitespace * newline)^1 +local comment = lpeg.P"#" * rest * newline +local block = lpeg.Ct((lpeg.Ct(definition) + comment)^1) +local thing = emptylines^0 * block * (emptylines * block)^0 local capture = lpeg.Ct(thing) -- cgit v1.1