source: app/src/kot/kot @ 25ae32e

help
Last change on this file since 25ae32e was 25ae32e, checked in by obrebski <obrebski@…>, 18 years ago

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@4 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

  • Property mode set to 100755
File size: 1.9 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use Getopt::Long;
5
6my $help=0;
7my $gap_fill="\n-----\n";
8my $spaces=0;
9
10my $configfile1="../../conf/kot.conf";
11my $configfile2="../conf/kot.conf";
12
13#read configuration files###########################
14my $file;
15foreach $file ($configfile1, $configfile2){
16  if(open(CONFIG, $file)){
17        while (<CONFIG>) {
18                chomp;                 
19                s/#.*//;               
20                s/^\s+//;               
21                s/\s+$//;               
22                next unless length;     
23                my ($name, $value) = split(/\s*=\s*/, $_, 2);
24                if(($name eq "gap-fill")or($name eq "g")){
25                        $gap_fill=$value;
26                }
27                elsif(($name eq "spaces")or($name eq "s")){
28                        $spaces=1;
29                }
30                elsif(($name eq "help")or($name eq "h")){
31                        $help=1;
32                }
33       
34        } 
35        close CONFIG;
36  }
37}
38#########################################################
39
40GetOptions("gap-fill|g=s" => \$gap_fill,
41           "spaces|r" => \$spaces,
42           "help|h" => \$help);
43
44if($help)
45{
46    print <<'END'
47Usage: ser [OPTIONS] [file ..]
48
49Options:
50   --gap-fill -g                  Help.
51   --spaces -r                   
52   --define=FILE                  Read macrodefinitions from FILE.
53   --flex-template=FILE           Read flex code template from FILE.
54   --only-matching -m             Print only fragments matching PATTERN.
55   --flex                         Print only the generated flex code and exit.
56END
57;
58    exit 0;
59}
60
61
62$gap_fill =~ s/\\t/\t/g;
63$gap_fill =~ s/\\n/\n/g;
64$gap_fill =~ s/\\r/\r/g;
65$gap_fill =~ s/\\f/\f/g;
66
67my $prevend=-1;
68my $count=0;
69
70while(<>)
71{
72    my ($start,$len,$type,$form) = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(\S+)/;
73   
74    if($start > $prevend)
75    {
76        print $gap_fill unless $count++ == 0;
77    }
78
79    $prevend=$start+$len;
80   
81    next if $len==0;# || $form eq "*";
82
83    $form =~ s/\\\*/*/g;
84
85    if($type eq 'S' && ! $spaces)
86    {
87        $form =~ s/_/ /g;
88        $form =~ s/\\t/\t/g;
89        $form =~ s/\\n/\n/g;
90        $form =~ s/\\r/\r/g;
91        $form =~ s/\\f/\f/g;
92    }
93
94    print $form;
95}
96
97#print $gap_fill;
98
99# print "\n";
Note: See TracBrowser for help on using the repository browser.