in reply to Parsing a file with parentheses to build a hash
It looks like a simple grammar so I'd use a recursive descent parser, Parse::RecDescent for one.
This is just a example off the top of my head and completely untested.
start : '(' section(s) ')' section : '(' id entry(s) ')' entry : '(' section | keypair ')' keypair : '(' key value ')'
Update
Looking at this again, entry shouldn't have those terminal brackets -- it would only parse sections like '(id ((key value))', so just
entry : section | keypair
(I did say this was just off the top of my head !)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing a file with parentheses to build a hash
by xcellsior (Novice) on Nov 13, 2014 at 23:49 UTC | |
by RichardK (Parson) on Nov 14, 2014 at 14:54 UTC | |
by toolic (Bishop) on Nov 14, 2014 at 15:15 UTC | |
by xcellsior (Novice) on Nov 14, 2014 at 18:38 UTC | |
|
Re^2: Parsing a file with parentheses to build a hash
by xcellsior (Novice) on Nov 13, 2014 at 23:10 UTC | |
|
Re^2: Parsing a file with parentheses to build a hash
by xcellsior (Novice) on Nov 18, 2014 at 13:40 UTC | |
by RichardK (Parson) on Nov 18, 2014 at 14:30 UTC |