Migration to new build system.

* sen moved and checked
This commit is contained in:
Mateusz Hromada 2009-06-09 01:46:50 +02:00
parent 12743b9e8c
commit 1e551bdd1b
4 changed files with 104 additions and 95 deletions

View File

@ -1,12 +0,0 @@
sen: sen.l
flex -osen.c sen.l
cc -O3 -o sen sen.c -lfl
copy:
ifdef UTT_BIN_DIR
cp sen ${UTT_BIN_DIR}
endif
clean:
rm sen.c sen

View File

@ -1,80 +0,0 @@
%{
int pos=0,len=0;
void set_position();
%}
ul [A-Z¡ÆÊ£ÑÓ¦¯¬]
ll [a-z±æê³ñ󶿼]
l ul|ll
n [0-9]+
s [ \t]+
ab1 (mgr|in¿|prof|hab|doc|dyr|kier|zast)
ab2 (ul|pl|al)
abrv (ab1|ab2)
SEG .*\n
N {n}{s}{n}{s}N{s}.*\n
S {n}{s}{n}{s}S{s}.*\n
P {n}{s}{n}{s}P{s}.*\n
W {n}{s}{n}{s}W{s}.*\n
UL {n}{s}{n}{s}W{s}{ul}.*\n
Cap {n}{s}{n}{s}W{s}{ul}{ll}*.*\n
POINT {n}{s}{n}{s}P{s}\.({s}.*)?\n
QMARK {n}{s}{n}{s}P{s}\?({s}.*)?\n
EXCL {n}{s}{n}{s}P{s}\!({s}.*)?\n
DASH {n}{s}{n}{s}P{s}\-({s}.*)?\n
POINTS {POINT}+
ABRV {n}{s}{n}{s}W{s}{abrv}({s}.*)?\n
EOS {POINT}|{POINTS}|{QMARK}|{EXCL}
%%
{N}({POINT}{N})+ ECHO; set_position();
({UL}{POINT}{S}?)+{Cap} ECHO; set_position();
{ABRV}{POINT} ECHO; set_position();
{P}/{S}{DASH} ECHO; set_position(); print_EOS();
{EOS}/{S}({Cap}|{P}|{N}) ECHO; set_position(); print_EOS();
.* ECHO; set_position();
<<EOF>> printf("%04d 00 EOS *\n",pos+len); exit(1);
%%
int main()
{
printf("0000 00 BOS *\n");
yylex();
}
int yywrap()
{
return 1;
}
void set_position()
{
char *lastseg, *tmp;
yytext[yyleng-1]='\0';
if(tmp=strrchr(yytext,'\n'))
lastseg=tmp+1;
else
lastseg=yytext;
sscanf(lastseg,"%d %d", &pos, &len);
yytext[yyleng-1]='\n';
}
int print_EOS()
{
printf("%04d 00 EOS *\n%04d 00 BOS *\n",pos+len,pos+len);
}

View File

@ -42,13 +42,16 @@ ALL_FFLAGS = -t \$(FFLAGS)
VPATH = ./src
PROGRAMS = tok
PROGRAMS = tok sen
TOK_OBJ_FILES = tok.o tok_cmdline.o
TOK_FLEX_FILES = tok.l
TOK_GGO_FILES = tok_cmdline.ggo
tok.o: tok_cmdline.h
SEN_OBJ_FILES = sen.o
SEN_FLEX_FILES = sen.l
CONFIG_FILES = src/config.h Makefile
.SUFFIXES:
@ -58,6 +61,8 @@ CONFIG_FILES = src/config.h Makefile
.INTERMEDIATE: \$(patsubst %.ggo,%.c,\$(TOK_GGO_FILES))
.INTERMEDIATE: \$(patsubst %.ggo,%.h,\$(TOK_GGO_FILES))
.INTERMEDIATE: \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES))
.PHONY: all
all: \$(PROGRAMS)
@ -79,6 +84,7 @@ clean:
\$(RM) \$(patsubst %.l,%.c,\$(TOK_FLEX_FILES))
\$(RM) \$(patsubst %.ggo,%.c,\$(TOK_GGO_FILES))
\$(RM) \$(patsubst %.ggo,%.h,\$(TOK_GGO_FILES))
\$(RM) \$(patsubst %.l,%.c,\$(SEN_FLEX_FILES))
.PHONY: distclean
distclean: clean
@ -99,10 +105,10 @@ uninstall:
\$(FLEX) -t \$< > \$@
%.c: %.ggo
gengetopt --input $< --file-name \$(patsubst %.c,%,\$@) --conf-parser
gengetopt --input $< --file-name \$(basename \$@) --conf-parser
%.h: %.ggo
gengetopt --input $< --file-name \$(patsubst %.h,%,\$@) --conf-parser
gengetopt --input $< --file-name \$(basename \$@) --conf-parser
%: %.o
\$(CC) \$? -o \$@ \$(ALL_LDFLAGS) \$(ALL_CFLAGS) \$(ALL_LDLIBS)

95
src/sen.l Normal file
View File

@ -0,0 +1,95 @@
%{
void print_EOS(void);
void set_position(void);
int pos=0;
int len=0;
%}
ul [A-Z¡ÆÊ£ÑÓ¦¯¬]
ll [a-z±æê³ñ󶿼]
l ul|ll
n [0-9]+
s [ \t]+
ab1 (mgr|in¿|prof|hab|doc|dyr|kier|zast)
ab2 (ul|pl|al)
abrv (ab1|ab2)
SEG .*\n
N {n}{s}{n}{s}N{s}.*\n
S {n}{s}{n}{s}S{s}.*\n
P {n}{s}{n}{s}P{s}.*\n
W {n}{s}{n}{s}W{s}.*\n
UL {n}{s}{n}{s}W{s}{ul}.*\n
Cap {n}{s}{n}{s}W{s}{ul}{ll}*.*\n
POINT {n}{s}{n}{s}P{s}\.({s}.*)?\n
QMARK {n}{s}{n}{s}P{s}\?({s}.*)?\n
EXCL {n}{s}{n}{s}P{s}\!({s}.*)?\n
DASH {n}{s}{n}{s}P{s}\-({s}.*)?\n
POINTS {POINT}+
ABRV {n}{s}{n}{s}W{s}{abrv}({s}.*)?\n
EOS {POINT}|{POINTS}|{QMARK}|{EXCL}
%%
{N}({POINT}{N})+ { ECHO; set_position(); }
({UL}{POINT}{S}?)+{Cap} { ECHO; set_position(); }
{ABRV}{POINT} { ECHO; set_position(); }
{P}/{S}{DASH} { ECHO; set_position(); print_EOS(); }
{EOS}/{S}({Cap}|{P}|{N}) { ECHO; set_position(); print_EOS(); }
.* { ECHO; set_position(); }
<<EOF>> { printf("%04d 00 EOS *\n",pos+len); exit(1); }
%%
int main()
{
printf("0000 00 BOS *\n");
yylex();
return 0;
}
int yywrap()
{
return 1;
}
void set_position()
{
char *lastseg;
char *tmp;
yytext[yyleng-1] = '\0';
tmp = strrchr(yytext, '\n');
if( tmp )
{
lastseg = tmp + 1;
}
else
{
lastseg = yytext;
}
sscanf(lastseg, "%d %d", &pos, &len);
yytext[yyleng-1] = '\n';
}
void print_EOS()
{
printf("%04d 00 EOS *\n%04d 00 BOS *\n", pos+len, pos+len);
}