mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 09:09:31 +00:00
Replace persistent variable system
Previous system linked the variable name with the saved value, meaning the variable could not be renamed or moved outside the global scope. Instead we propose to store all persistent values in a global table, identifying each by a key. To still allow nice manipulation with identifiers, the alias syntax replace the persistent syntax for symbols - an aliases symbol will act as if a function call was used in place of the identifier when it appear.
This commit is contained in:
parent
56ed6c912b
commit
e71bff9562
13 changed files with 169 additions and 58 deletions
|
|
@ -16,11 +16,11 @@ return primary {
|
|||
|
||||
parse = function(self, source, str)
|
||||
local mod_const, mod_export, rem = source:consume(str:match("^(%:(:?)([&@]?))(.-)$"))
|
||||
local constant, persistent, type_check_exp, exported
|
||||
local constant, alias, type_check_exp, exported
|
||||
|
||||
-- get modifier
|
||||
if mod_const == ":" then constant = true end
|
||||
if mod_export == "&" then persistent = true
|
||||
if mod_export == "&" then alias = true
|
||||
elseif mod_export == "@" then exported = true end
|
||||
|
||||
-- name
|
||||
|
|
@ -35,6 +35,6 @@ return primary {
|
|||
type_check_exp = exp.arguments.positional[2]
|
||||
end
|
||||
|
||||
return ident:to_symbol{ constant = constant, persistent = persistent, exported = exported, type_check = type_check_exp }:set_source(source), rem
|
||||
return ident:to_symbol{ constant = constant, alias = alias, exported = exported, type_check = type_check_exp }:set_source(source), rem
|
||||
end
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue