diff --git a/anselme/common/init.lua b/anselme/common/init.lua index e125d33..9dd1093 100644 --- a/anselme/common/init.lua +++ b/anselme/common/init.lua @@ -48,7 +48,7 @@ local common = { { "&", 5 }, { "|", 5 }, { "==", 6 }, { "!=", 6 }, { ">=", 6 }, { "<=", 6 }, { "<", 6 }, { ">", 6 }, { "+", 7 }, { "-", 7 }, - { "//", 8 }, { "/", 8 }, { "*", 8 }, { "%", 8 }, + { "/", 8 }, { "*", 8 }, { "%", 8 }, { "^", 10 }, { "::", 11 }, { ".", 14 }, diff --git a/anselme/parser/expression/secondary/infix/integer_division.lua b/anselme/parser/expression/secondary/infix/integer_division.lua deleted file mode 100644 index e7dc538..0000000 --- a/anselme/parser/expression/secondary/infix/integer_division.lua +++ /dev/null @@ -1,9 +0,0 @@ -local infix = require("anselme.parser.expression.secondary.infix.infix") - -local operator_priority = require("anselme.common").operator_priority - -return infix { - operator = "//", - identifier = "_//_", - priority = operator_priority["_//_"] -} diff --git a/anselme/parser/expression/secondary/init.lua b/anselme/parser/expression/secondary/init.lua index 3106aa3..a18d647 100644 --- a/anselme/parser/expression/secondary/init.lua +++ b/anselme/parser/expression/secondary/init.lua @@ -23,7 +23,6 @@ local secondaries = { r("infix.addition"), r("infix.substraction"), r("infix.multiplication"), - r("infix.integer_division"), r("infix.division"), r("infix.modulo"), r("infix.implicit_multiplication"), diff --git a/anselme/stdlib/number.lua b/anselme/stdlib/number.lua index f181497..fd99ca9 100644 --- a/anselme/stdlib/number.lua +++ b/anselme/stdlib/number.lua @@ -45,7 +45,7 @@ return { { "_*_", "(a::is number, b::is number)", function(state, a, b) return Number:new(a.number * b.number) end }, { "_/_", "(a::is number, b::is number)", function(state, a, b) return Number:new(a.number / b.number) end }, { - "_//_", "(a::is number, b::is number)", function(state, a, b) + "div", "(a::is number, b::is number)", function(state, a, b) local r = a.number / b.number if r < 0 then return Number:new(math.ceil(r)) diff --git a/doc/language.md b/doc/language.md index b2cc7f8..ed5aeda 100644 --- a/doc/language.md +++ b/doc/language.md @@ -58,7 +58,7 @@ List of operators and their precedence: 5: _&_ _|_ _:_ 6: _==_ _!=_ _>=_ _<=_ _<_ _>_ 7: _+_ _-_ -8: _//_ _/_ _*_ _%_ +8: _/_ _*_ _%_ 9: _implicit*_ 10: _^_ 11: _::_ !_ -_ +_ *_ %_ @@ -117,7 +117,7 @@ function(1, 2, 3) The operators described in this section are defined using regular Anselme functions and can be redefined or overloaded. For example, `1+1` is equivalent `_+_(1, 1)`. For a detailled description of what these operators do by default, look at the [standard library](standard_library.md) documentation. -`_+_`, `_-_`, `_*_`, `_/_`, `_//_`, `_%_`, `_^_` are intended to be used as addition, substraction, multiplication, division, integer division, modulo, and exponentiation respectively. +`_+_`, `_-_`, `_*_`, `_/_`, `_%_`, `_^_` are intended to be used as addition, substraction, multiplication, division, modulo, and exponentiation respectively. `-_` and `+_` are intended to be used as the negation and positive prefixes.