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

Function needsParentheses

Rewrite-Parser.js:3124–3143  ·  view source on GitHub ↗
(node, parentOperator)

Source from the content-addressed store, hash-verified

3122 }
3123
3124 function needsParentheses(node, parentOperator) {
3125 if (!parentOperator) {
3126 return false
3127 }
3128
3129 const currentPrecedence = LOGICAL_OPERATORS_PRECEDENCE[node.operator]
3130 const parentPrecedence = LOGICAL_OPERATORS_PRECEDENCE[parentOperator]
3131
3132 if (currentPrecedence === undefined) {
3133 return false
3134 }
3135
3136 if (currentPrecedence <= parentPrecedence) {
3137 return true
3138 }
3139 if (node.operator === 'NOT') {
3140 return true
3141 }
3142 return false
3143 }
3144
3145 function flattenChildren(children) {
3146 const result = []

Callers 1

traverseTreeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected