mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Move anselme code into its own directory
This commit is contained in:
parent
404e7dd56e
commit
5dd971ff8f
179 changed files with 603 additions and 579 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local resume_manager
|
local resume_manager
|
||||||
|
|
||||||
|
|
@ -30,6 +30,6 @@ Anchor = ast.abstract.Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
package.loaded[...] = Anchor
|
package.loaded[...] = Anchor
|
||||||
resume_manager = require("state.resume_manager")
|
resume_manager = require("anselme.state.resume_manager")
|
||||||
|
|
||||||
return Anchor
|
return Anchor
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Identifier, Number
|
local Identifier, Number
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ArgumentTuple
|
local ArgumentTuple
|
||||||
ArgumentTuple = ast.abstract.Node {
|
ArgumentTuple = ast.abstract.Node {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Nil
|
local Nil
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Assignment = ast.abstract.Node {
|
local Assignment = ast.abstract.Node {
|
||||||
type = "assignment",
|
type = "assignment",
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Nil, Return, AutoCall, ArgumentTuple, Flush
|
local Nil, Return, AutoCall, ArgumentTuple, Flush
|
||||||
|
|
||||||
local resume_manager = require("state.resume_manager")
|
local resume_manager = require("anselme.state.resume_manager")
|
||||||
|
|
||||||
local Block = ast.abstract.Node {
|
local Block = ast.abstract.Node {
|
||||||
type = "block",
|
type = "block",
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
return ast.abstract.Node {
|
return ast.abstract.Node {
|
||||||
type = "boolean",
|
type = "boolean",
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
-- used to handle mutability. probably the only mutable node you'll ever need! it's literally perfect!
|
-- used to handle mutability. probably the only mutable node you'll ever need! it's literally perfect!
|
||||||
-- note: all values here are expected to be already evaluated
|
-- note: all values here are expected to be already evaluated
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local Branched = ast.abstract.Runtime {
|
local Branched = ast.abstract.Runtime {
|
||||||
type = "branched",
|
type = "branched",
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Identifier
|
local Identifier
|
||||||
|
|
||||||
local regular_operators = require("common").regular_operators
|
local regular_operators = require("anselme.common").regular_operators
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local function reverse(t, fmt)
|
local function reverse(t, fmt)
|
||||||
for _, v in ipairs(t) do t[fmt:format(v[1])] = v[2] end
|
for _, v in ipairs(t) do t[fmt:format(v[1])] = v[2] end
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local ArgumentTuple
|
local ArgumentTuple
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Choice
|
local Choice
|
||||||
Choice = ast.abstract.Runtime {
|
Choice = ast.abstract.Runtime {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- note: functions only appear in non-evaluated nodes! once evaluated, they always become closures
|
-- note: functions only appear in non-evaluated nodes! once evaluated, they always become closures
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Overloadable, Runtime = ast.abstract.Overloadable, ast.abstract.Runtime
|
local Overloadable, Runtime = ast.abstract.Overloadable, ast.abstract.Runtime
|
||||||
local Definition
|
local Definition
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Nil, Overloadable
|
local Nil, Overloadable
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Definition = ast.abstract.Node {
|
local Definition = ast.abstract.Node {
|
||||||
type = "definition",
|
type = "definition",
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Branched, ArgumentTuple, Overload, Overloadable, Table
|
local Branched, ArgumentTuple, Overload, Overloadable, Table
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Nil
|
local Nil
|
||||||
|
|
||||||
local event_manager = require("state.event_manager")
|
local event_manager = require("anselme.state.event_manager")
|
||||||
|
|
||||||
local Flush = ast.abstract.Node {
|
local Flush = ast.abstract.Node {
|
||||||
type = "flush",
|
type = "flush",
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
-- note: functions only appear in non-evaluated nodes! once evaluated, they always become closures
|
-- note: functions only appear in non-evaluated nodes! once evaluated, they always become closures
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Overloadable = ast.abstract.Overloadable
|
local Overloadable = ast.abstract.Overloadable
|
||||||
local Closure, ReturnBoundary
|
local Closure, ReturnBoundary
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Function
|
local Function
|
||||||
Function = Overloadable {
|
Function = Overloadable {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local FunctionParameter
|
local FunctionParameter
|
||||||
FunctionParameter = ast.abstract.Node {
|
FunctionParameter = ast.abstract.Node {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Symbol, String
|
local Symbol, String
|
||||||
|
|
||||||
local Identifier
|
local Identifier
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Branched, Tuple
|
local Branched, Tuple
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local List
|
local List
|
||||||
List = ast.abstract.Runtime {
|
List = ast.abstract.Runtime {
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Overloadable = ast.abstract.Overloadable
|
local Overloadable = ast.abstract.Overloadable
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
local unpack = table.unpack or unpack
|
||||||
|
|
||||||
local LuaFunction
|
local LuaFunction
|
||||||
LuaFunction = ast.abstract.Runtime(Overloadable) {
|
LuaFunction = ast.abstract.Runtime(Overloadable) {
|
||||||
|
|
@ -46,7 +47,7 @@ LuaFunction = ast.abstract.Runtime(Overloadable) {
|
||||||
|
|
||||||
state.scope:pop()
|
state.scope:pop()
|
||||||
|
|
||||||
local r = self.func(table.unpack(lua_args))
|
local r = self.func(unpack(lua_args))
|
||||||
assert(r, "lua function returned no value")
|
assert(r, "lua function returned no value")
|
||||||
return r
|
return r
|
||||||
end,
|
end,
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
return ast.abstract.Node {
|
return ast.abstract.Node {
|
||||||
type = "nil",
|
type = "nil",
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local Number
|
local Number
|
||||||
Number = ast.abstract.Node {
|
Number = ast.abstract.Node {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local Overload
|
local Overload
|
||||||
Overload = ast.abstract.Node {
|
Overload = ast.abstract.Node {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
return ast.abstract.Runtime {
|
return ast.abstract.Runtime {
|
||||||
type = "pair",
|
type = "pair",
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ParameterTuple
|
local ParameterTuple
|
||||||
ParameterTuple = ast.abstract.Node {
|
ParameterTuple = ast.abstract.Node {
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
-- create a partial layer to define temporary variables
|
-- create a partial layer to define temporary variables
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Identifier, Quote
|
local Identifier, Quote
|
||||||
|
|
||||||
local attached_block_identifier, attached_block_symbol
|
local attached_block_identifier, attached_block_symbol
|
||||||
|
local unpack = table.unpack or unpack
|
||||||
|
|
||||||
local PartialScope
|
local PartialScope
|
||||||
PartialScope = ast.abstract.Node {
|
PartialScope = ast.abstract.Node {
|
||||||
|
|
@ -45,7 +46,7 @@ PartialScope = ast.abstract.Node {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
_eval = function(self, state)
|
_eval = function(self, state)
|
||||||
state.scope:push_partial(table.unpack(self._identifiers))
|
state.scope:push_partial(unpack(self._identifiers))
|
||||||
for sym, val in pairs(self.definitions) do state.scope:define(sym, val) end
|
for sym, val in pairs(self.definitions) do state.scope:define(sym, val) end
|
||||||
local exp = self.expression:eval(state)
|
local exp = self.expression:eval(state)
|
||||||
state.scope:pop()
|
state.scope:pop()
|
||||||
|
|
@ -54,7 +55,7 @@ PartialScope = ast.abstract.Node {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
_prepare = function(self, state)
|
_prepare = function(self, state)
|
||||||
state.scope:push_partial(table.unpack(self._identifiers))
|
state.scope:push_partial(unpack(self._identifiers))
|
||||||
for sym, val in pairs(self.definitions) do state.scope:define(sym, val) end
|
for sym, val in pairs(self.definitions) do state.scope:define(sym, val) end
|
||||||
self.expression:prepare(state)
|
self.expression:prepare(state)
|
||||||
state.scope:pop()
|
state.scope:pop()
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
--
|
--
|
||||||
-- used for infix operators where the evaluation of the right term depends of the left one (lazy boolean operators, conditionals, etc.)
|
-- used for infix operators where the evaluation of the right term depends of the left one (lazy boolean operators, conditionals, etc.)
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local Quote
|
local Quote
|
||||||
Quote = ast.abstract.Node {
|
Quote = ast.abstract.Node {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Return
|
local Return
|
||||||
Return = ast.abstract.Node {
|
Return = ast.abstract.Node {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- used stop propagating Return when leaving functions
|
-- used stop propagating Return when leaving functions
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Return
|
local Return
|
||||||
|
|
||||||
local ReturnBoundary = ast.abstract.Node {
|
local ReturnBoundary = ast.abstract.Node {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Identifier
|
local Identifier
|
||||||
|
|
||||||
local String = ast.abstract.Node {
|
local String = ast.abstract.Node {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local String
|
local String
|
||||||
|
|
||||||
local StringInterpolation = ast.abstract.Node {
|
local StringInterpolation = ast.abstract.Node {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Pair, Number, Nil
|
local Pair, Number, Nil
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Struct
|
local Struct
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Identifier, String
|
local Identifier, String
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Symbol
|
local Symbol
|
||||||
Symbol = ast.abstract.Node {
|
Symbol = ast.abstract.Node {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Branched, Struct, Nil = ast.Branched, ast.Struct, ast.Nil
|
local Branched, Struct, Nil = ast.Branched, ast.Struct, ast.Nil
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Table
|
local Table
|
||||||
Table = ast.abstract.Runtime {
|
Table = ast.abstract.Runtime {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local AutoCall, Event, Runtime = ast.abstract.AutoCall, ast.abstract.Event, ast.abstract.Runtime
|
local AutoCall, Event, Runtime = ast.abstract.AutoCall, ast.abstract.Event, ast.abstract.Runtime
|
||||||
|
|
||||||
return Runtime(AutoCall, Event) {
|
return Runtime(AutoCall, Event) {
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Text, String
|
local Text, String
|
||||||
|
|
||||||
local tag_manager = require("state.tag_manager")
|
local tag_manager = require("anselme.state.tag_manager")
|
||||||
|
|
||||||
local TextInterpolation = ast.abstract.Node {
|
local TextInterpolation = ast.abstract.Node {
|
||||||
type = "text interpolation",
|
type = "text interpolation",
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local TextInterpolation, String
|
local TextInterpolation, String
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local translation_manager
|
local translation_manager
|
||||||
|
|
||||||
|
|
@ -44,6 +44,6 @@ local Translatable = ast.abstract.Node {
|
||||||
package.loaded[...] = Translatable
|
package.loaded[...] = Translatable
|
||||||
TextInterpolation, String = ast.TextInterpolation, ast.String
|
TextInterpolation, String = ast.TextInterpolation, ast.String
|
||||||
|
|
||||||
translation_manager = require("state.translation_manager")
|
translation_manager = require("anselme.state.translation_manager")
|
||||||
|
|
||||||
return Translatable
|
return Translatable
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local Tuple
|
local Tuple
|
||||||
Tuple = ast.abstract.Node {
|
Tuple = ast.abstract.Node {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local format_identifier
|
local format_identifier
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- called automatically when returned by one of the expression in a block
|
-- called automatically when returned by one of the expression in a block
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
return ast.abstract.Node {
|
return ast.abstract.Node {
|
||||||
type = "auto call",
|
type = "auto call",
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- for nodes that can be written to the event buffer
|
-- for nodes that can be written to the event buffer
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
return ast.abstract.Node {
|
return ast.abstract.Node {
|
||||||
type = "event",
|
type = "event",
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local class = require("class")
|
local class = require("anselme.lib.class")
|
||||||
local fmt = require("common").fmt
|
local fmt = require("anselme.common").fmt
|
||||||
local binser = require("lib.binser")
|
local binser = require("anselme.lib.binser")
|
||||||
local utf8 = utf8 or require("lua-utf8")
|
local utf8 = utf8 or require("lua-utf8")
|
||||||
|
|
||||||
-- NODES SHOULD BE IMMUTABLE AFTER CREATION IF POSSIBLE!
|
-- NODES SHOULD BE IMMUTABLE AFTER CREATION IF POSSIBLE!
|
||||||
|
|
@ -11,7 +11,7 @@ local utf8 = utf8 or require("lua-utf8")
|
||||||
-- reminder: when requiring AST nodes somewhere, try to do it at the end of the file. and if you need to require something in this file, do it in the :_i_hate_cycles method.
|
-- reminder: when requiring AST nodes somewhere, try to do it at the end of the file. and if you need to require something in this file, do it in the :_i_hate_cycles method.
|
||||||
-- i've had enough headaches with cyclics references and nodes required several times...
|
-- i've had enough headaches with cyclics references and nodes required several times...
|
||||||
|
|
||||||
local uuid = require("common").uuid
|
local uuid = require("anselme.common").uuid
|
||||||
|
|
||||||
local State, Runtime, Call, Identifier, ArgumentTuple
|
local State, Runtime, Call, Identifier, ArgumentTuple
|
||||||
local resume_manager
|
local resume_manager
|
||||||
|
|
@ -320,12 +320,12 @@ Node = class {
|
||||||
-- The worst thing with this kind of require loop combined with our existing cycle band-aids is that Lua won't error, it will just execute the first node to subclass from Node twice. Which is annoying since now we have several, technically distinct classes representing the same node frolicking around.
|
-- The worst thing with this kind of require loop combined with our existing cycle band-aids is that Lua won't error, it will just execute the first node to subclass from Node twice. Which is annoying since now we have several, technically distinct classes representing the same node frolicking around.
|
||||||
-- Thus, any require here that may require other Nodes shall be done here. This method is called in anselme.lua after everything else is required.
|
-- Thus, any require here that may require other Nodes shall be done here. This method is called in anselme.lua after everything else is required.
|
||||||
_i_hate_cycles = function(self)
|
_i_hate_cycles = function(self)
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
Runtime, Call, Identifier, ArgumentTuple = ast.abstract.Runtime, ast.Call, ast.Identifier, ast.ArgumentTuple
|
Runtime, Call, Identifier, ArgumentTuple = ast.abstract.Runtime, ast.Call, ast.Identifier, ast.ArgumentTuple
|
||||||
custom_call_identifier = Identifier:new("_!")
|
custom_call_identifier = Identifier:new("_!")
|
||||||
|
|
||||||
State = require("state.State")
|
State = require("anselme.state.State")
|
||||||
resume_manager = require("state.resume_manager")
|
resume_manager = require("anselme.state.resume_manager")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
_debug_traverse = function(self, level)
|
_debug_traverse = function(self, level)
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- for nodes that can be put in an Overload
|
-- for nodes that can be put in an Overload
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
return ast.abstract.Node {
|
return ast.abstract.Node {
|
||||||
type = "overloadable",
|
type = "overloadable",
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
-- indicate a Runtime node: it should not exist in the AST generated by the parser but only as a result of an evaluation or call
|
-- indicate a Runtime node: it should not exist in the AST generated by the parser but only as a result of an evaluation or call
|
||||||
-- is assumed to be already evaluated and prepared (will actually error on prepare)
|
-- is assumed to be already evaluated and prepared (will actually error on prepare)
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
|
|
||||||
return ast.abstract.Node {
|
return ast.abstract.Node {
|
||||||
type = "runtime",
|
type = "runtime",
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
abstract = setmetatable({}, {
|
abstract = setmetatable({}, {
|
||||||
__index = function(self, key)
|
__index = function(self, key)
|
||||||
self[key] = require("ast.abstract."..key)
|
self[key] = require("anselme.ast.abstract."..key)
|
||||||
return self[key]
|
return self[key]
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
}, {
|
}, {
|
||||||
__index = function(self, key)
|
__index = function(self, key)
|
||||||
self[key] = require("ast."..key)
|
self[key] = require("anselme.ast."..key)
|
||||||
return self[key]
|
return self[key]
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
local escape_cache = {}
|
local escape_cache = {}
|
||||||
local ansicolors = require("lib.ansicolors")
|
local ansicolors = require("anselme.lib.ansicolors")
|
||||||
|
|
||||||
local common = {
|
local common = {
|
||||||
-- escape text to be used as an exact pattern
|
-- escape text to be used as an exact pattern
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Number, Struct, String, Nil, Boolean
|
local Number, Struct, String, Nil, Boolean
|
||||||
|
|
||||||
local function to_anselme(val)
|
local function to_anselme(val)
|
||||||
|
|
@ -42,13 +42,13 @@
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
-- ```
|
-- ```
|
||||||
|
--
|
||||||
-- LuaJIT compatibility
|
-- If `require("anselme")` fails with an error similar to `module 'anselme' not found`, you might need to redefine `package.path` before the require:
|
||||||
-- TODO: too heavyhanded
|
-- ```lua
|
||||||
if _VERSION == "Lua 5.1" then
|
-- package.path = "path/?/init.lua;path/?.lua;" .. package.path -- where path is the directory where anselme is located
|
||||||
package.path = "./?/init.lua;" .. package.path
|
-- require("anselme")
|
||||||
table.unpack = unpack
|
-- ```
|
||||||
end
|
-- Anselme expects that `require("anselme.module")` will try loading both `anselme/module/init.lua` and `anselme/module.lua`, which may not be the case without the above code as `package.path`'s default value is system dependent, i.e. not my problem.
|
||||||
|
|
||||||
local parser, State
|
local parser, State
|
||||||
|
|
||||||
|
|
@ -86,8 +86,8 @@ local anselme = {
|
||||||
|
|
||||||
package.loaded[...] = anselme
|
package.loaded[...] = anselme
|
||||||
|
|
||||||
parser = require("parser")
|
parser = require("anselme.parser")
|
||||||
State = require("state.State")
|
State = require("anselme.state.State")
|
||||||
require("ast.abstract.Node"):_i_hate_cycles()
|
require("anselme.ast.abstract.Node"):_i_hate_cycles()
|
||||||
|
|
||||||
return anselme
|
return anselme
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
--
|
--
|
||||||
-- usage:
|
-- usage:
|
||||||
--
|
--
|
||||||
-- local class = require("class")
|
-- local class = require("anselme.lib.class")
|
||||||
-- local Vehicle = class {
|
-- local Vehicle = class {
|
||||||
-- type = "vehicle", -- class name, optional
|
-- type = "vehicle", -- class name, optional
|
||||||
--
|
--
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
-- local car = Car:new("red") -- instancing
|
-- local car = Car:new("red") -- instancing
|
||||||
-- print(car:is_stable(), car.color) -- true, "red"
|
-- print(car:is_stable(), car.color) -- true, "red"
|
||||||
--
|
--
|
||||||
-- the default class returned by require("class") contains a few other default methods that will be inherited by all subclasses
|
-- the default class returned by require("anselme.lib.class") contains a few other default methods that will be inherited by all subclasses
|
||||||
-- see line 99 and further for details & documentation
|
-- see line 99 and further for details & documentation
|
||||||
--
|
--
|
||||||
-- design philosophy:
|
-- design philosophy:
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local class = require("class")
|
local class = require("anselme.lib.class")
|
||||||
local utf8 = utf8 or require("lua-utf8")
|
local utf8 = utf8 or require("lua-utf8")
|
||||||
|
|
||||||
local Source
|
local Source
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
local utf8 = utf8 or require("lua-utf8")
|
local utf8 = utf8 or require("lua-utf8")
|
||||||
|
|
||||||
local Source = require("parser.Source")
|
local Source = require("anselme.parser.Source")
|
||||||
|
|
||||||
local function indented_to_tree(indented)
|
local function indented_to_tree(indented)
|
||||||
local tree = {}
|
local tree = {}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local comment
|
local comment
|
||||||
comment = primary {
|
comment = primary {
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
local identifier = require("parser.expression.primary.identifier")
|
local identifier = require("anselme.parser.expression.primary.identifier")
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local FunctionParameter = ast.FunctionParameter
|
local FunctionParameter = ast.FunctionParameter
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
local assignment_priority = operator_priority["_=_"]
|
local assignment_priority = operator_priority["_=_"]
|
||||||
local type_check_priority = operator_priority["_::_"]
|
local type_check_priority = operator_priority["_::_"]
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local function_parameter = require("parser.expression.contextual.function_parameter")
|
local function_parameter = require("anselme.parser.expression.contextual.function_parameter")
|
||||||
|
|
||||||
return function_parameter {
|
return function_parameter {
|
||||||
parse = function(self, source, str, limit_pattern)
|
parse = function(self, source, str, limit_pattern)
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
local function_parameter = require("parser.expression.contextual.function_parameter")
|
local function_parameter = require("anselme.parser.expression.contextual.function_parameter")
|
||||||
local function_parameter_no_default = require("parser.expression.contextual.function_parameter_no_default")
|
local function_parameter_no_default = require("anselme.parser.expression.contextual.function_parameter_no_default")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local ParameterTuple = ast.ParameterTuple
|
local ParameterTuple = ast.ParameterTuple
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local identifier = require("parser.expression.primary.identifier")
|
local identifier = require("anselme.parser.expression.primary.identifier")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Anchor = ast.Anchor
|
local Anchor = ast.Anchor
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Identifier, Call, ArgumentTuple = ast.Identifier, ast.Call, ast.ArgumentTuple
|
local Identifier, Call, ArgumentTuple = ast.Identifier, ast.Call, ast.ArgumentTuple
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
local function_parameter_no_default = require("parser.expression.contextual.function_parameter_no_default")
|
local function_parameter_no_default = require("anselme.parser.expression.contextual.function_parameter_no_default")
|
||||||
local parameter_tuple = require("parser.expression.contextual.parameter_tuple")
|
local parameter_tuple = require("anselme.parser.expression.contextual.parameter_tuple")
|
||||||
local identifier = require("parser.expression.primary.identifier")
|
local identifier = require("anselme.parser.expression.primary.identifier")
|
||||||
|
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Symbol, Definition, Function, ParameterTuple = ast.Symbol, ast.Definition, ast.Function, ast.ParameterTuple
|
local Symbol, Definition, Function, ParameterTuple = ast.Symbol, ast.Definition, ast.Function, ast.ParameterTuple
|
||||||
|
|
||||||
local regular_operators = require("common").regular_operators
|
local regular_operators = require("anselme.common").regular_operators
|
||||||
local prefixes = regular_operators.prefixes
|
local prefixes = regular_operators.prefixes
|
||||||
local suffixes = regular_operators.suffixes
|
local suffixes = regular_operators.suffixes
|
||||||
local infixes = regular_operators.infixes
|
local infixes = regular_operators.infixes
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
-- same as function_parameter_no_default, but allow wrapping in (evenetual) parentheses
|
-- same as function_parameter_no_default, but allow wrapping in (evenetual) parentheses
|
||||||
-- in order to solve some priotity issues (_._ has higher priority than _::_, leading to not being possible to overload it with type filtering without parentheses)
|
-- in order to solve some priotity issues (_._ has higher priority than _::_, leading to not being possible to overload it with type filtering without parentheses)
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local Identifier = require("ast.Identifier")
|
local Identifier = require("anselme.ast.Identifier")
|
||||||
|
|
||||||
local disallowed_set = (".~`^+-=<>/[]*{}|\\_!?,;:()\"@&$#%"):gsub("[^%w]", "%%%1")
|
local disallowed_set = (".~`^+-=<>/[]*{}|\\_!?,;:()\"@&$#%"):gsub("[^%w]", "%%%1")
|
||||||
local identifier_pattern = "%s*[^0-9%s'"..disallowed_set.."][^"..disallowed_set.."]*"
|
local identifier_pattern = "%s*[^0-9%s'"..disallowed_set.."][^"..disallowed_set.."]*"
|
||||||
|
|
||||||
local common = require("common")
|
local common = require("anselme.common")
|
||||||
local trim, escape = common.trim, common.escape
|
local trim, escape = common.trim, common.escape
|
||||||
|
|
||||||
-- for operator identifiers
|
-- for operator identifiers
|
||||||
local regular_operators = require("common").regular_operators
|
local regular_operators = require("anselme.common").regular_operators
|
||||||
local operators = {}
|
local operators = {}
|
||||||
for _, prefix in ipairs(regular_operators.prefixes) do table.insert(operators, prefix[1].."_") end
|
for _, prefix in ipairs(regular_operators.prefixes) do table.insert(operators, prefix[1].."_") end
|
||||||
for _, infix in ipairs(regular_operators.infixes) do table.insert(operators, "_"..infix[1].."_") end
|
for _, infix in ipairs(regular_operators.infixes) do table.insert(operators, "_"..infix[1].."_") end
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
--- try to parse a primary expression
|
--- try to parse a primary expression
|
||||||
|
|
||||||
local function r(name)
|
local function r(name)
|
||||||
return require("parser.expression.primary."..name), nil
|
return require("anselme.parser.expression.primary."..name), nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local primaries = {
|
local primaries = {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local Number = require("ast.Number")
|
local Number = require("anselme.ast.Number")
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
match = function(self, str)
|
match = function(self, str)
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
-- either parentheses or nil ()
|
-- either parentheses or nil ()
|
||||||
|
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Nil = ast.Nil
|
local Nil = ast.Nil
|
||||||
|
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
match = function(self, str)
|
match = function(self, str)
|
||||||
8
anselme/parser/expression/primary/prefix/else.lua
Normal file
8
anselme/parser/expression/primary/prefix/else.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
local prefix_quote_right = require("anselme.parser.expression.primary.prefix.prefix_quote_right")
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return prefix_quote_right {
|
||||||
|
operator = "~",
|
||||||
|
identifier = "~_",
|
||||||
|
priority = operator_priority["~_"]
|
||||||
|
}
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
local prefix = require("parser.expression.primary.prefix.prefix")
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
local parameter_tuple = require("parser.expression.contextual.parameter_tuple")
|
local parameter_tuple = require("anselme.parser.expression.contextual.parameter_tuple")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Function, ParameterTuple = ast.Function, ast.ParameterTuple
|
local Function, ParameterTuple = ast.Function, ast.ParameterTuple
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
return prefix {
|
return prefix {
|
||||||
operator = "$",
|
operator = "$",
|
||||||
9
anselme/parser/expression/primary/prefix/mutable.lua
Normal file
9
anselme/parser/expression/primary/prefix/mutable.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return prefix {
|
||||||
|
operator = "*",
|
||||||
|
identifier = "*_",
|
||||||
|
priority = operator_priority["*_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/primary/prefix/negation.lua
Normal file
9
anselme/parser/expression/primary/prefix/negation.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return prefix {
|
||||||
|
operator = "-",
|
||||||
|
identifier = "-_",
|
||||||
|
priority = operator_priority["-_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/primary/prefix/not.lua
Normal file
9
anselme/parser/expression/primary/prefix/not.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return prefix {
|
||||||
|
operator = "!",
|
||||||
|
identifier = "!_",
|
||||||
|
priority = operator_priority["!_"]
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
-- unary prefix operators, for example: the - in -5
|
-- unary prefix operators, for example: the - in -5
|
||||||
|
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local prefix = require("parser.expression.primary.prefix.prefix")
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Nil = ast.Nil
|
local Nil = ast.Nil
|
||||||
|
|
||||||
return prefix {
|
return prefix {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local prefix = require("parser.expression.primary.prefix.prefix")
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple, Quote = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.Quote
|
local Call, Identifier, ArgumentTuple, Quote = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.Quote
|
||||||
|
|
||||||
return prefix {
|
return prefix {
|
||||||
15
anselme/parser/expression/primary/prefix/return.lua
Normal file
15
anselme/parser/expression/primary/prefix/return.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
local prefix_maybe_nil_right = require("anselme.parser.expression.primary.prefix.prefix_maybe_nil_right")
|
||||||
|
|
||||||
|
local ast = require("anselme.ast")
|
||||||
|
local Return = ast.Return
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return prefix_maybe_nil_right {
|
||||||
|
operator = "@",
|
||||||
|
priority = operator_priority["@_"],
|
||||||
|
|
||||||
|
build_ast = function(self, right)
|
||||||
|
return Return:new(right)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local prefix = require("parser.expression.primary.prefix.prefix")
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
return prefix {
|
return prefix {
|
||||||
operator = ";",
|
operator = ";",
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local prefix = require("parser.expression.primary.prefix.prefix")
|
local prefix = require("anselme.parser.expression.primary.prefix.prefix")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Translatable = ast.Translatable
|
local Translatable = ast.Translatable
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
return prefix {
|
return prefix {
|
||||||
operator = "%",
|
operator = "%",
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
local class = require("class")
|
local class = require("anselme.lib.class")
|
||||||
|
|
||||||
return class {
|
return class {
|
||||||
new = false, -- static class
|
new = false, -- static class
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
-- note: this is reused in primary.text, hence all the configurable fields
|
-- note: this is reused in primary.text, hence all the configurable fields
|
||||||
|
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local String, StringInterpolation = ast.String, ast.StringInterpolation
|
local String, StringInterpolation = ast.String, ast.StringInterpolation
|
||||||
|
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
|
|
||||||
local escape_code = {
|
local escape_code = {
|
||||||
["n"] = "\n",
|
["n"] = "\n",
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
local tuple = require("parser.expression.primary.tuple")
|
local tuple = require("anselme.parser.expression.primary.tuple")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Struct = ast.Struct
|
local Struct = ast.Struct
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
local type_check = require("parser.expression.secondary.infix.type_check")
|
local type_check = require("anselme.parser.expression.secondary.infix.type_check")
|
||||||
|
|
||||||
local identifier = require("parser.expression.primary.identifier")
|
local identifier = require("anselme.parser.expression.primary.identifier")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Nil = ast.Nil
|
local Nil = ast.Nil
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local string = require("parser.expression.primary.string")
|
local string = require("anselme.parser.expression.primary.string")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local TextInterpolation, Translatable = ast.TextInterpolation, ast.Translatable
|
local TextInterpolation, Translatable = ast.TextInterpolation, ast.Translatable
|
||||||
|
|
||||||
return string {
|
return string {
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
local primary = require("parser.expression.primary.primary")
|
local primary = require("anselme.parser.expression.primary.primary")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Tuple = ast.Tuple
|
local Tuple = ast.Tuple
|
||||||
|
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
|
|
||||||
return primary {
|
return primary {
|
||||||
match = function(self, str)
|
match = function(self, str)
|
||||||
9
anselme/parser/expression/secondary/infix/addition.lua
Normal file
9
anselme/parser/expression/secondary/infix/addition.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = "+",
|
||||||
|
identifier = "_+_",
|
||||||
|
priority = operator_priority["_+_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/secondary/infix/and.lua
Normal file
9
anselme/parser/expression/secondary/infix/and.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix_quote_right = require("anselme.parser.expression.secondary.infix.infix_quote_right")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix_quote_right {
|
||||||
|
operator = "&",
|
||||||
|
identifier = "_&_",
|
||||||
|
priority = operator_priority["_&_"]
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Identifier, Assignment = ast.Identifier, ast.Assignment
|
local Identifier, Assignment = ast.Identifier, ast.Assignment
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call = ast.Call
|
local Call = ast.Call
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
||||||
|
|
||||||
local assignment = require("parser.expression.secondary.infix.assignment")
|
local assignment = require("anselme.parser.expression.secondary.infix.assignment")
|
||||||
local assignment_call = require("parser.expression.secondary.infix.assignment_call")
|
local assignment_call = require("anselme.parser.expression.secondary.infix.assignment_call")
|
||||||
|
|
||||||
local infixes = require("common").regular_operators.infixes
|
local infixes = require("anselme.common").regular_operators.infixes
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local generated = {}
|
local generated = {}
|
||||||
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
local identifier = require("parser.expression.primary.identifier")
|
local identifier = require("anselme.parser.expression.primary.identifier")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, ArgumentTuple = ast.Call, ast.ArgumentTuple
|
local Call, ArgumentTuple = ast.Call, ast.ArgumentTuple
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple, ParameterTuple, Function = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.ParameterTuple, ast.Function
|
local Call, Identifier, ArgumentTuple, ParameterTuple, Function = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.ParameterTuple, ast.Function
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Definition, Symbol = ast.Definition, ast.Symbol
|
local Definition, Symbol = ast.Definition, ast.Symbol
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
9
anselme/parser/expression/secondary/infix/different.lua
Normal file
9
anselme/parser/expression/secondary/infix/different.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = "!=",
|
||||||
|
identifier = "_!=_",
|
||||||
|
priority = operator_priority["_!=_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/secondary/infix/division.lua
Normal file
9
anselme/parser/expression/secondary/infix/division.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = "/",
|
||||||
|
identifier = "_/_",
|
||||||
|
priority = operator_priority["_/_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/secondary/infix/equal.lua
Normal file
9
anselme/parser/expression/secondary/infix/equal.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = "==",
|
||||||
|
identifier = "_==_",
|
||||||
|
priority = operator_priority["_==_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/secondary/infix/exponent.lua
Normal file
9
anselme/parser/expression/secondary/infix/exponent.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = "^",
|
||||||
|
identifier = "_^_",
|
||||||
|
priority = operator_priority["_^_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/secondary/infix/greater.lua
Normal file
9
anselme/parser/expression/secondary/infix/greater.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = ">",
|
||||||
|
identifier = "_>_",
|
||||||
|
priority = operator_priority["_>_"]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = ">=",
|
||||||
|
identifier = "_>=_",
|
||||||
|
priority = operator_priority["_>=_"]
|
||||||
|
}
|
||||||
9
anselme/parser/expression/secondary/infix/if.lua
Normal file
9
anselme/parser/expression/secondary/infix/if.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix_quote_right = require("anselme.parser.expression.secondary.infix.infix_quote_right")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix_quote_right {
|
||||||
|
operator = "~",
|
||||||
|
identifier = "_~_",
|
||||||
|
priority = operator_priority["_~_"]
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
local identifier = require("parser.expression.primary.identifier")
|
local identifier = require("anselme.parser.expression.primary.identifier")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
local operator_priority = require("common").operator_priority
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
local secondary = require("parser.expression.secondary.secondary")
|
local secondary = require("anselme.parser.expression.secondary.secondary")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
local Call, Identifier, ArgumentTuple = ast.Call, ast.Identifier, ast.ArgumentTuple
|
||||||
|
|
||||||
return secondary {
|
return secondary {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
-- same as infix, but skip if no valid expression after the operator instead of erroring
|
-- same as infix, but skip if no valid expression after the operator instead of erroring
|
||||||
-- useful for operators that are both valid as infix and as suffix
|
-- useful for operators that are both valid as infix and as suffix
|
||||||
|
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
local escape = require("common").escape
|
local escape = require("anselme.common").escape
|
||||||
local expression_to_ast = require("parser.expression.to_ast")
|
local expression_to_ast = require("anselme.parser.expression.to_ast")
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
-- returns exp, rem if expression found
|
-- returns exp, rem if expression found
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple, Quote = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.Quote
|
local Call, Identifier, ArgumentTuple, Quote = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.Quote
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local infix = require("parser.expression.secondary.infix.infix")
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
local ast = require("ast")
|
local ast = require("anselme.ast")
|
||||||
local Call, Identifier, ArgumentTuple, Quote = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.Quote
|
local Call, Identifier, ArgumentTuple, Quote = ast.Call, ast.Identifier, ast.ArgumentTuple, ast.Quote
|
||||||
|
|
||||||
return infix {
|
return infix {
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
local infix = require("anselme.parser.expression.secondary.infix.infix")
|
||||||
|
|
||||||
|
local operator_priority = require("anselme.common").operator_priority
|
||||||
|
|
||||||
|
return infix {
|
||||||
|
operator = "//",
|
||||||
|
identifier = "_//_",
|
||||||
|
priority = operator_priority["_//_"]
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue