mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
[doc] standard library documentation first draft
This commit is contained in:
parent
41dede808e
commit
0195913dcc
29 changed files with 2045 additions and 67 deletions
|
|
@ -1,11 +1,20 @@
|
|||
--- # Boolean
|
||||
-- @titlelevel 3
|
||||
|
||||
local ast = require("anselme.ast")
|
||||
local Boolean, ArgumentTuple = ast.Boolean, ast.ArgumentTuple
|
||||
|
||||
return {
|
||||
--- A boolean true value.
|
||||
{ "true", Boolean:new(true) },
|
||||
--- A boolean false value.
|
||||
{ "false", Boolean:new(false) },
|
||||
|
||||
{
|
||||
--- Equality operator.
|
||||
-- Returns true if `a` and `b` are equal, false otherwise.
|
||||
--
|
||||
-- Mutable values are compared by reference, immutable values are compared by value.
|
||||
"_==_", "(a, b)",
|
||||
function(state, a, b)
|
||||
if a.mutable ~= b.mutable then return Boolean:new(false)
|
||||
|
|
@ -15,6 +24,8 @@ return {
|
|||
end
|
||||
},
|
||||
{
|
||||
--- Inequality operator.
|
||||
-- Retrusn false if `a` and `b` are equal, true otherwise.
|
||||
"_!=_", "(a, b)",
|
||||
function(state, a, b)
|
||||
if a.mutable ~= b.mutable then return Boolean:new(true)
|
||||
|
|
@ -24,12 +35,16 @@ return {
|
|||
end
|
||||
},
|
||||
{
|
||||
--- Boolean not operator.
|
||||
-- Returns false if `a` is true, false otherwise.
|
||||
"!_", "(a)",
|
||||
function(state, a)
|
||||
return Boolean:new(not a:truthy())
|
||||
end
|
||||
},
|
||||
{
|
||||
--- Boolean lazy and operator.
|
||||
-- If `left` is truthy, evaluate `right` and returns it. Otherwise, returns left.
|
||||
"_&_", "(left, right)",
|
||||
function(state, left, right)
|
||||
if left:truthy() then
|
||||
|
|
@ -40,6 +55,8 @@ return {
|
|||
end
|
||||
},
|
||||
{
|
||||
--- Boolean lazy or operator.
|
||||
-- If `left` is truthy, returns it. Otherwise, evaluate `right` and returns it.
|
||||
"_|_", "(left, right)",
|
||||
function(state, left, right)
|
||||
if left:truthy() then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue