to operator priority

higher than logical operators, lower than all other operators
This commit is contained in:
Umur Ozkul 2022-10-03 16:16:00 +02:00
parent 5f5334ed8e
commit 54cbcea5d6

View File

@ -98,12 +98,20 @@ equality
equalityOp "operator" = '=='/'!='
relational
= left:additive _ operator:relationalOp _nl right:additive
= left:credibleInterval _ operator:relationalOp _nl right:credibleInterval
{ return h.makeFunctionCall(h.toFunction[operator], [left, right])}
/ additive
/ credibleInterval
relationalOp "operator" = '<='/'<'/'>='/'>'
credibleInterval
= head:additive tail:(__ operator:credibleIntervalOp __nl arg:additive {return {operator: operator, right: arg}})*
{ return tail.reduce(function(result, element) {
return h.makeFunctionCall(h.toFunction[element.operator], [result, element.right])
}, head)}
credibleIntervalOp "operator" = 'to'
additive
= head:multiplicative tail:(_ operator:additiveOp _nl arg:multiplicative {return {operator: operator, right: arg}})*
{ return tail.reduce(function(result, element) {
@ -121,21 +129,13 @@ multiplicative
multiplicativeOp "operator" = '*' / '/' / '.*' / './'
power
= head:credibleInterval tail:(_ operator:powerOp _nl arg:credibleInterval {return {operator: operator, right: arg}})*
= head:chainFunctionCall tail:(_ operator:powerOp _nl arg:chainFunctionCall {return {operator: operator, right: arg}})*
{ return tail.reduce(function(result, element) {
return h.makeFunctionCall(h.toFunction[element.operator], [result, element.right])
}, head)}
powerOp "operator" = '^' / '.^'
credibleInterval
= head:chainFunctionCall tail:(__ operator:credibleIntervalOp __nl arg:chainFunctionCall {return {operator: operator, right: arg}})*
{ return tail.reduce(function(result, element) {
return h.makeFunctionCall(h.toFunction[element.operator], [result, element.right])
}, head)}
credibleIntervalOp "operator" = 'to'
chainFunctionCall
= head:unary tail:(_ ('->'/'|>') _nl chained:chainedFunction {return chained})*
{ return tail.reduce(function(result, element) {