veripool / verilog-perl

Verilog parser, preprocessor, and related tools for the Verilog-Perl package
https://www.veripool.org/verilog-perl
Artistic License 2.0
121 stars 34 forks source link

extra text in 'number' callback of Verilog::Parser 3.408 #893

Closed veripoolbot closed 9 years ago

veripoolbot commented 9 years ago

Author Name: Greg Waters Original Redmine Issue: 893 from https://www.veripool.org Original Date: 2015-03-02


See bug description in this callback function for Verilog::Parser 3.408.

sub number { my $self = shift; my $tokens = $self->tokens; # I collect a vector of tokens $self->show1(SUB, qw(token), @) if $Debug;

 my $token = shift; # What token was parsed
 $self->unreadbackCat($token)  if $self->use_unreadback;

 #BUG in Verilog::Parser:
 # For "cntr_r <=#1 '0;" (or "1 'd0" or "1 ' 0"), it calls back with:
 # ("cntr_r", "<=", "#", "1 '0", "'0", ";").
 # Workaround it by splitting "1 '[0-9A-Za-z]" at space-tick-char
 # if preceding token was "#".

 if (substr($self->{_buffer}, $self->{_prevTokEnd} - 1, 1) eq "#"
     && $token =~ m!^(\d+)\s+\'\s*[0-9A-Za-z]!) {
     $token = $1;
 }
 #          number := real_number | integral_number
 # integral_number := (decimal,octal,binary,hex)_number
 $self->_storeToken('NUMBER', $token);

} Drop me a line if that's not clear. The issue is to scan a simple decimal integer, or a time with units, after "<= #". A number with size and radix prefix is not allowed in that context. Just FYI, no rush. --Greg

veripoolbot commented 9 years ago

Original Redmine Comment Author Name: Greg Waters Original Date: 2015-03-02T02:36:17Z


One more try to post with formatted code, not to be reflowed...

sub number {        # Default Internal callback
     my $self = shift;
     my $tokens = $self->tokens;
     $self->_show1(__SUB__, qw(token), @_)  if $Debug;
     my $token = shift; # What token was parsed
     $self->unreadbackCat($token)  if $self->use_unreadback;

     #BUG in Verilog::Parser:
     # For "cntr_r <=#1 '0;" (or "1 'd0" or "1 ' 0"), it calls back with:
     # ("cntr_r", "<=", "#", "1 '0", "'0", ";").
     # Workaround it by splitting "1 '[0-9A-Za-z]" at space-tick-char.

     if (substr($self->{_buffer}, $self->{_prevTokEnd} - 1, 1) eq "#"
         && $token =~ m!^(\d+)\s+\'\s*[0-9A-Za-z]!) {
         $token = $1;
     }
     #          number := real_number | integral_number
     # integral_number := (decimal,octal,binary,hex)_number
     $self->_storeToken('NUMBER', $token);
}
veripoolbot commented 9 years ago

Original Redmine Comment Author Name: Wilson Snyder (@wsnyder) Original Date: 2015-03-02T03:54:04Z


Thanks for the report, rather than your patch, fixed the parser, as the parser simply was issuing the callback with the wrong parameters.

Fixed in git towards 3.409. If you need a formal release let me know.

veripoolbot commented 9 years ago

Original Redmine Comment Author Name: Wilson Snyder (@wsnyder) Original Date: 2015-03-14T16:29:15Z


In 3.410.