mirror of
https://github.com/Oreolek/ink-instead.git
synced 2024-04-28 15:19:25 +03:00
knot,choices
This commit is contained in:
parent
35f1229b94
commit
656ade95af
50
peg.lua
50
peg.lua
|
@ -1,36 +1,30 @@
|
|||
require "util"
|
||||
local lpeg = require "lpeg"
|
||||
local S,C,P = lpeg.S, lpeg.C, lpeg.P
|
||||
|
||||
lpeg.locale(lpeg)
|
||||
local S,C,Ct,P = lpeg.S, lpeg.C, lpeg.Ct, lpeg.P
|
||||
local parserLogger = print
|
||||
|
||||
local function prefix(pref, p)
|
||||
return p / function(i)
|
||||
return pref..": "..i
|
||||
end
|
||||
end
|
||||
local sp = S" \t" ^0 + -1
|
||||
local wh = S" \t\r\n" ^0 + -1
|
||||
local nl = S"\r\n" ^1 + -1
|
||||
local id = (lpeg.alpha + '_') * (lpeg.alnum + '_')^0
|
||||
|
||||
local sp = S" \t" ^0
|
||||
local wh = S" \t\r\n" ^0
|
||||
local nl = S"\r\n" ^1
|
||||
local ch = P(1)
|
||||
|
||||
local todo = 'TODO:' * sp * (ch-nl)^0 / parserLogger -- TODO log location
|
||||
local commOL = '//' * sp * (ch-nl)^0 -- TODO comment that does not start at the line beginning
|
||||
local commML = '/*' * wh * (ch-'*/')^0 * '*/'
|
||||
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 commML = sp * '/*' * wh * (P(1)-'*/')^0 * '*/' * wh
|
||||
local comm = commOL + commML + todo
|
||||
local para = C(((1-nl-'*') * (1-nl)^1)) *wh -- hm
|
||||
|
||||
local para = (C((ch-nl)^1) *nl^0)-comm
|
||||
local knot = P('=')^2 * wh * C(id) * wh * P('=')^0 * wh
|
||||
local choiceAnswer = '*' * sp * para/"CHOICE: %1"
|
||||
local choiceBlock = Ct(choiceAnswer * para^0)
|
||||
local choices = Ct(choiceBlock^1)
|
||||
--local statement = * (comm + choices + para) *n
|
||||
--local prog = ((n * lpeg.Ct((statement*n)^0)) )* -1
|
||||
--local ink = prog
|
||||
|
||||
local choiceAnswer = '*' * sp * prefix("CHOICE", para)
|
||||
local choiceBlock = choiceAnswer * lpeg.Ct( (para- choiceAnswer)^0)
|
||||
local choices = lpeg.Ct(choiceBlock^1)
|
||||
|
||||
local statement = wh * (comm + choices + para) * wh
|
||||
|
||||
local prog = ((wh * lpeg.Ct((statement*wh)^0)) )* -1
|
||||
|
||||
local ink = prog
|
||||
|
||||
test(ink, 'content')
|
||||
test(ink, 'choices')
|
||||
--test(ink, 'content')
|
||||
test(choices, 'choices')
|
||||
--r=choices:match('*ans\nsss\nsss\n*second\n*second\n*second')
|
||||
--print (to_string( (r)))
|
||||
--tprint(r)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
"What that's?" my master asked.
|
||||
* "I am somewhat tired[."]," I repeated.
|
||||
"Really," he responded. "How deleterious."
|
||||
* "Nothing, Monsieur!"[] I replied.
|
||||
"Very good, then."
|
||||
"Very good, *then."
|
||||
you hairy basterd
|
||||
* "I said, this journey is appalling[."] and I want no more of it."
|
||||
"Ah," he replied, not unkindly. "I see you are feeling frustrated. Tomorrow, things will improve."
|
||||
// and then FIXME
|
||||
// and then FIXME
|
||||
nothing
|
||||
sdf
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Hello, world!
|
||||
Hello?
|
||||
Hello, are you there?
|
||||
TODO: Write this section properly!
|
||||
TODO:Write this section properly!
|
||||
|
||||
"What do you make of this?" she asked.
|
||||
|
||||
|
|
2
util.lua
2
util.lua
|
@ -40,7 +40,7 @@ function tprint (tbl, indent)
|
|||
for k, v in pairs(tbl) do
|
||||
formatting = string.rep(" ", indent) .. k .. ": "
|
||||
if type(v) == "table" then
|
||||
print(formatting)
|
||||
print(formatting .. 'table:')
|
||||
tprint(v, indent+1)
|
||||
elseif type(v) == 'boolean' then
|
||||
print(formatting .. tostring(v))
|
||||
|
|
Loading…
Reference in a new issue