#!/usr/bin/env lua -- __ _ _ -- __ _____ / _| __ _| | ___ __| | -- \ \ / / _ \ |_ / _` | |/ _ \ / _` | -- \ V / __/ _| (_| | | (_) | (_| | -- \_/ \___|_| \__,_|_|\___/ \__,_| -- -- Copyright (C) 2026, the mro.name/vefalod contributors. -- License: CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/ -- local function w(s) io.stdout:write(s) end local lpeg = require 'lpeg' local P, R, C, Cc = lpeg.P, lpeg.R, lpeg.C, lpeg.Cc local lf = P '\n' local ws = P ' ' + lf local digit1 = R '09' local digit2 = digit1 * digit1 local digit4 = digit2 * digit2 local date = P 'Sitzungsdatum:' * ws ^ 1 * (1 - P ',') ^ 5 * P ',' * ws ^ 0 * (C(digit2) * '.' * C(digit2) * '.' * C(digit4)) / function(d, m, y) return table.concat({ y, m, d }, '-') end local time = C(digit2 * ':' * digit2) / function(t) return t .. ':00' end local dtstart = P 'Beginn:' * ws ^ 1 * time * ws ^ 0 * P 'Uhr' ^ -1 local dtend = P 'Ende' * ws ^ 1 * time * ws ^ 0 * P 'Uhr' ^ -1 local location = P 'Ort:' * ws ^ 1 * (C((1 - lf) ^ 1) * lf * ws ^ 0 * C((1 - lf) ^ 1)) / function(a, b) return table.concat({ a, b }, ', ') end local head = ws ^ 0 * (P 'NIEDERSCHRIFT ÜBER DIE' / print) * ws ^ 0 * (P 'SITZUNG DES STADTRATES' / print) * ws ^ 0 * (date / print) * ws ^ 0 * (dtstart / print) * ws ^ 0 * (dtend / print) * ws ^ 0 * (location / print) local group = (Cc "Group:" / print) * C(((1 - lf) ^ 1) / print) * lf * ((C((1 - lf) ^ 1) / print) * lf) ^ 1 * -- @todo the end-of-line comment lf local anwesenheit = ws ^ 0 * P 'ANWESENHEITSLISTE' * ws ^ 0 * group ^ 0 * ws ^ 0 * P 'Abwesende und entschuldigte Personen:' * ws ^ 0 * group ^ 0 local tagesordnung = ws ^ 0 * P 'TAGESORDNUNG' -- ignore * (1 - P 'ÖFFENTLICHE SITZUNG') ^ 0 local tota = {} -- collect multiple lines local topl1 = ws ^ 12 * C((1 - ws) * (1 - lf) ^ 0) / function(s) table.insert(tota, s) end * lf local top = topl1 ^ 0 * (ws ^ 0 * P 'TOP' * ws ^ 1 * (Cc " vefa:top " / w) * (C(digit1) ^ 1 / w) * (Cc " ;\n" / w) * ws ^ 0 * C((1 - lf) ^ 0) / function(s) table.insert(tota, s) end ) * lf * topl1 ^ 0 * lf / function() w(' dct:title """') w(table.concat(tota, ' ')) w('""" ;\n') tota = {} end local protokoll = P 'ÖFFENTLICHE SITZUNG' * ( Cc ' [\n' / w * top * ws ^ 1 * Cc ' dct:description """' / w * C((1 - top) ^ 1) / w -- assert there no """ inside * Cc '""" ;\n' / w * Cc ' ],\n' / w ) ^ 1 * Cc ' [] ;\n' / w * Cc '.\n' / w local doc = head * anwesenheit * tagesordnung * protokoll * -1 local txt = io.stdin:read("*all") w [[@prefix rdf: . @prefix cal: . @prefix dct: . @prefix foaf: . @prefix owl: . @prefix rdfs: . @prefix vefa: . @prefix xs: . <.> dct:license ; ]] doc:match(txt)