summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--srcinfo.lua15
1 files changed, 8 insertions, 7 deletions
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)