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"^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) local function srcinfo (handle) return capture:match(handle:read"a") end return srcinfo