Friend monks,
We have a certain internal language (a programming language, or more accurately a Hardware Description Language, like Verilog). There are full-fledged parsers for it (C + Lex + Yacc), but I have to do some simple preprocessing and wonder what is the easiest way to go...
Suppose I have some keyword, say "env", which is followed by a body within braces:
env
{
...
...
}
I want to rip the contents out (from the braces) into some string. Needless to say that there may be other "bodies", delimited by braces nested inside to an arbitrary level, so regexes aren't much of a help (a regex assuming just one level of nesting already looks very scary).
Thus my question: what is the
easiest way to handle it ? Use some Parser module from CPAN ? I don't need, and don't want to define the full grammar of this language - I just want what's inside the braces.
TIA
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.