, ], (abc, def, ghi),...">

Is there a CPAN module for parsing nested parentheses?

Is there a CPAN module that can read a line like this:

"[[<asdf>, <foo>], (abc, def, ghi), ({'jkl'})]" 

... and disassemble it into some kind of tree structure that is easy to move and beautifully printed?

+6
perl cpan
source share
5 answers

I think you could build on top of Text :: Balanced , which will do a lot of hard work for you. However, you still need to build a tree structure.

+9
source share

Perl 5.10 regular expressions can handle balanced structures. See Section (?PARNO) (?-PARNO) (?+PARNO) (?R) (?0) in perlre .

+4
source share

Perl 6 will have built-in tools to support this. At the same time, Text :: Balanced (as Dave Rolski mentioned) is probably the module of choice. Please note that this was also written by Damian Conway (as expressed by Bill Carvin).

+2
source share

Damian Conway Parse :: RecDescent

I have not used this, but it is a good bet that the Perl module written by Damian Conway is worth using.

+1
source share

If the string is identical to the Data Dumper format, then it can be eval -returned to the original structure.

0
source share

All Articles