%{ #include #include #include #include #include using namespace std; /* Hack, to get rid of the yywrap. */ #define YY_SKIP_YYWRAP 1 #define yywrap() 1 bool removeLinks = false; %} %x ANCHORMODE %x HEADINGMODE ws [ \t\n\r]* nonws [^ \t\n\r] par {ws}("<"[pP]">"{ws})* glue {ws}("<"[pP]">"{ws})*""{ws}("<"[pP]">"{ws})* %% "" { removeLinks = true; } "" { removeLinks = false; } [<][aA]{ws}[hH][rR][eE][fF][^>]*[>] { if( removeLinks ) BEGIN(ANCHORMODE); else ECHO; } "" { BEGIN(INITIAL); } "<"[hH][1-6] { BEGIN( HEADINGMODE); ECHO;} "" { BEGIN( INITIAL); ECHO;} . { ECHO;} ""{glue}"]*">" { ; /* smooth adjacent tables */ } ""{glue}"]*">" { ; /* smooth adjacent tables */ } ""{glue}"" << endl << " "{par}"]*">" { /* smooth adjacent tables */ cout << "
"; } ""{par}"]*">" { /* smooth adjacent tables */ cout << "
"; } ""{par}"" << endl << "

" << endl << endl << " "{ws}("<"[pP]">"{ws})* { /* Reduce

's to one

*/ cout << endl << "

" << endl << endl; } {ws}"<"[bB][rR]">"{ws} { /* Pretty print single
*/ cout << "
" << endl << endl; } "" { ; /* remove superfluous glues */ } "" { ; /* remove superfluous table hints */ } "" { ; /* remove superfluous table hints */ } %% int main( int argc, char** argv ) { yylex(); return 0; }