File: flexfix

package info (click to toggle)
libverilog-perl 3.482-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,728 kB
  • sloc: perl: 8,685; yacc: 3,387; cpp: 2,266; lex: 1,502; makefile: 8; fortran: 3
file content (39 lines) | stat: -rwxr-xr-x 1,815 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl -w
######################################################################
#
# Copyright 2002-2024 by Wilson Snyder.  This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
######################################################################

# DESCRIPTION: Edits flex output to get around various broken flex issues.

my $Opt_Prefix = $ARGV[0] or die "%Error: No prefix specified,";

foreach my $line (<STDIN>) {
    # Fix flex 2.6.0 warning
    $line =~ s/ number_to_move == YY_MORE_ADJ / (int)number_to_move == (int)YY_MORE_ADJ /;
    # Fix flex 2.5.4 namespace omission
    $line =~ s/^class istream;/\#include <iostream>\nusing namespace std;\n/;
    # Fix flex 2.5.31 redefinition
    $line =~ s!(\#define\s+yyFlexLexer\s+yyFlexLexer)!//flexfix: $1!g;
    # Fix flex 2.5.1 yytext_ptr undef
    $line =~ s!(\#undef\s+yytext_ptr)!//flexfix: $1!g;
    # Fix flex 2.5.4 and GCC 4.1.0 warn_unused_result
    $line =~ s!\(void\) *fwrite\((.*)\)!if (fwrite($1)) {}!g;
    # Fix flex 2.5.33 and GCC 4.1.2 "warning: comparison between signed and unsigned integer expressions" in YY_INPUT
    $line =~ s!for \( n = 0; n < max_size && !for ( n = 0; ((size_t)n < (size_t)max_size) && !g;
    # Fix flex 2.5.4 and GCC 4.0.2 under FLEX_DEBUG
    $line =~ s!--accepting rule at line %d !--accepting rule at line %ld !g;
    # Fix compiler warning filenames
    $line =~ s!(#line \d+ ".*)_pretmp!$1!;

    print "$line";
}