%pointer
%s LIGATEX
%x KLAMMER GARNICHT
NN [ ,.;\n\t\r<-]
kon [b-df-hj-np-tv-z]
vok ([aeiou�]|(ä)|(\"a)|(ü)|(\"u)|(ö)|(\"o))
kss [bdfghklmnpqrstvwxz]
klein ([a-z��]|(ä)|(\"a)|(ü)|(\"u)|(ö)|(\"o)|�|(\"s)|(ß))
grosz ([A-Z���]|(Ä)|(\"A)|(Ü)|(\"U)|(Ö)|(\"O))
endung (e|(en)|(es)|(em)|(er)|(est)|(este)|(esten)|(ester)|(estes)|(estem)|(ste)|(ster)|(stes)|(sten)|(stem)|(st)|(ste)|(stes)|(sten)|(stem)|(ster))
konjugiert (e|(en)|(st)|(en)|t|(te)|(test)|(ten)|(tet))
ae (�|(ä)|(\"a))
ue (�|(ü)|(\"u))
oe (�|(ö)|(\"o))
Ae (�|(Ä)|(\"A))
Ue (�|(Ü)|(\"U))
Oe (�|(Ö)|(\"O))
uml (�|(ä)|(\"a)|�|(ü)|(\"u)|�|(ö)|(\"o))
Uml (�|(Ä)|(\"A)|�|(Ü)|(\"U)|�|(Ö)|(\"O))
sz (�|(\"s)|(ß))
sstp (((ssch)|(sst)|(ssp))([a-z]|(�|(ä)|(\"a)|�|(ü)|(\"u)|�|(ö)|(\"o))))
%{
/* Ligatex
Copyright (C) 1999,2000 Gerhard Killesreiter <
[email protected]>
Ligatex ist ein freies Programm; Sie k�nnen es unter den
Bedingungen der GNU General Public Licence, wie sie von der Free
Software Foundation ver�ffentlicht wurde, verteilen und/oder
modifizieren. Sie k�nnen die zweite Version verwenden oder nach
ihrer Wahl jedwede sp�ter erscheinende Version.
Ligatex wird in der Hoffnung verteilt, da� es n�tzlich sei, aber
OHNE JEDWEDE GARANTIE, sogar ohne auch nur die implizite Garantie
der HANDELBARKEIT oder der EIGNUNG F�R EINEN BESTIMMTEN ZWECK. Lesen
Sie die GNU General Public Licence, um mehr Details zu erfahren.
Sie sollten in der Datei COPYING eine Kopie der GNU General Public
Licence mit Ligatex erhalten haben. Falls nicht, schreiben Sie
an die Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
USA. In der Datei LIZENZ befindet sich eine �bersetzung der GNU
General Public Licence ins Deutsche, im Zweifelsfall ist die
englische Originalversion die ausschlaggebende.
Ligatex is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Ligatex is distributed in the hope that it will be usefull,
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.
You should have received a copy of the GNU General Public License
along with Ligatex; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
%}
char zeich;
int i,j;
int umlleng = 1;
int latex = 0;
int klammer = 0;
int scan = 0;
int foreign = 0;
char *szp;
char *aep;
char *deutsch;
%%
[������] {ECHO; umlleng=1; szp = "�";aep = "�";}
((&[Aa]uml;)|(&[Uu]uml;)|(&[Uu]uml;)|(ß)) {ECHO; umlleng= 6;
szp = "ß";
aep = "ä";}
((\"[Aa])|(\"[Uu])|(\"[Oo])|(\"s)) {ECHO; umlleng = 2; szp = "\"s";
aep = "\"a";}
^[ \t]*"\\documentclass[" {printf(yytext); latex = 1;}
^[ \t]*"\\documentclass" {printf(yytext);
latex = 1;}
^[ \t]*"\\documentclass["[a-z,]*n?german[a-z,]*"]" {printf(yytext);
deutsch = "babel";
latex = 1;}
^[ \t]*"\\documentclass["[a-z,]*n?austrian[a-z,]*"]" {printf(yytext);
deutsch = "babel";
latex = 1;}
^[ \t]*"\\usepackage{"[a-z,]*n?german[a-z,]*"}" {printf(yytext);
deutsch = "german";}
^[ \t]*"\\usepackage["[a-z,]*n?german"]{babel}" {printf(yytext);
deutsch = "babel2";}
^[ \t]*"\\usepackage["[a-z,]*n?german[a-z,]*"]{babel}" {printf(yytext);
deutsch = "babel";}
^[ \t]*"\\usepackage["[a-z,]*n?austrian"]{babel}" {printf(yytext);
deutsch = "babel2";}
^[ \t]*"\\usepackage["[a-z,]*n?austrian[a-z,]*"]{babel}" {printf(yytext);
deutsch = "babel";}
^[ \t]*"\\begin{document}" {printf(yytext);
if ( deutsch == "german" ||
deutsch == "babel2"){
BEGIN(LIGATEX);
scan = 1;}}
<GARNICHT,INITIAL>^%*"\\begin{ligatex}" {printf(yytext);
BEGIN(LIGATEX);
scan = 1;}
"\\selectlanguage{"[a-z]+"}" {
int stamm = yyleng - 17;
char sprache[yyleng - 17];
printf(yytext);
if ( stamm >= 7 ){
for (i = 0;i < stamm; i++){
sprache[i] = yytext[16 + i];
}
if(strncmp(sprache,"german",6) == 0 ||
strncmp(sprache,"\\german",7) == 0 ||
strncmp(sprache,"ngerman",7) == 0 ||
strncmp(sprache,"austrian",8) == 0 ||
strncmp(sprache,"naustrian",9) == 0)
{
BEGIN(LIGATEX);
scan = 1;} else{
BEGIN(INITIAL);
scan = 0;}
} else {BEGIN(INITIAL);
scan = 0;}
}
"\\begin{otherlanguage}{"[a-z]+"}" {
int stamm = yyleng - 23;
char sprache[yyleng - 23];
printf(yytext);
if ( stamm >= 6 ){
for (i = 0;i< stamm; i++){
sprache[i] = yytext[22 + i];
}
if(strncmp(sprache,"german",6) == 0 ||
strncmp(sprache,"ngerman",7) == 0 ||
strncmp(sprache,"austrian",8) == 0 ||
strncmp(sprache,"naustrian",9) == 0)
{
BEGIN(LIGATEX);
scan = 1;} else{
BEGIN(INITIAL);
scan = 0;}
} else {BEGIN(INITIAL);
scan = 0;}
}
"\\begin{otherlanguage*}{"[a-z]*"}" {
int stamm = yyleng - 24;
char sprache[yyleng - 24];
printf(yytext);
if ( stamm >= 6 ){
for (i = 0;i < stamm;i++){
sprache[i] = yytext[23 + i];
}
if( strncmp(sprache,"german",6) == 0 ||
strncmp(sprache,"ngerman",7) == 0 ||
strncmp(sprache,"austrian",8) == 0 ||
strncmp(sprache,"naustrian",9) == 0)
{
BEGIN(LIGATEX);
scan = 1;} else{
BEGIN(INITIAL);
scan = 0;}
} else {BEGIN(INITIAL);
scan = 0;}
}
"\\end{otherlanguage}" {printf(yytext);
if(scan == 1){
BEGIN(INITIAL);
scan = 0;}
else {
BEGIN(LIGATEX);
scan = 1;}}
"\\foreignlanguage{"[a-z]+"}{" {
int stamm = yyleng - 19;
char sprache[yyleng - 19];
printf(yytext);
if ( stamm >= 6 &&
stamm <= 9 ){
for (i = 0;i < stamm ; i++){
sprache[i] = yytext[17 + i];
}
if(strncmp(sprache,"german",6) == 0 ||
strncmp(sprache,"ngerman",7) == 0 ||
strncmp(sprache,"austrian",8) == 0 ||
strncmp(sprache,"naustrian",9) == 0)
{
BEGIN(LIGATEX);
scan = 1;
klammer = 1;
foreign = 1;
} else{
BEGIN(KLAMMER);
scan = 0;
foreign = 0;
klammer = 1;
}
} else {BEGIN(KLAMMER);
scan = 0;
klammer = 1;
foreign = 0;
}
}
<LIGATEX>"\\{" ECHO;
<LIGATEX>"\\}" ECHO;
<LIGATEX>"{" {printf(yytext);
if (foreign == 1 ){
klammer = klammer + 1;}}
<LIGATEX>"}" {printf(yytext);
if (foreign == 1 ){
klammer = klammer - 1;}
if ( klammer == 0 &&
foreign == 1){
BEGIN(INITIAL);
scan = 0;
foreign = 0;
}}
<KLAMMER>"\\{" ECHO;
<KLAMMER>"\\}" ECHO;
<KLAMMER>"{" {printf(yytext);
klammer = klammer + 1;}
<KLAMMER>"}" {printf(yytext);
klammer = klammer - 1;
if ( klammer == 0){
BEGIN(LIGATEX);
scan = 1;
}}
^[ \t]*"\\end{document}" {printf(yytext);
BEGIN(INITIAL);
scan = 0;}
^%*"\\end{ligatex}" {printf(yytext);
BEGIN(GARNICHT);
scan = 0;}
<LIGATEX>{
"\\"({grosz}{klein}*)* printf(yytext);/*TeX Makros*/
"\\"{klein}*{NN} printf(yytext);
"\\"{klein}*"\\" printf(yytext);
"\\begin{"{grosz}{klein}*"}" printf(yytext);/*Umgebungen*/
"\\begin{"{klein}*"}" printf(yytext);/*Umgebungen*/
"\\end{"{grosz}{klein}*"}" printf(yytext);/*Umgebungen*/
"\\end{"{klein}*"}" printf(yytext);/*Umgebungen*/
[Tt]"iefl" {for (i = 0;i < yyleng - 1;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("l");
[Tt]"ieffl" {for (i = 0;i < yyleng - 2;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("fl");
"Aufl." printf("Aufl.");
[^Bb][Aa]"ufl" {for (i = 0;i < yyleng - 1;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("l");
[Aa]"uffl" {for (i = 0;i < yyleng - 2;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("fl");
[Aa]"uffi" {for (i = 0;i < yyleng - 2;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("fi");
[Aa]"uff" {for (i = 0;i < yyleng - 1;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("f");
[Cc]"heffl" {for (i = 0;i < yyleng - 2;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("fl");
[Cc]"hefi" {for (i = 0;i < yyleng - 1;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("i");
[Dd]"ampfl" {for (i=0;i < yyleng -1;i++){
printf("%c",yytext[i]);}
};printf("\"|");printf("l");
[Ff]"reiberufl" {for (i=0;i < yyleng -1;i++){
printf("%c",yytext[i]);}
};printf("\"|");printf("l");
"pffl" {for (i = 0;i < yyleng - 2;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("fl");
[Kk]"ampff" {for (i=0;i < yyleng -1;i++){
printf("%c",yytext[i]);}
};printf("\"|");printf("f");
[Kk]"opflastig" printf("%c",yytext[0]);printf("opf\"|lastig");
{NN}[Oo]"ffl" {for (i = 0;i < yyleng - 1;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("l");
[Ss]"chaffell" printf("%c",yytext[0]);printf("chaf\"|fell");
[Ss]"chaufl" {for (i = 0;i < yyleng;i++ ){
printf("%c",yytext[i]);
}
};
[Ss]"chlupfl" printf("%c",yytext[0]);printf("chlupf\"|l");
[Ss]"chn"{ue}"ffl" {for (i = 0;i < yyleng -3 ;i++ ){
printf("%c",yytext[i]);
}
};printf("ff\"|l");
[Ss]"umpfl" {for (i=0;i < yyleng -1;i++){
printf("%c",yytext[i]);}
};printf("\"|");printf("l");
[Cc]"hauffi" {for (i = 0;i < yyleng;i++ ){
printf("%c",yytext[i]);
}
};
[Cc]"hauff" {for (i = 0;i < yyleng;i++ ){
printf("%c",yytext[i]);
}
};
[alp]"flos"([^s]|{NN}) {printf("%c",yytext[0]);
printf("f\"|los");
printf("%c",yytext[5]);}
"flich"({endung}|{NN}) printf("f\"|lich");{
for (i = 5;i < yyleng;i++ ){
printf("%c",yytext[i]);
}};
"flisch"({endung}|{NN}) printf("f\"|lisch");{
for (i = 6;i < yyleng;i++ ){
printf("%c",yytext[i]);
}};
"flig"({endung}|{NN}) printf("f\"|lig");{
for (i = 4;i < yyleng;i++ ){
printf("%c",yytext[i]);
}};
[^Pp]"flich"({endung}|{NN}) {printf("%c",yytext[0]);
printf("f\"|lich");{
for (i = 6;i < yyleng;i++ ){
printf("%c",yytext[i]);
}};}
"lffach"{NN} {printf("lf\"|fach");
printf("%c",yytext[6]);}
"lffach"{endung} {printf("lf\"|fach");
{for (i = 6;i < yyleng;i++ ){
printf("%c",yytext[i]);
}};}
[Ss]"chiefl" {for (i = 0;i < yyleng - 1;i++ ){
printf("%c",yytext[i]);}
printf("\"|");printf("l");}
"fling" printf("f\"|ling");
"flein" printf("f\"|lein");
"flung" printf("f\"|lung");
"afle" printf("af\"|le");
"ifle" printf("if\"|le");
"ofle" printf("of\"|le");
"opflo" printf("opf\"|lo");
"opfle" printf("opf\"|le");
"afli" printf("af\"|li");
"rafla" printf("raf\"|la");
"rifl" printf("rif\"|l");
({oe}|o)"pfl"{oe} {for (i = 0;i < yyleng - umlleng - 1;i++ )
{ printf("%c",yytext[i]);}
printf("\"|l");
for (i = yyleng - umlleng;i < yyleng ;i++ ){
printf("%c",yytext[i]);
}}
"mpflie" printf("mpf\"|lie");
"mpflu" printf("mpf\"|lu");
"mpffi" printf("mpf\"|fi");
"offin" printf("off\"|in");
"lffi" printf("lf\"|fi");
"nffi" printf("nf\"|fi");
"nffa" printf("nf\"|fa");
"flichkeit" printf("f\"|lichkeit");
[Kk]"aufin" {for (i = 0;i < yyleng - 2;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("in");
[Ss]"treiflicht" {for (i = 0;i < yyleng - 5;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("licht");
[Ww]"aldorflehrer" {for (i = 0;i < yyleng - 6;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("lehrer");
[Zz]"upfin" {for (i = 0;i < yyleng - 2;i++ ){
printf("%c",yytext[i]);
}
};printf("\"|");printf("in");
"fff" printf("ff\"|f"); /*RSR ist doof*/
}
%%
#define HELP \
"Usage: %s [OPTIONS]\n\n\
The following mutually exclusiv options are recognized:\n\n\
--help display this help and exit\n\
--version output version information and exit\n\n\
This program is a filter; it reads data from standard input, processes it,\n\
and writes the results to standard output.\n\
The data can be text encoded either in latin-1, TeX, or Html.\n\
"
#define VERSION "Ligatex 0.2.0"
extern int parse_args(int, char **, char *, char *);
int main(int argc, char **argv)
{
parse_args(argc, argv, HELP, VERSION);
/* fputs(GERMAN,stderr); */
/* fputs(BABEL,stderr); */
/* fputc('\n', stderr); */
yylex();
return(EXIT_SUCCESS);
}