[antlr-interest] Verilog VCD Parser

Gavin Lambert antlr at mirality.co.nz
Mon Feb 11 03:51:45 PST 2008


At 05:44 11/02/2008, Amal Khailtash wrote:

>That's the problem.  There is no restriction on comment/version 
>content.  Especially version might have cvs keywords, say 
>$revision, ...
[...]
> > CONTENT
> > //options { greedy = false; }
> >   : ~('$')*
> >   ;

Well, there's probably a cleaner way to do it, and bear in mind 
that I haven't actually tested this, but something along these 
lines might work:

CONTENT
   :  (  ~'$'
      |  '$'
         (  ~'e'
         |  'e'
            (  ~'n'
            |  'n' ~'d'
            )
         )
      )*
   ;

Yet another alternative: first, replace the '$end' literal in the 
comment and version rules with END, change the CONTENT in each to 
CONTENT*, then add these rules:

fragment END: '$end';

CONTENT
   :  '$' ( ('end') => 'end' { $type = END; } )?
   |  (~'$')*
   ;

This is possibly less ideal, since it will end up generating 
multiple CONTENT tokens if there are embedded $s, but it should 
end up matching properly.  I think.  (Again, untested.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080212/cce661e4/attachment.html 
-------------- next part --------------


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.20.2/1270 - Release Date: 10/02/2008 12:21


More information about the antlr-interest mailing list