• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 9307175333

30 May 2024 06:08PM UTC coverage: 70.644% (-3.5%) from 74.124%
9307175333

push

github

web-flow
Merge b18390e74 into 70ff5c335

1910 of 2592 new or added lines in 108 files covered. (73.69%)

901 existing lines in 52 files now uncovered.

12203 of 17274 relevant lines covered (70.64%)

6112.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.94
/inputters/sil-epnf.lua
1
local epnf = require("epnf")
167✔
2
local bits = require("core.parserbits")
167✔
3

4
local passthroughCommands = {
167✔
5
   ftl = true,
6
   lua = true,
7
   math = true,
8
   raw = true,
9
   script = true,
10
   sil = true,
11
   use = true,
12
   xml = true,
13
}
14

15
local isPassthrough = function (_, _, command)
16
   return passthroughCommands[command] or false
4,463✔
17
end
18

19
local isNotPassthrough = function (...)
20
   return not isPassthrough(...)
4,382✔
21
end
22

23
local isMatchingEndEnv = function (_, _, thisCommand, lastCommand)
24
   return thisCommand == lastCommand
286✔
25
end
26

27
-- luacheck: push ignore
28
-- stylua: ignore start
29
---@diagnostic disable: undefined-global, unused-local, lowercase-global
30
local function builder (_ENV)
31
   local _ = WS^0
167✔
32
   local eol = S"\r\n"
167✔
33
   local specials = S"\\{}%"
167✔
34
   local escaped_specials = P"\\" * specials
167✔
35
   local unescapeSpecials = function (str)
36
      return str:gsub('\\([{}%%\\])', '%1')
2,017✔
37
   end
38
   local myID = C(bits.silidentifier) / 1
167✔
39
   local cmdID = myID - P"begin" - P"end"
167✔
40
   local wrapper = function (a) return type(a)=="table" and a or {} end
1,999✔
41
   local parameters = (P"[" * bits.parameters * P"]")^-1 / wrapper
167✔
42

43
   local pass_end =
44
         P"\\end{" *
167✔
45
         ( cmdID * Cb"command" ) *
167✔
46
         ( P"}" * _ ) + E"Environment begun but never ended"
334✔
47
   local notpass_end =
48
         P"\\end{" *
167✔
49
         ( Cmt(cmdID * Cb"command", isMatchingEndEnv) + E"Environment mismatch") *
334✔
50
         ( P"}" * _ ) + E"Environment begun but never ended"
334✔
51

52
   env_passthrough_content = Cg(
334✔
53
         V"env_passthrough_text"
167✔
54
      )^0
167✔
55
   env_passthrough_text = C((1 - (P"\\end{" * Cmt(cmdID * Cb"command", isMatchingEndEnv) * P"}"))^1)
167✔
56
   passthrough_content = C(Cg(
501✔
57
         V"passthrough_text" +
167✔
58
         V"debraced_passthrough_text"
167✔
59
      )^0)
334✔
60
   passthrough_text = C((1-S("{}"))^1)
167✔
61
   debraced_passthrough_text = C(V"braced_passthrough_text")
167✔
62
   braced_passthrough_text = P"{" * V"passthrough_content" * ( P"}" + E("} expected") )
334✔
63

64
   START"document"
167✔
65
   document = V"content" * EOF"Unexpected character at end of input"
334✔
66
   content = Cg(
334✔
67
         V"environment" +
167✔
68
         V"comment" +
167✔
69
         V"text" +
167✔
70
         V"braced_content" +
167✔
71
         V"command"
167✔
72
      )^0
167✔
NEW
73
   environment =
×
74
      P"\\begin" *
167✔
75
      Cg(parameters, "options") *
167✔
76
      P"{" *
167✔
77
      Cg(cmdID, "command") *
167✔
78
      P"}" *
167✔
NEW
79
      (
×
80
         (Cmt(Cb"command", isPassthrough) * V"env_passthrough_content" * pass_end) +
167✔
81
         (Cmt(Cb"command", isNotPassthrough) * V"content" * notpass_end)
167✔
82
      )
167✔
83
   comment = C( P"%" * P(1-eol)^0 * eol^-1 / "" )
167✔
84
   text = C((1 - specials + escaped_specials)^1) / unescapeSpecials
167✔
85
   braced_content = P"{" * V"content" * ( P"}" + E("} expected") )
334✔
NEW
86
   command = (
×
87
         P"\\" *
167✔
88
         Cg(cmdID, "command") *
167✔
89
         Cg(parameters, "options") *
167✔
NEW
90
         (
×
91
         (Cmt(Cb"command", isPassthrough) * V"braced_passthrough_text") +
167✔
92
         (Cmt(Cb"command", isNotPassthrough) * V"braced_content")
167✔
93
         )^0
167✔
94
      )
167✔
95
end
96
-- luacheck: pop
97
-- stylua: ignore end
98
---@diagnostic enable: undefined-global, unused-local, lowercase-global
99

100
local grammar = epnf.define(builder)
167✔
101

102
local function parser (string)
103
   return epnf.parsestring(grammar, string)
168✔
104
end
105

106
return parser
167✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc