mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Add text buffer syntax
This commit is contained in:
parent
ccaa40a99d
commit
e9606cdee0
13 changed files with 345 additions and 145 deletions
|
|
@ -291,7 +291,7 @@ common = {
|
|||
implicit_call = implicit_call, -- was call implicitely (no ! or parentheses)?
|
||||
variants = variants, -- list of potential variants
|
||||
argument = { -- wrap everything in a list literal to simplify later things (otherwise may be nil, single value, list constructor)
|
||||
type = "map_brackets",
|
||||
type = "map brackets",
|
||||
expression = arg
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,15 @@ local function expression(s, state, namespace, current_priority, operating_on)
|
|||
local l, e = parse_text(d, state, namespace, "string") -- parse interpolated expressions
|
||||
if not l then return l, e end
|
||||
return expression(r, state, namespace, current_priority, l)
|
||||
-- text buffer
|
||||
elseif s:match("^%%%[") then
|
||||
local text = s:match("^%%(.*)$")
|
||||
local v, r = parse_text(text, state, namespace, "text", "#~", true)
|
||||
if not v then return nil, r end
|
||||
return expression(r, state, namespace, current_priority, {
|
||||
type = "text buffer",
|
||||
text = v
|
||||
})
|
||||
-- paranthesis
|
||||
elseif s:match("^%b()") then
|
||||
local content, r = s:match("^(%b())(.*)$")
|
||||
|
|
@ -134,7 +143,7 @@ local function expression(s, state, namespace, current_priority, operating_on)
|
|||
if r_paren:match("[^%s]") then return nil, ("unexpected %q at end of list parenthesis expression"):format(r_paren) end
|
||||
end
|
||||
return expression(r, state, namespace, current_priority, {
|
||||
type = "list_brackets",
|
||||
type = "list brackets",
|
||||
expression = exp
|
||||
})
|
||||
-- map parenthesis
|
||||
|
|
@ -149,7 +158,7 @@ local function expression(s, state, namespace, current_priority, operating_on)
|
|||
if r_paren:match("[^%s]") then return nil, ("unexpected %q at end of map parenthesis expression"):format(r_paren) end
|
||||
end
|
||||
return expression(r, state, namespace, current_priority, {
|
||||
type = "map_brackets",
|
||||
type = "map brackets",
|
||||
expression = exp
|
||||
})
|
||||
-- identifier
|
||||
|
|
|
|||
|
|
@ -53,6 +53,16 @@ local function parse(state)
|
|||
end
|
||||
end
|
||||
end
|
||||
-- get list of properties
|
||||
-- (unlike scoped, does not includes subnamespaces)
|
||||
if line.properties then
|
||||
line.properties = {}
|
||||
for name in pairs(state.variables) do
|
||||
if name:sub(1, #namespace) == namespace and not name:sub(#namespace+1):match("%.") then
|
||||
table.insert(line.properties, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- expressions
|
||||
if line.expression then
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ local function parse_line(line, state, namespace, parent_function)
|
|||
elseif lr:match("^%%") then
|
||||
r.subtype = "class"
|
||||
r.resume_boundary = true
|
||||
r.properties = true
|
||||
allow_params = false
|
||||
allow_assign = false
|
||||
elseif lr:match("^%!") then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue