Duh, I'm spacing out.
 
I wrote a parser using Parse::RecDescent that
parses verilog. Verilog is C-like but for hardware
development. At the very least, you could use
it to benchmark how fast it would parse your code.
 
I think I include some verilog samples and a 
benchmarking test to tell you how many lines
you're parsing a second or minute. If it runs
fast enough on your system, then that at least
proves you could use parse recdescent to 
act as your parser.
 
If you're lucky, you might be able to use a bunch
of my verilog rules to parse your C-like language.
Verilog is a lot like C, but there is a superset
of the language for handling the parallel nature
of hardware. But it has expressions and conditionals
and case statements and for loops and C stuff like
that too. So you could probably use that as
a starting point for your grammar.
 
I believe I implemented the entire verilog grammar.
It was something like a thouand or maybe two thousand
rules in Parse RecDescent. Or maybe I'm thinking
of the VHDL grammar I wrote. I forget.
 
http://search.cpan.org/~gslondon/Hardware-Verilog-Parser-0.13/Parser.pm
 
The file that contains the actual grammar is here
http://search.cpan.org/src/GSLONDON/Hardware-Verilog-Parser-0.13/generate_precompiled_parser.pl
 
 
Greg
 

________________________________

From: [EMAIL PROTECTED] on behalf of Ted Zlatanov
Sent: Mon 6/26/2006 1:45 PM
To: David Cantrell
Cc: Boston Perl Mongers
Subject: Re: [Boston.pm] Parser for C-like language?



On 23 Jun 2006, [EMAIL PROTECTED] wrote:

On Fri, Jun 23, 2006 at 09:23:09AM -0400, Ted Zlatanov wrote: > On 23 Jun 2006, 
[EMAIL PROTECTED] wrote:
>>>> Wasn't there a C grammer for Parse::RecDescent ?
>>> Not that worked.  Damian has acknowledged elsewhere that it shouldn't
>>> have been included.
>> It works for simple cases, and may be adequate for the OP's needs.  I
>> would recommend P::RD, because its grammar definitions are pretty
>> similar to the Perl 6 grammar definitions (it will matter, some day),
>> and because it's pretty good in general.  About the only thing that's
>> hard about it is parsing the error messages, which takes practice.
>
> I've tried P::RD.  I didn't like it at all.  It seemed to take an awful
> lot of work to define a very simple language ...

That hasn't been my experience.

> ... and I was not impressed by the documentation.
> Next time I need a parser I'll try Parse::Yapp.

I actually found Parse::Yapp's documentation much worse.  P::RD has a
lot of good docs and a FAQ.  While it has shortcomings (speed is a
problem for a lot of people, though for me it hasn't been too bad)
documentation is not one of them.

Ted

_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


 
_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to