MCPcopy Create free account
hub / github.com/Script-Hub-Org/Script-Hub / needsParentheses

Function needsParentheses

Rewrite-Parser.beta.js:3536–3555  ·  view source on GitHub ↗
(node, parentOperator)

Source from the content-addressed store, hash-verified

3534 }
3535
3536 function needsParentheses(node, parentOperator) {
3537 if (!parentOperator) {
3538 return false
3539 }
3540
3541 const currentPrecedence = LOGICAL_OPERATORS_PRECEDENCE[node.operator]
3542 const parentPrecedence = LOGICAL_OPERATORS_PRECEDENCE[parentOperator]
3543
3544 if (currentPrecedence === undefined) {
3545 return false
3546 }
3547
3548 if (currentPrecedence <= parentPrecedence) {
3549 return true
3550 }
3551 if (node.operator === 'NOT') {
3552 return true
3553 }
3554 return false
3555 }
3556
3557 function flattenChildren(children) {
3558 const result = []

Callers 1

traverseTreeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected