Changeset 754d2a3 for app/src/ser
- Timestamp:
- 03/11/08 14:56:13 (17 years ago)
- Branches:
- master, help
- Children:
- 52bccea
- Parents:
- 25ae32e
- git-author:
- obrebski <obrebski@…> (03/11/08 14:56:13)
- git-committer:
- obrebski <obrebski@…> (03/11/08 14:56:13)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/src/ser/ser
r25ae32e r754d2a3 7 7 use strict; 8 8 use Getopt::Long; 9 use File::Temp; 9 10 10 my $SHARE_DIR="/usr/share/utt"; 11 my $USER_DIR="$ENV{HOME}/.utt/share"; 11 my $LIB_DIR="/usr/local/lib/utt"; 12 13 my $systemconfigfile='/usr/local/etc/utt/ser.conf'; 14 my $userconfigfile="$ENV{'HOME'}/.utt/ser.conf"; 12 15 13 16 #use lib "$ENV{HOME}/.utt/lib/perl"; … … 25 28 my $morfield='lem'; 26 29 27 my $configfile1="../../conf/ser.conf";28 my $configfile2="../conf/ser.conf";29 30 30 #read configuration files########################### 31 31 my $file; 32 foreach $file ($ configfile1, $configfile2){32 foreach $file ($systemconfigfile, $userconfigfile){ 33 33 if(open(CONFIG, $file)){ 34 34 while (<CONFIG>) { … … 51 51 $no_markers=1; 52 52 } 53 elsif($name eq " define"){53 elsif($name eq "macros"){ 54 54 $macros=$value; 55 55 } … … 74 74 "only-matching|m" => \$only_matching, 75 75 "no-markers|M" => \$no_markers, 76 " define=s" => \$macros,76 "macros=s" => \$macros, 77 77 "flex-template=s" => \$flextemplate, 78 78 "flex" => \$flex, … … 88 88 --pattern=PATTERN -e PATTERN Search pattern. 89 89 --morph=STRING Field containing morphological information (default 'lem'). 90 -- define=FILE Read macrodefinitions from FILE.90 --macros=FILE Read macrodefinitions from FILE. 91 91 --flex-template=FILE Read flex code template from FILE. 92 92 --only-matching -m Print only fragments matching PATTERN. … … 102 102 die("$0: flex template file not found") unless 103 103 $flextemplate or 104 -e "$USER_DIR/ser.l.template" and $flextemplate="$USER_DIR/ser.l.template" or 105 -e "$SHARE_DIR/ser.l.template" and $flextemplate="$SHARE_DIR/ser.l.template"; 104 -e "$LIB_DIR/ser.l.template" and $flextemplate="$LIB_DIR/ser.l.template"; 106 105 107 106 die("$0: macro file not found") unless 108 107 $macros or 109 -e "$USER_DIR/terms.m4" and $macros="$USER_DIR/terms.m4" or 110 -e "$SHARE_DIR/terms.m4" and $macros="$SHARE_DIR/terms.m4"; 108 -e "$LIB_DIR/terms.m4" and $macros="$LIB_DIR/terms.m4"; 111 109 112 110 … … 120 118 # discarding spaces 121 119 $pattern =~ s/\s+/\\`'/g; #` 120 122 121 123 122 my $flexpattern = `echo \"$pattern\" | m4 --define=ENDOFSEGMENT=\\\\n --define=MORFIELD=$morfield $macros - 2>/dev/null`; … … 153 152 # docelowo posrednie pliki powinny byc w jakims tempie !!! 154 153 155 system "m4 \"--define=PATTERN=$flexpattern\" \"--define=DEFAULTACTION=$defaultaction\" $flextemplate > $USER_DIR/ser.l"; 154 (undef, my $tmpfile_l) = File::Temp::tempfile(SUFFIX=>'.l'); 155 (undef, my $tmpfile_c) = File::Temp::tempfile(SUFFIX=>'.c'); 156 (undef, my $tmpfile_x) = File::Temp::tempfile(); 157 158 159 system "m4 \"--define=PATTERN=$flexpattern\" \"--define=DEFAULTACTION=$defaultaction\" $flextemplate > $tmpfile_l"; 156 160 157 161 if($flex) 158 162 { 159 system "cat $ USER_DIR/ser.l";163 system "cat $tmpfile_l"; 160 164 exit 0; 161 165 } 162 166 163 system "flex -o$ USER_DIR/ser.c $USER_DIR/ser.l";164 system "cc -O3 -o $ USER_DIR/ser.executable $USER_DIR/ser.c -lfl";165 system "$ USER_DIR/ser.executable";167 system "flex -o$tmpfile_c $tmpfile_l"; 168 system "cc -O3 -o $tmpfile_x $tmpfile_c -lfl"; 169 system "$tmpfile_x"; 166 170 167 system "rm -f $ USER_DIR/ser.{l,c,executable}";171 system "rm -f $tmpfile_l $tmpfile_c $tmpfile_x"; 168 172
Note: See TracChangeset
for help on using the changeset viewer.