";
@end\ quotation /*margin(-10); PUTA(":rm margin=1.");*/ *out << "
";
@r\{ PUTE ("B", arg ()); /*font("'Tms Rmn'"); PUTS(arg()); font(0);*/
@ref\{ words(arg()); xref(0, w[0], w[1], w[2], w[3], w[4]);
@refill ;
@result\{\} *out << "=>";
@samp\{ PUTE("SAMP", arg ());
@sc\{ { const char *cp = upcase(arg()); PUTE ("TT", cp); }
@section heading(HeadingLevel+2, eol());
@set setflag(eol());
@setchapternewpage skip (); /* eol(); */
@setfilename skip (); /* eol () */
@settitle PUTE ("TITLE", eol ()); *out << endl << "" << endl << "" << endl; PUTE ("H1", "Preface");
@shortcontents ;
@smallbook ;
@smallexample beg_example("Courier");
@end\ smallexample end_example();
@smalllisp beg_example("Courier");
@end\ smalllisp end_example();
@sp { int n = atoi(eol()); while (n--) *out << "
" << endl; }
@strong\{ PUTE ("STRONG", arg ());
@subheading heading(HeadingLevel+3, eol());
@subsection heading(HeadingLevel+3, eol());
@subsubheading heading(HeadingLevel+4, eol());
@subsubsection heading(HeadingLevel+4, eol());
@subtitle eol();
@summarycontents ;
@syncodeindex eol();
@synindex eol();
@t\{ PUTE ("TT", arg ());
/* I can't find any documentation about this @tt{} */
@tt\{ PUTE ("TT", arg ());
@table /* BEGIN(TABLE); */ item_begin("
", 'p',0); SAVESTATE (TABLE);
@end\ table item_end("
");
@ktable item_begin(":parml break=fit.", 'p',0); SAVESTATE (TABLE); /* BEGIN (TABLE); */
@end\ ktable item_end(":eparml.");
@TeX\{\} *out << "TeX";
@tex SAVESTATE (TEX); /* BEGIN(TEX);*/
^@end\ tex RESTORESTATE; /*BEGIN(0);*/ eol();
\n ++yylineno;
. ;
@thischapter ;
@thischaptername ;
@thisfile ;
@thispage ;
@thistitle ;
@tindex indexref("tp", eol());
@title skip (); /* might be changed to get the title */
@titlefont\{ arg();
@shorttitlepage eol();
@titlepage SAVESTATE (TITLE); /*BEGIN(TITLE);*/
^@end\ titlepage RESTORESTATE; /* BEGIN(0);*/ eol();
<TITLE>\n ++yylineno;
<TITLE>. ;
@today\{\} ;
@top table["Top"] = Name(++hdid, 1, 0); heading(1, eol());
@unnumbered heading(HeadingLevel+1, eol());
@unnumberedsec heading(HeadingLevel+2, eol());
@unnumberedsubsec heading(HeadingLevel+3, eol());
@unnumberedsubsubsec heading(HeadingLevel+4, eol());
@url\{ { String s = arg (); PUTEA ("A", "HREF=\"" << s << "\"", s); }
@value\{ { String& s = arg(); if (flags.contains(s)) PUT(flags[s]); }
@var\{ PUTE ("VAR", arg ());
@vindex indexref("vr", eol());
@vskip eol();
@vtable SAVESTATE(TABLE); item_begin(":parml break=fit.", 'p',"Variable"); /* BEGIN(TABLE); */
@end\ vtable item_end(":eparml.");
@w\{ PUT(arg()); /* *out << arg (); */ /*<< endl;*/ /*single_word(arg());*/
@xref\{ words(arg()); xref("See ", w[0], w[1], w[2], w[3], w[4]);
@end[ ]+[.]+ ErrorOut ("Unknown control", yytext);
/* Those things inserted here are handled but
not correct.
I have to check if they are makeable in IPF
*/
@AA\{\} *out << "A";
@aa\{\} *out << "a";
@AE\{\} *out << "Æ";
@ae\{\} *out << "æ";
@dotless\{ PUTS(arg()); /* has to print without dots.
I don't know if this is possible
under IPF */
@H\{ { arg (); } /* Ignore the parameters */
@l\{\} *out << "l";
@L\{\} *out << "L";
@o\{\} *out << "ø";
@O\{\} *out << "Ø";
@OE\{\} *out << "OE"; /* not correct */
@oe\{\} *out << "oe"; /* not correct */
/* @\" should be done. */
@ss\{\} *out << "ß";
@\"a *out << "ä";
@\"o *out << "ö";
@\"u *out << "ü";
@\"A *out << "Ä";
@\"O *out << "Ö";
@\"U *out << "Ü";
@questiondown\{\} *out << "¿";
@exclamdown\{\} *out << "¡";
@pounds\{\} *out << "&pund;";
@dotaccent\{ PUTS(arg ());
@ringaccent\{ PUTS(arg ());
@tieaccent\{ PUTS(arg ());
@ubaraccent\{ PUTS(arg ());
@udotaccent\{ PUTS(arg ());
@u\{ PUTS(arg ());
@v\{ PUTS(arg ());
@raisesections skip (); /*HeadingLevel--; */
@lowersections skip (); /*HeadingLevel++; */
\& *out << "&";
\n ++yylineno; return '\n';
\r ;
" " return 0x20;
\: *out << ":";
\. *out << ".";
\{ return '{'; /* PUTS(arg());*/
\} return '}';
. PUTS (yytext[0]); /* *out << yytext[0]; */
<<EOF>> {
if (yy_flex_debug) cerr << "<<EOF>> done." << endl;
if (--incllevel < 0)
yyterminate();
else {
yy_delete_buffer(YY_CURRENT_BUFFER);
if (inclstack[incllevel].fn)
free (inclstack[incllevel].fn);
yy_switch_to_buffer(inclstack[incllevel].state);
yylineno = inclstack[incllevel].lineno;
/*yyrestart (yyin);*/
}
}
@end\ [-a-zA-Z0-9_$]+ ErrorOut ("Unknown @end control-sequence", yytext); yylineno++;
@[-a-zA-Z0-9_$]+ ErrorOut ("Unknown control", yytext);
%%
// @[$0-9A-Z_a-z]+ ErrorOut ("Unknown control", yytext);
//@defcv[ \t]+ define(eol(), 0, "vr", 1, 0, null);
// { SAVESTATE (DEF); }
//<DEF> /* in paramter or arguments it is allowed to put @var or @values
// * (seen in texinfo manual chapter 16 def-commands)
// */
//<DEF>@var\{ { PUT(":hp1."); PUTS(arg()); PUT(":ehp1."); }
//<DEF>@value\{ { String& s = arg(); if (flags.contains(s)) PUT(flags[s]); }
//<DEF>\n { RESTORESTATE; }
/***********************
<INITIAL,TABLE,FALSE,MENU,TITLE>@ifclear if (!iff(eol(), 0)) SAVESTATE (FALSE);
<INITIAL,TABLE,FALSE,MENU,TITLE>@ifset if (!iff(eol(), 1)) SAVESTATE (FALSE);
<INITIAL,TABLE,MENU,TITLE>^@end\ ifclear RESTORESTATE;
<INITIAL,TABLE,MENU,TITLE>^@end\ ifset RESTORESTATE;
<FALSE>^@end\ if[a-z]+ yy_start = endiff(); eol(); RESTORESTATE;
<FALSE>\n ++yylineno;
<FALSE>. ;
**********************************************************/
static String buffer;
String &
arg()
{
ostrstream ostr;
ostream *old = out;
out = &ostr;
int Argument = 1;
if (plevel == 9)
unexpected(0);
plines[++plevel] = yylineno;
if (yy_flex_debug)
{
fprintf(stderr, "++push to %d\n", plevel);
cerr << "Saving state." << endl;
}
SAVESTATE (INITIAL);
int old_np = newpara;
int old_nl = lastnl;
/* BEGIN(0);*/
newpara = 0;
for (;;) {
switch (yylex()) {
case 0:
unexpected("EOF");
case '{':
continue;
case '}':
if (!Argument)
continue;
else
Argument = 0;
break;
case 0x20:
*out << " ";
continue;
case '\n':
/*if (ostr.pcount() > 100) {
PUTL();
} else
PUT(' ');
*/
*out << endl;
/*++yylineno; */ /* already done by yylex () */
continue;
default:
continue;
}
break;
}
if (yy_flex_debug)
cerr << "Restoring state." << endl;
RESTORESTATE;
newpara = old_np;
lastnl = old_nl;
if (yy_flex_debug)
fprintf(stderr, "++pop from %d\n", plevel);
--plevel;
buffer = String(ostr.str(), ostr.pcount());
/* while (buffer.length() && isspace(buffer[0]))
buffer.del(0, 1);
*/
if (yy_flex_debug)
cerr << "arg(): \"" << buffer << "\"" << endl;
out = old;
return buffer;
}
String &
eol()
{
ostrstream ostr;
ostream *old = out;
out = &ostr;
if (plevel == 9)
unexpected(0);
plines[++plevel] = yylineno;
if (yy_flex_debug)
fprintf(stderr, "++push to %d\n", plevel);
int old_start = yy_start;
int old_np = newpara;
int old_nl = lastnl;
int Argument = 0;
BEGIN(INITIAL); /* this might be wrong */
newpara = 0;
for (;;) {
switch (yylex()) {
case 0:
unexpected("EOF");
case '{':
Argument = 1;
PUTS(arg());
continue;
case '}':
if (!Argument)
unput('}');
else
Argument = 0;
break;
case '\n':
/*unput('\n');*/
/**out << endl;*/
break;
case 0x20:
*out << " ";
continue;
default:
continue;
}
break;
}
yy_start = old_start;
newpara = old_np;
lastnl = old_nl;
if (yy_flex_debug)
fprintf(stderr, "++pop from %d\n", plevel);
--plevel;
buffer = String(ostr.str(), ostr.pcount());
while (buffer.length() && isspace(buffer[0]))
buffer.del(0, 1);
out = old;
return buffer;
}
void
unexpected(const char *msg)
{
if (msg)
ErrorOut ("Unexpected EOF",(char *)NULL);
else
{
if (incllevel > 0)
cerr << inclstack[incllevel-1].fn << ": Nesting overflow in line " << yylineno << endl;
else
cerr << "Nesting overflow in line " << yylineno << endl;
}
for (; plevel; --plevel)
{
cerr << "\tunterminated argument starting in line "
<< plines[plevel] << endl;
}
cerr.flush();
exit(1);
}
void
footnote()
{
++fnid;
PUT ("<A HREF=\"#fn" << fnid << "\">(" << fnid << ")</A>");
PUTS ("<FN NAME=\"fn" << fnid << "\">" << arg () << "</FN>");
/* PUTS(":fn id=fn" << fnid << '.' << arg() << ":efn. "
<< ":link reftype=fn refid=fn" << fnid << ".(" << fnid << "):elink.");
*/
}
void
newline()
{
if (!lastnl) {
lastnl = 1;
*out << endl;
}
if (!nofill) {
int c = yyinput();
if (c == '\n') {
newpara = 1;
do ++yylineno; while ((c = yyinput()) == '\n');
}
unput(c);
}
}
void
skip()
{
int c;
for (; (c = yyinput()) != '\n'; )
;
++yylineno;
}
String &EolPar (void)
{
static String Buffer;
int c;
Buffer = "";
for (; (c = yyinput()) != '\n'; )
Buffer += (char)c;
/* ++yylineno; ???*/
return Buffer;
}
void
dot()
{
int c = yyinput();
if (c == '.') {
PUTS("&dot.");
do { PUT("&dot."); } while ((c = yyinput()) == '.');
} else if (lastnl) {
PUTS("&dot.");
} else
PUTS('.');
unput(c);
}
void include(const char *fname)
{
if (incllevel >= MaxIncl)
{
cerr << "Includes nested too deeply" << endl;
exit(1);
}
inclstack[incllevel].fn = strdup (fname);
if (!(inclstack[incllevel].fn))
{
cerr << "Not enough memory" << endl;
exit (2);
}
inclstack[incllevel].state = YY_CURRENT_BUFFER;
inclstack[incllevel++].lineno = yylineno;
cerr << " [" << fname;
char name[FILENAME_MAX+1];
strcpy(name, fname);
char *namep = strtok(name, " \t"); // strip any blanks
yyin = fopen(namep, "r");
if (!yyin) {
char *dotp = strrchr(namep, '.');
if (dotp && !strpbrk(dotp, ":\\/") && strlen(dotp) > 4)
dotp[4] = 0; // truncate .texi to .tex
yyin = fopen(namep, "r");
}
if (!yyin)
{
cerr << "Cannot open include file '" << namep << "': "
<< strerror(errno) << endl;
exit(1);
}
IncludeFile = 1;
/* next include file we start counting from one */
yylineno = 1;
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
yyrestart (yyin);
}
int
yywrap()
{
static int Nr = 0;
fclose (yyin);
if (incllevel >0 )
{
cerr << "] ";
Nr ++;
if (Nr > 3)
{
cerr << endl;
Nr = 0;
}
}
else
cerr << "] " << endl;
if (--incllevel < 0)
{
yyterminate();
return 1;
}
else
{
yy_delete_buffer(YY_CURRENT_BUFFER);
if (inclstack[incllevel].fn)
free (inclstack[incllevel].fn);
yylineno = inclstack[incllevel].lineno;
yy_switch_to_buffer(inclstack[incllevel].state);
return 0;
}
}
int iff(String& arg, tIfType IfType)
{
if (yy_flex_debug)
cerr << "Contains(" << arg << ")=" << flags.contains (arg) << endl;
if (iflevel >= MaxIf)
{
cerr << "Conditions nested too deeply" << endl;
exit (3);
}
ifstack[iflevel].IfType = IfType;
ifstack[iflevel++].Condition = flags.contains(arg);
if (flags.contains(arg))
return 1;
else
return 0;
}
int endiff(tIfType IfType)
{
String s;
if (iflevel < 1)
return -1; /* Error, unmatched @end */
--iflevel;
if (ifstack[iflevel].IfType != IfType)
{
s = "Expected @end ";
s += cIfType[ifstack[iflevel].IfType];
s += " but read another.";
ErrorOut (s, (char *)NULL);
}
return ifstack[iflevel].Condition;
}
/*
*/
String &DefPar ()
{
static String buffer;
ostrstream ostr;
ostream *old = out;
out = &ostr;
int old_start = yy_start;
int old_np = newpara;
int old_nl = lastnl;
int c;
int Paras = 0;
if (plevel == 9)
unexpected(0);
plines[++plevel] = yylineno;
if (yy_flex_debug)
fprintf(stderr, "++ DefPar:: push to %d\n", plevel);
BEGIN(0);
newpara = 0;
for (;;)
{
c = yylex ();
if (yy_flex_debug)
fprintf(stderr, " DefPar:: c=%d c=\"%c\"\n", c, (char)c);
switch (c)
{
case 0:
unexpected("EOF");
case '{':
if (yy_flex_debug)
fprintf(stderr, "DefPar:: { erkannt\n");
Paras = 1;
/*yylex ();*/
/**out << arg();*/
continue;
case '}':
if (!Paras)
{
yyinput ();
continue;
}
if (yy_flex_debug)
fprintf(stderr, "DefPar:: } erkannt\n");
Paras = 0;
/*c = yylex ();*/
yyinput ();
/*IgnoreSpace ();*/
break;
case 0x20:
if (Paras)
{
*out << " ";
continue;
}
else
{
/*c = yylex ();*/
/*IgnoreSpace ();*/
break;
}
case '\n':
/* *out << endl; ??? */
/*unexpected ("LF");*/
break;
default:
continue;
} /* switch (yylex())... */
break;
} /* for (;;)... */
yy_start = old_start;
newpara = old_np;
lastnl = old_nl;
if (yy_flex_debug)
fprintf(stderr, "++ DefPar:: pop from %d\n", plevel);
--plevel;
while ( (c = yyinput ()) == ' ');
unput (c);
buffer = String(ostr.str(), ostr.pcount());
while (buffer.length() && isspace(buffer[0]))
buffer.del(0, 1);
out = old;
return buffer;
}
void Defs
(
int xVariant, /* is on of the @def...x */
int exCategory, /* =1 means category exists */
int exClass, /* =1 class exists */
int exType, /* =1 means type exists */
int exArgs, /* =1 means arguments exists */
const char *TypeOfIndex, /* make index entry in e.g. "fn" */
const char *CategoryDef /* some of the @def's are shortages of other @def's */
)
{
String Category = CategoryDef;
String Class;
String Type;
String Name;
String Args;
if (yy_flex_debug)
{
cerr << "Defs" << endl;
cerr << "Defs::Category:" << endl;
}
if (exCategory)
{
Category = DefPar ();
if (yy_flex_debug)
cerr << "CAT: " << Category << endl;
}
if (yy_flex_debug)
cerr << "Defs::Class:" << endl;
if (exClass)
{
Class = DefPar ();
if (yy_flex_debug)
cerr << "CLASS: " << Class << endl;
}
if (yy_flex_debug) cerr << "Defs::Type:" << endl;
if (exType)
{
Type = DefPar ();
if (yy_flex_debug)
cerr << "TYP: " << Type << endl;
}
/* should always exist */
if (yy_flex_debug)
cerr << "Defs::Name:" << endl;
Name = DefPar ();
if (yy_flex_debug)
cerr << "Defs::Args:" << endl;
if (exArgs)
{
Args = eol ();
if (yy_flex_debug)
cerr << "ARGS: " << Args << endl;
}
/*newpara = 1;
if (xVariant)
margin (-10);
else if (newpara)
para (); */
/*font ("Courier", FontSize);*/
/* make sure to begin the definition in new line */
if (!xVariant)
{
*out << "<BR>" << endl;
}
*out << "<TABLE WIDTH=\"100%\">" << endl
<< "<TR>" << endl;
*out << "<TD ALIGN=\"LEFT\">";
if (exType)
PUTE ("CODE", Type << " " );
PUTE ("I", Name << " ");
if (exArgs)
PUTE ("TT", Args);
*out << "</TD>" << endl;
*out << "<TD ALIGN=\"RIGHT\"><B>(" << Category << ")</B></TD>" << endl;
/* PUTE ("B", " (" << Category << ")" );*/
*out << "</TR>" << endl;
*out << "</TABLE>" << endl;
/*lastnl = 1;
margin (10);
*/
indexref (TypeOfIndex, Name);
}
void ErrorOut (const char *msg, const char *yyt)
{
if (incllevel > 0)
cerr << endl << inclstack[incllevel-1].fn << ":"
<< yylineno << ": " << msg << "(" << yyt << ")"
<< endl;
else
cerr << msg << "(" << yyt << ") in line " << yylineno << endl;
}
void WarningOut (const char *msg, const char *yyt)
{
if (incllevel > 0)
cerr << endl << "warning: " << inclstack[incllevel-1].fn << ":"
<< yylineno << ": " << msg << "(" << yyt << ")"
<< endl;
else
cerr << "warning: " << msg << "(" << yyt << ") in line " << yylineno << endl;
}