1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 08:39:30 +00:00
anselme/test/tests/function type dispatch with default.lua
Étienne Reuh Fildadut 64bc85741a Changed a few things
- Bumped to 0.15.0
- Add boot script
- Change variable definition syntax, using a = to distinguish more cleary between identifier and value
- Variables initial values are evaluated on first use instead of at parsing time
- Error on variable redefinition. Means you should make sure to load saves after your scripts.
- Improve string parsing, support for escape codes
- Remove support for number literals with empty decimal part (42. for 42.0) as there's no distinction in Anselme and it conflicts with .function call suffix
- Changed priority of : pair operator
- Add type type, and type annotations to variables and function parameters
- Change Lua function system to use regular Anselme functions
  - Defining a function from Lua is now way simpler and require providing a full Anselme function signature
- Change Anselme function system
  - Dynamic dispatch, based on arity, type annotation and parameter names. Will select the most specific function at runtime.
  - Define way to overload most operators
  - Allow custom type to text formatters
  - Allow assignment to custom functions
  - Index operator ( renamed to ()
  - Functions with parameters each have their own private namespace (scoping ersatz)
  - Internal: "custom"-mode operators now have their own expression AST type instead of cluttering the function system
- Remove static type checker as it is barely useful with new function system. May or may not rewrite one in the future.
- Improve error messages here and there
- Internal: cleaning
2021-06-03 15:29:25 +02:00

73 lines
No EOL
1.2 KiB
Lua

local _={}
_[31]={}
_[30]={}
_[29]={}
_[28]={}
_[27]={}
_[26]={}
_[25]={}
_[24]={}
_[23]={}
_[22]={}
_[21]={}
_[20]={data="gn",tags=_[31]}
_[19]={data="gs",tags=_[30]}
_[18]={data="gn",tags=_[29]}
_[17]={data="gs",tags=_[28]}
_[16]={data="gn",tags=_[27]}
_[15]={data="gs",tags=_[26]}
_[14]={data="gn",tags=_[25]}
_[13]={data="gs",tags=_[24]}
_[12]={data="a",tags=_[23]}
_[11]={data="x",tags=_[22]}
_[10]={data="a",tags=_[21]}
_[9]={_[13],_[14],_[15],_[16],_[17],_[18],_[19],_[20]}
_[8]={_[12]}
_[7]={_[11]}
_[6]={_[10]}
_[5]={"return"}
_[4]={"text",_[9]}
_[3]={"text",_[8]}
_[2]={"text",_[7]}
_[1]={"text",_[6]}
return {_[1],_[2],_[3],_[4],_[5]}
--[[
{ "text", { {
data = "a",
tags = {}
} } }
{ "text", { {
data = "x",
tags = {}
} } }
{ "text", { {
data = "a",
tags = {}
} } }
{ "text", { {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
}, {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
}, {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
}, {
data = "gs",
tags = {}
}, {
data = "gn",
tags = {}
} } }
{ "return" }
]]--