[antlr-interest] Verilog VCD Parser

Mark Volkmann r.mark.volkmann at gmail.com
Sun Feb 10 06:35:14 PST 2008


On Feb 10, 2008 8:33 AM, Mark Volkmann <r.mark.volkmann at gmail.com> wrote:
> On Feb 9, 2008 11:05 PM, Amal Khailtash <akhailtash at gmail.com> wrote:
> > Can someone please guide me to writing a grammar that can parse the
> > following:
> >
> >   $comment
> >     ANY CHARACTER HERE INCLUDING WHITESPACE
> >   $end
> >
> >   $version
> >     ANY CHARACTER HERE INCLUDING WHITESPACE
> >    $end
> >
> > I am having problem with the text between the two keywords.  Generally
> > whitespace is ignored, but not if it is between $commen/$end or
> > $version/$end.
>
> Here's a start, but it's not completely correct. I'll keep trying.
>
> grammar Verilog;
>
> script: block* EOF;
>
> block: comment | version;
>
> comment: '$comment' CONTENT '$end';
>
> version: '$version' CONTENT '$end';
>
> NEWLINE: ('\r'? '\n')+ { $channel = HIDDEN; };
>
> CONTENT
> //options { greedy = false; }
>   : ~('$')*
>   ;

Hey, this does work! I fell into that old trap of not selecting the
correct start rule in ANTLRWorks. The downside of my grammar is that
you can't have a '$' in the content of a comment or version.

-- 
R. Mark Volkmann
Object Computing, Inc.


More information about the antlr-interest mailing list