-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathepp.lua
More file actions
executable file
·41 lines (34 loc) · 853 Bytes
/
epp.lua
File metadata and controls
executable file
·41 lines (34 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/lua
local state = {}
local mode = arg[1]
local START_PATTERN = "^;;;ifdef (%w+)$"
local END_PATTERN = "^;;;endif (%w+)$"
function update_state(l)
local start_chunk = string.match(l, START_PATTERN)
local end_chunk = string.match(l, END_PATTERN)
if start_chunk then state[start_chunk] = true
elseif end_chunk then state[end_chunk] = false
end
end
function cleanup(l)
if not (string.match(l, START_PATTERN) or string.match(l, END_PATTERN)) then return l end
end
function process_dump()
for l in io.lines() do
update_state(l)
if state["dump"] then print(cleanup(l)) end
end
end
function process_excl()
for l in io.lines() do
update_state(l)
if not state["excl"] then print(cleanup(l)) end
end
end
if mode == "dump" then
process_dump()
elseif mode == "excl" then
process_excl()
else
io.stderr:write("what?\n")
end