Question

I gotta make a CFG and PDA for the grammar that has perfectly nested parentheses and brackets.

S -> [S]
S -> (S)
S -> SS
S -> Epsilon

Not sure if this is correct, or how to make the PDA from it?

Was it helpful?

Solution

take a look at Spirit. It's really worth a deep visit.

Otherwise, your grammar it's so simple that a recursive LL(1) parser should be easy to write.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top