mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 09:09:31 +00:00
Replace checkpoint system
The previous system needed to store of the scope and full AST to build a Resumable object, which means that if persisted, updating the resumable script will have no effect. The new system instead uses an anchor token and does not require any information besides the anchor name.
This commit is contained in:
parent
c4636343b4
commit
56ed6c912b
21 changed files with 217 additions and 234 deletions
25
parser/expression/primary/anchor.lua
Normal file
25
parser/expression/primary/anchor.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
local primary = require("parser.expression.primary.primary")
|
||||
|
||||
local identifier = require("parser.expression.primary.identifier")
|
||||
|
||||
local ast = require("ast")
|
||||
local Anchor = ast.Anchor
|
||||
|
||||
return primary {
|
||||
match = function(self, str)
|
||||
if str:match("^#") then
|
||||
return identifier:match(str:match("^#(.-)$"))
|
||||
end
|
||||
return false
|
||||
end,
|
||||
|
||||
parse = function(self, source, str)
|
||||
local start_source = source:clone()
|
||||
local rem = source:consume(str:match("^(#)(.-)$"))
|
||||
|
||||
local ident
|
||||
ident, rem = identifier:parse(source, rem)
|
||||
|
||||
return Anchor:new(ident.name):set_source(start_source), rem
|
||||
end
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue