mirror of
https://github.com/Oreolek/ink-instead.git
synced 2024-07-04 23:54:44 +03:00
cleanup
This commit is contained in:
parent
2dadbec183
commit
59b9db2ae0
19
peg.lua
19
peg.lua
|
@ -11,10 +11,9 @@ local id = (lpeg.alpha + '_') * (lpeg.alnum + '_')^0
|
||||||
local addr = C(id) * ('.' * C(id))^-1
|
local addr = C(id) * ('.' * C(id))^-1
|
||||||
|
|
||||||
local todo = sp * 'TODO:' * sp * (1-nl)^0 / parserLogger * wh -- TODO log location
|
local todo = sp * 'TODO:' * sp * (1-nl)^0 / parserLogger * wh -- TODO log location
|
||||||
local commOL = sp * '//' * sp * (1-nl)^0 * wh -- TODO comment that does not start at the line beginning
|
local commOL = sp * '//' * sp * (1-nl)^0 * wh
|
||||||
local commML = sp * '/*' * wh * (P(1)-'*/')^0 * '*/' * wh
|
local commML = sp * '/*' * wh * (P(1)-'*/')^0 * '*/' * wh
|
||||||
local comm = commOL + commML + todo
|
local comm = commOL + commML + todo
|
||||||
-- TODO can contain divert mid sentence
|
|
||||||
|
|
||||||
local glue = P('<>')/'glue' *wh
|
local glue = P('<>')/'glue' *wh
|
||||||
|
|
||||||
|
@ -31,26 +30,16 @@ local stitchHead = P('=')^1/'stitch' * wh * C(id) * wh * P('=')^0 * wh
|
||||||
--local choiceBlock = Ct(choiceAnswer * para^0)
|
--local choiceBlock = Ct(choiceAnswer * para^0)
|
||||||
--local choices = Ct(choiceBlock^1)
|
--local choices = Ct(choiceBlock^1)
|
||||||
|
|
||||||
|
|
||||||
--local statement = * (comm + choices + para) *n
|
|
||||||
--local prog = ((n * lpeg.Ct((statement*n)^0)) )* -1
|
|
||||||
--local ink = prog
|
|
||||||
|
|
||||||
--test(ink, 'content')
|
|
||||||
--test(choices, 'choices')
|
|
||||||
--r=knotted:match('= start ==\nhello\nagain\n-> END')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local ink = P({
|
local ink = P({
|
||||||
"lines",
|
"lines",
|
||||||
|
|
||||||
knott = Ct(knotHead * (V'line'-knotHead)^0 * wh),
|
knott = Ct(knotHead * (V'line'-knotHead)^0 * wh),
|
||||||
stitch = Ct(stitchHead * (V'line'-stitchHead)^0 * wh),
|
stitch = Ct(stitchHead * (V'line'-stitchHead)^0 * wh),
|
||||||
|
|
||||||
stmt = glue + divert + V'knott' + V'stitch',
|
stmt = glue + divert + V'knott' + V'stitch' + comm,
|
||||||
|
|
||||||
|
para = Ct(Cc('para') * C((1-nl-V'stmt')^1)*wh),
|
||||||
|
|
||||||
para = Ct(Cc('para') * C((1-nl-V'stmt')^1)*wh), -- hm
|
|
||||||
line = V'stmt' + V'para',
|
line = V'stmt' + V'para',
|
||||||
lines = Ct(V'line'^1)
|
lines = Ct(V'line'^1)
|
||||||
})
|
})
|
||||||
|
|
10
test/dev.lua
10
test/dev.lua
|
@ -1,9 +1,8 @@
|
||||||
return {
|
return {
|
||||||
ink=[[
|
ink=[[
|
||||||
we <>
|
we <> /* he
|
||||||
hurr ied
|
asdf
|
||||||
|
*/ hurr ied-> to_savile_row // comm
|
||||||
<> -> to_savile_row
|
|
||||||
|
|
||||||
|
|
||||||
=== to_savile_row ===
|
=== to_savile_row ===
|
||||||
|
@ -18,8 +17,7 @@ stiiii
|
||||||
expected= {
|
expected= {
|
||||||
{"para", "we "},
|
{"para", "we "},
|
||||||
"glue",
|
"glue",
|
||||||
{"para", "hurr ied "},
|
{"para", "hurr ied"},
|
||||||
"glue",
|
|
||||||
{"divert", "to_savile_row"},
|
{"divert", "to_savile_row"},
|
||||||
{
|
{
|
||||||
"knot",
|
"knot",
|
||||||
|
|
Loading…
Reference in a new issue