raganwald.com raganwald.com

Going Under the Hood with Balanced Parentheses

As we discussed in both Pattern Matching and Recursion, a popular programming “problem” is to determine whether a string of parentheses is “balanced:”1 Given a string that consists of open and closed parentheses, write a function that determines whether the parentheses in the string are balanced. “Balanced” parentheses means that each opening symbol has a corresponding closing symbol and the pairs of parentheses are...

raganwald.com raganwald.com

Recursive Descent Parsing and Parser Combinators

As we discussed in the previous essay, a popular programming “problem” is to determine whether a string of parentheses is “balanced:” Given a string that consists of open and closed parentheses, write a function that determines whether the parentheses in the string are balanced. “Balanced” parentheses means that each opening symbol has a corresponding closing symbol and the pairs of parentheses are properly nested. In...