spurperl has asked for the wisdom of the Perl Monks concerning the following question:
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:
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
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Parsing... possible w/o too much stress ?
by Corion (Patriarch) on Mar 19, 2003 at 13:40 UTC | |
by rob_au (Abbot) on Mar 19, 2003 at 14:06 UTC | |
by merlyn (Sage) on Mar 22, 2003 at 16:21 UTC | |
Re: Parsing... possible w/o too much stress ?
by broquaint (Abbot) on Mar 19, 2003 at 13:43 UTC | |
Re: Parsing... possible w/o too much stress ?
by hsmyers (Canon) on Mar 19, 2003 at 15:47 UTC | |
Re: Parsing... possible w/o too much stress ?
by BrowserUk (Patriarch) on Mar 19, 2003 at 16:39 UTC | |
by antifun (Sexton) on Mar 19, 2003 at 21:16 UTC | |
Re: Parsing... possible w/o too much stress ?
by Rudif (Hermit) on Mar 19, 2003 at 22:34 UTC | |
Re: Parsing... possible w/o too much stress ?
by Anonymous Monk on Mar 19, 2003 at 16:10 UTC | |
Re: Parsing... possible w/o too much stress ?
by I0 (Priest) on Mar 20, 2003 at 15:11 UTC |
Back to
Seekers of Perl Wisdom