[Question]
  [
[Picolisp](https://picolisp.com) has a feature called "super parentheses":
> 
> Brackets ('[' and ']') can be used as super parentheses. A closing bracket will match [all parentheses to and including] the innermost opening bracket, or [if there are no unmatched opening brackets] all currently open parentheses. [src](http://www.software-lab.de/doc/ref.html)
> 
> 
> 
Taking a string containing only the characters `[]()` (and newline if your language requires it), remove all closing brackets `[]` and replace them with the corresponding parentheses. A `[` is replaced with a `(`, but your program will not have to handle a `[` or `(` without a matching `]` or `)`. Output may contain trailing newlines.
`]` matches as many open parens as possible until it hits a `[` at which point it has to stop [--DJMcMayhem](https://codegolf.meta.stackexchange.com/questions/2140/sandbox-for-proposed-challenges/22421#comment74153_22421)
## Examples
```
((((] -> (((())))
(([()(()])) -> (((()(()))))
) or ( or ] or [) or ([(]  -> invalid, do not need to handle
(] -> ()
((](] -> (())()
[] -> ()
[(] -> (())
[[()(]] -> ((()()))
((][(] -> (())(())
(([((](] -> ((((()))()))
```
---
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest code per language wins.
  
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 26 bytes
```
ＦＳ≡ι)⊟υ]Ｗ∧υ⊟υκ«(Ｆ⁼ι[⊞υω⊞υ)
```
[Try it online!](https://tio.run/##NY6xDoMwEENn@IpTJkeCH6BThw7dkDoihihAEzUCSpIyVHx7erR0tP3OZ23UoiflUhqmhXAd5xhuYbHjHVKSX23QhmAlvXOtfE9CiopqzgPqaUaU8nQELQersa4nnMcOsaADkAf/YLTrBxVdqLgu@7kCgv3s@/3yjMp52IJEI/a76M1etO7EX/ACllu@pQQ0QIs2lS/3AQ "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
ＦＳ≡ι
```
Switch over each character of the input.
```
)⊟υ
```
If it's a `)` then pop and print the top of the stack (which should always be a `)` at this point).
```
]Ｗ∧υ⊟υκ
```
If it's a `]` then pop and print the top of the stack until it becomes empty or an empty string was popped.
```
«(Ｆ⁼ι[⊞υω⊞υ)
```
Otherwise, print a `(`, push an empty string to the stack if it was a `[`, and push a `)` to the stack.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~117~~ 115 bytes
-2 thanks to [ovs](https://codegolf.stackexchange.com/users/64121) (use mod 8 in place of mod 6 allowing the bitwise-OR in place of exponentiation; remove a space from `5!=x or` with `x!=5or`.)
My golf of [hyper-neutrino](https://codegolf.stackexchange.com/users/68942/hyper-neutrino)'s [Python 3 answer](https://codegolf.stackexchange.com/a/229189/53748).
```
k=[0]
o=""
for c in input():x=ord(c)%8;o+="() ( )"[x]*(x<5or k.pop());k=[0]+k+[1]*(x==3);k[-1]+=x<3and-x|1
print(o)
```
**[Try it online!](https://tio.run/##LU7RCsIwDHzvV5SBLLFMLEOQbf2S2gfpKhuTtoyJFfz3mg6PIyF3R5L42abg22zD6LjidV3f8qL02bCgqoo9wsotnz0xvjbALqmwjmDxcO2DUBUgB46VTuYIabhQejnFEAGx37eIRWhZPKVaknQjjVBpaO9@bNJXsrjOfoOAmQ7rjlzG3tP8dFx2jBNcchbKb5iBYBiABgRAg8j20VDVxNKKZXZR/6PF/gE "Python 3 – Try It Online")**
Remaps `'(', ')', '[', ']'` to the integers `0, 1, 3, 5` (`x`) with `x=ord(c)%8` then uses this for the decision making process to save quotes.
Inlines all the decision-making to avoid newlines, tabs and `if-elif-else` syntax.
Gets the character to output for the current input character by using `x` to index into `"() ( )"`.
When the current character is one of `"()"` we need to add or subtract one, respectively, from the last entry in the counts list, `k`. To do so we check if the character is one of `"()"` we use `x<3` (`False`, the value for `'['` and `']'` is equivalent to `0`) and logical-AND that with `-x` bitwise-OR with `1` (`-x|1`) translating the `0` of `(` to `1` and the `1` if `)` to `-1`. Thus we can add `x<3and-x|1`.
[Answer]
# [PicoLisp](http://picolisp.com/), 211 bytes
```
(de f(x k)[or k(set'k(0][set'a(car x][set'b(cdr x](if x(cond[(="("a)(prin a)(f b(cons(+(car k)1)(cdr k][(=")"a)(prin a)(f b(cons(-(car k)1)(cdr k][(="["a)(prin"(")(f b(cons 1 k](1[prin(need(car k)")"](f b(cdr k]
```
[Try it online!](https://tio.run/##bYxBDsIgFET3nuKHjfNjTOQAnoSwoEAjwRRSXODpEVqNm65mJvNmcrDpGUpuDc7TjEqRVVopovjXOeKm1TAG1qxU9zDBuhEQZqqwaXEKdwFhGHkNC3WdaRpFwWUbRpa8jaIeKB@i1yNU/dD@/2dJ9hpSjQKL9@477c96h7aD1j3sI2USgAI0tGA@YXp7bh8 "PicoLisp – Try It Online")
-1 byte thanks to Wzl
First time using picolisp, so it's probably very badly golfed.
[Answer]
# [Python 3](https://docs.python.org/3/), 139 bytes
```
o=""
k=[0]
for c in input():
	if"["<c:o+=")"*k.pop();k=[0]+k
	elif"Z"<c:k+=[1];o+="("
	elif")">c:k[-1]+=1;o+=c
	else:k[-1]-=1;o+=c
print(o)
```
[Try it online!](https://tio.run/##NcrLCsMgEIXhdXyKMKuZSkqlu6T2QSKuJKFicSSxiz690V7grM7/pXd@cLyWwhpABG0uVqy89a73sS69MtIoOr@CgZsbWWogOIVz4oQ0fbwMolueVcxNBKmNslODCL9AcK/BDMpKrVpyLezL9xv@X9p8zMhUCqJFOgA "Python 3 – Try It Online")
-4 bytes thanks to caird coinheringaahing  
bugfix thanks to Jonathan Allan
trivial attempt, will try to golf it down more later
[Answer]
# JavaScript (ES6), ~~96~~ 94 bytes
Expects an array of characters. Returns a string.
```
a=>a.map(c=>c>{}?')'.repeat(b.pop()):b.push(-~(c>')'?c='(':b.pop()-2*(c>'(')))&&c,b=[]).join``
```
[Try it online!](https://tio.run/##ZZBBTsMwEEX3OcUoi3oGJV6wDHKy4hSWpbrGoa1KbMVthYTgBEhsWMI9OE8vwBGCQ4iaUC8s6//3Pd/e6qMOpt34fd64O9vVotOi1PxBezSiNOXTc8WI8dZ6q/e44t55JCri4RDWmL@gKaNfGcGQFX92fn3Vy8iIaLEw2UpIRXzrNs1y2d3IBEBCinGpNBsOEaQUVDZaEimKKoojMDBTaAjPYmq8kWhqyAtUnsGJ2E9VYyfCf53UJDQP9n3Ps4fnXKSRZtUSlfDatbfarGM8ZGAfvSIQJRjXBLezfOfusbUBBNQoOedBUQa/guhhqIB9f72dPt7jzqAAdvp8jT/e/QA "JavaScript (Node.js) – Try It Online")
### Commented
```
a =>                // a[] = input
a.map(c =>          // for each character c in a[]:
  c > {} ?          //   if c is ']':
    ')'             //     use ')'
    .repeat(        //     and repeat it as many times as
      b.pop()       //     recorded in the last slot,
    )               //     which is removed from b[]
  :                 //   else:
    b.push(         //     push in b[]:
      -~(           //
        c > ')' ?   //       if c is '[':
          c = '('   //         update c to '(' and push 1 (a new slot)
        :           //       else
          b.pop()   //         update the last slot (it may be undefined):
          - 2 *     //           increment it if c is '('
          (c > '(') //           decrement it if c is ')'
      )             //
    )               //     end of push()
    && c,           //     yield c
  b = []            //   start with b[] = empty array
).join``            // end of map(); join everything
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 49 bytes
```
+`(^|\[)(((\()|(?<-4>\)))*)]
$.1$*($2$#4$*)$.1$*)
```
[Try it online!](https://tio.run/##LUs7CoAwFNt7DZ@QVBQUR9HRQ7RP6uDg4iCO3r22RQgJ@d3Hc157rLGG2ARsr3cE4MEXy9SOsydpqUa6XixkkGoUy@IYY5pCDeCQXlTSFKuJXUKWXGkJ3T/N9Qc "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
+`
```
Repeat until no more replacements can be made.
```
(^|\[)(((\()|(?<-4>\)))*)]
```
Starting at the beginning of the string or at a `[`, start counting `(`s, but subtract 1 for every `)`, until a `]` is reached.
```
$.1$*($2$#4$*)$.1$*)
```
Append `)`s according to the count of remaining `(`s, and if we started at a `[` then wrap the whole thing in `)`s (because the count of `(`s doesn't include the initial `[`).
[Answer]
# JavaScript (ES6), 96 bytes
```
f=s=>s>(s=s.replace(/.([()]*)]/,(_,m)=>'('+m+')'.repeat(3+m.length-2*m.split`)`.length)))?f(s):s
```
[Try it online!](https://tio.run/##TY/BbsMgEETv/gpu7MQ2kdpbI9xTv8JBNXJx4gqMZaxeon67C6FuijjszrydhU/9pUO/jPNaT/7DbIOMN8gmNBRkEIuZre4NHQW1BHWAOlb0XjnIhhMvXcnBE2T0Ss@lE9ZMl/VaPx2cCLMd1w7drwbgdaCAl7CdWFdQPIrVDUtF9BCVuCHWCvjTsxW9jCZI7WNA7NvdaB9y0aYgtaeDcrr6h9yxtPARl59xZzuxLqMj5C8QP08cwumZLJMNs7uc5jggBr@86f4a48aKGYUE3QrGej8Fb42w/kIDjVGXzFQslSi@cdp@AA "JavaScript (Node.js) – Try It Online")
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 46 bytes
```
L#aaR:`((\[|^)[()]*)]`{b.')X#b-2*(')Nb)R'['(}a
```
[Try it online!](https://tio.run/##K8gs@P/fRzkxMcgqQUMjJromTjNaQzNWSzM2oTpJT10zQjlJ10hLQ13TL0kzSD1aXaM28f///xoa0RoasRqxAA "Pip – Try It Online")
Algorithm:
* Find the first pair of square brackets with only parentheses between them (the opening bracket is optional if we're at the beginning of the string) using regex.
* Call the regex match minus the final bracket `b`. Replace the match (including the bracket) with:
	+ `b`,
	+ concatenated to a number of `)` equal to the length of `b` minus two times the number of closing parens in `b`,
	+ with `[` replaced with `(`
* Do that as many times as there are characters in the input (overkill, but gets the job done).
* Print the result.
---
Different algorithm, **also 46 bytes**:
```
Fca{l|:^0cLT0?@l+:v**A OccQ'[?lPU1&O'(O')XPOl}
```
[Try it online!](https://tio.run/##K8gs@P/fLTmxOqfGKs4g2SfEwN4hR9uqTEvLUcE/OTlQPdo@JyDUUM1fXcNfXTMiwD@n9v///xoa0RoasRqxAA "Pip – Try It Online")
Treating the list `l` as a stack, loop over each character in the input:
* If the stack is empty, put a 0 on it.
* If the character is a parenthesis, output it and increment/decrement the top of stack.
* If the character is an open square bracket, push a 1 to the stack and output an open parenthesis.
* If the character is a close bracket, pop the stack and output that many close parentheses.
[Answer]
# [Red](http://www.red-lang.org), ~~131~~ 119 bytes
-12 bytes thanks to @9214
```
func[a][do{s:[""""]}parse a[any["("(insert s/1")")|")"(take s/1)|
change"[""("(insert s copy")")| change"]"(take s)]]a]
```
[Try it online!](https://tio.run/##TU07DsIwDN17CstTMiDE2oFDsFoerDahFSKNkiJRUc4e0i/1YD@9j18wdbqZmriwJST7chUJU919YkmYh79eQjQgJG4gVKhaF03oIZ4vqFGPealeHmYi9FhUjbi7wZw9WKHq/DC7YdV5C2lm4WS7YKRqwLx9ACoAAFUexhWS0kpp1noldoE3SNvdiSnDfyMdvy05Jh9a11Nufy7VeLoi2Bkzpx8 "Red – Try It Online")
[Answer]
# Ruby 3.0.1, ~~123~~ ~~93~~ 92 bytes
Expects an array of characters and returns an array of characters
```
->x{*a=0
x.map{|c|c<?*?a[-1]+=(c<?)?1:-1):c<?]?(a<<0;c=?():c=?)*a.pop+(a[0]??):c*(*a=0));c}}
```
Old explanation:
```
-> x {
  a=[0] # this is the "stack"
  x.map do |c| # for each character `c` in input
    case c
    when ?( # ? creates a one-character string. Shorter than '('
      a[-1] += 1 # increment the top of the stack
    when ?)
      a[-1] -= 1 # decrement the top of the stack
    when ?[
      a << 0 # push a new element, 0, onto the stack
      c = ?( # 'output' an open paren in place of this character
    when ?]
      c = ?) * a.pop + # remove the last element of the array, and print that many closing parens.
      # however, we need to print another closing paren iff the stack isn't empty after we popped it.
        ( a[0] ? # ternary. a[0] is nil(falsy) if the array is empty, but 0 is truthy
          ?) : # if the array isn't empty, add another close parent
          # if the array is empty, we need to add nothing, but also add a 0 onto the array. 
          # `a<<0` is shorter, but evaluates to the array `a`.
          # `a[0]=0` evaluates to 0. 
          # any string * 0 is the empty string, so we use `c` since it's shorter than `""`
          c*(a[0]=0)
        )
    end
    c #last value evaluated is implicitly returned
  }
}
```
[Answer]
# [Vyxal](https://github.com/Lyxal/Vyxal) `ṠJs`, 32 bytes
```
0⅛ƛk(nc[k)k-ĿI¼+⅛|\[=[1⅛\(|\)¼⌊*
```
[Try it Online!](http://lyxal.pythonanywhere.com?flags=%E1%B9%A0Js&code=0%E2%85%9B%C6%9Bk%28nc%5Bk%29k-%C4%BFI%C2%BC%2B%E2%85%9B%7C%5C%5B%3D%5B1%E2%85%9B%5C%28%7C%5C%29%C2%BC%E2%8C%8A*&inputs=%5B%5D&header=&footer=) ([Try all testcases!](http://lyxal.pythonanywhere.com?flags=&code=0%E2%85%9B%C6%9Bk%28nc%5Bk%29k-%C4%BFI%C2%BC%2B%E2%85%9B%7C%5C%5B%3D%5B1%E2%85%9B%5C%28%7C%5C%29%C2%BC%E2%8C%8A*&inputs=%28%5D%20-%3E%20%28%29%0A%5B%5D%20-%3E%20%28%29%0A%5B%28%5D%20-%3E%20%28%28%29%29%0A%28%28%5D%28%5D%20-%3E%20%28%28%29%29%28%29%0A%28%28%28%28%5D%20-%3E%20%28%28%28%28%29%29%29%29%0A%28%28%5D%5B%28%5D%20-%3E%20%28%28%29%29%28%28%29%29%0A%5B%5B%28%29%28%5D%5D%20-%3E%20%28%28%28%29%28%29%29%29%0A%28%28%5B%28%28%5D%28%5D%20-%3E%20%28%28%28%28%28%29%29%29%28%29%29%29%0A%28%28%5B%28%29%28%28%29%5D%29%29%20-%3E%20%28%28%28%28%29%28%28%29%29%29%29%29&header=%40f%3A1%7C&footer=%5D%5D%3B%E2%81%8B%3B%0A%E2%96%A1%C6%9B%60%20-%3E%20%60%E2%82%AC%3Ah%3A%60%3A%5Ct%60%2B%E2%82%B4%40f%3B%C8%A7%E2%82%B4%60%20%3D%20%60%E2%82%B4t%2C))
```
0⅛ƛk(nc[k)k-ĿI¼+⅛|\[=[1⅛\(|\)¼⌊*   
 
0⅛                    Set the global array to [0]
  ƛ                     For each char n in input:
       [         |        If...
   k(nc                   n is in "()":
            Ŀ               Transliterate...
        k)                  n's index in ")("...
          k-                into [-1, 1]
             I              Cast to integer
              ¼+⅛           Add to top of global stack
|                         Otherwise...
    [    |                If...
 \[=                      n is '[':
     1⅛                     Push 1 to the global array
       \(                   Push "(" for output
         |                Otherwise:
              *             Repeat...
          \)                the string ")"...
            ¼⌊              pop(global_array) times
```
* `Ṡ` - treat `[]` as the string ``[]``, not an empty array
* `Js` - output properly
]