summaryrefslogtreecommitdiff
path: root/support/makeprog/src/doc2tex.l
blob: fbe22e600a540dbf3d06cec26b9aa0b85d54abb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
%{
/* doc2tex.l					06 Oct 90
 *---------------------------------------------------------
 * (c) 1990 by J.Schrod.  
 *     Copyright conditions: GNU General Public License
 */

/*
 *       VERSION HISTORY
 *
 * DATE     REMARK
 * 90-10-06 mentioned filelist WEBWARE for LISTSERV in Heidelberg,
 *	    added tuglib
 * 90-01-14 june.cs.washington.edu instead of cs.washington.edu
 * 90-01-20 first version
 */

%}

%S PREAMBLE COMMENT COPY


%{
#include <ctype.h>
void hint_to_makeprog();
%}


%%

%{
#ifdef MSDOS
                check_yycrank(); /* this should go into ncform... */
#endif
                BEGIN PREAMBLE;
%}


^\ *\n          putc('\n', yyout);


<PREAMBLE>^%.*\n ECHO;
<PREAMBLE>^.    {
                hint_to_makeprog();
		unput(yytext[0]);  NLSTATE;
		BEGIN COMMENT;
		}

<COMMENT>^\\beginprog.*\n {
                fputs("%%% ", yyout);  ECHO;
		BEGIN COPY;
		}
<COMMENT>^.*\n  {
                fputs("%%% ", yyout);  ECHO;
		}

<COPY>^\\endprog.*\n {
                fputs("%%% ", yyout);  ECHO;
		BEGIN COMMENT;
		}
<COPY>^%%%.*\n  {
                fputs("%%% ", yyout);  ECHO;
                fprintf(stderr, "Macro code changed at line %d\n", yylineno-1);
		}
<COPY>^.*\n     ECHO;


.|\n            {
                register char c = yytext[0];
                fprintf(stderr, 
		      "! Illegal state at char %c (\"%02x) in line %d\n",
		      ( isprint(c)  ?  c : ' ' ), 
		      (unsigned char)c,
		      ( c == '\n'  ?  yylineno-1 : yylineno )
		      );
                }


%%

void hint_to_makeprog()
{
   fputs("%%%%\n",yyout);
   fputs("%%%%\n",yyout);
   fputs(
      "%%%% These TeX macros were documented with the documentation system\n",
      yyout);
   fputs(
      "%%%% MAKEPROG and automatically converted to the current form.\n",
      yyout);
   fputs(
      "%%%% If you have MAKEPROG available you may transform it back to\n",
      yyout);
   fputs(
      "%%%% the original input: Remove every occurence of three percents\n",
      yyout);
   fputs(
      "%%%% and one optional blank from the beginning of a line and remove\n",
      yyout);
   fputs(
      "%%%% every line which starts with four percents.  The following lex\n",
      yyout);
   fputs(
      "%%%% program will do this:\n",
      yyout);
   fputs("%%%%\n",yyout);
   fputs("%%%%    %%\n",yyout);
   fputs("%%%%\n",yyout);
   fputs("%%%%    ^%%%\\ ?   ;\n",yyout);
   fputs("%%%%    ^%%%%.*\\n ;\n",yyout);
   fputs("%%%%\n",yyout);
   fputs(
      "%%%% MAKEPROG may be obtained over the net from the Bitnet-Listserver\n",
      yyout);
   fputs(
    "%%%% LISTSERV@DHDURZ1 (filelist WEBWARE), from tuglib@science.utah.edu,\n",
      yyout);
   fputs("%%%% or via ftp from june.cs.washington.edu.\n", yyout);
   fputs("%%%%\n",yyout);
   fputs("%%%%\n",yyout);
   return;
}