Home | History | Annotate | Download | only in css
      1 #! /usr/bin/perl
      2 #
      3 #   This file is part of the WebKit project
      4 #
      5 #   Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
      6 #
      7 #   This library is free software; you can redistribute it and/or
      8 #   modify it under the terms of the GNU Library General Public
      9 #   License as published by the Free Software Foundation; either
     10 #   version 2 of the License, or (at your option) any later version.
     11 #
     12 #   This library is distributed in the hope that it will be useful,
     13 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15 #   Library General Public License for more details.
     16 #
     17 #   You should have received a copy of the GNU Library General Public License
     18 #   along with this library; see the file COPYING.LIB.  If not, write to
     19 #   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20 #   Boston, MA 02110-1301, USA.
     21 use strict;
     22 use warnings;
     23 
     24 use File::Basename;
     25 use File::Spec;
     26 use Getopt::Long;
     27 
     28 my $outputDir = ".";
     29 
     30 GetOptions(
     31     'outputDir=s' => \$outputDir,
     32 );
     33 
     34 my $grammarFilePath = $ARGV[0];
     35 my $grammarIncludesFilePath = @ARGV > 0 ? $ARGV[1] : "";
     36 
     37 my ($filename, $basePath, $suffix) = fileparse($grammarFilePath, (".y", ".y.in"));
     38 
     39 my $grammarFileOutPath = File::Spec->join($outputDir, "$filename.y");
     40 if (!$grammarIncludesFilePath) {
     41     $grammarIncludesFilePath = "${basePath}${filename}.y.includes";
     42 }
     43 
     44 open GRAMMAR, ">$grammarFileOutPath" or die;
     45 open INCLUDES, "<$grammarIncludesFilePath" or die;
     46 
     47 while (<INCLUDES>) {
     48     print GRAMMAR;
     49 }
     50 
     51 open GRAMMARFILE, "<$grammarFilePath" or die;
     52 while (<GRAMMARFILE>) {
     53     print GRAMMAR;
     54 }
     55 
     56 close GRAMMAR;
     57 
     58 $grammarFilePath = $grammarFileOutPath;
     59