summaryrefslogtreecommitdiff
path: root/support/xetal
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/xetal
Initial commit
Diffstat (limited to 'support/xetal')
-rw-r--r--support/xetal/COPYING249
-rw-r--r--support/xetal/README20
-rw-r--r--support/xetal/glbl.h64
-rw-r--r--support/xetal/l.l1081
-rw-r--r--support/xetal/main.c344
-rw-r--r--support/xetal/makefile91
-rw-r--r--support/xetal/proto.h97
-rw-r--r--support/xetal/stack.c135
-rw-r--r--support/xetal/stack.h46
-rw-r--r--support/xetal/str.c49
-rw-r--r--support/xetal/str.h24
-rw-r--r--support/xetal/xetal.1106
-rw-r--r--support/xetal/y.y1031
13 files changed, 3337 insertions, 0 deletions
diff --git a/support/xetal/COPYING b/support/xetal/COPYING
new file mode 100644
index 0000000000..9a17037581
--- /dev/null
+++ b/support/xetal/COPYING
@@ -0,0 +1,249 @@
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 1, February 1989
+
+ Copyright (C) 1989 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The license agreements of most software companies try to keep users
+at the mercy of those companies. By contrast, our General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. The
+General Public License applies to the Free Software Foundation's
+software and to any other program whose authors commit to using it.
+You can use it for your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Specifically, the General Public License is designed to make
+sure that you have the freedom to give away or sell copies of free
+software, that you receive source code or can get it if you want it,
+that you can change the software or use pieces of it in new free
+programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of a such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must tell them their rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any program or other work which
+contains a notice placed by the copyright holder saying it may be
+distributed under the terms of this General Public License. The
+"Program", below, refers to any such program or work, and a "work based
+on the Program" means either the Program or any work containing the
+Program or a portion of it, either verbatim or with modifications. Each
+licensee is addressed as "you".
+
+ 1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this
+General Public License and to the absence of any warranty; and give any
+other recipients of the Program a copy of this General Public License
+along with the Program. You may charge a fee for the physical act of
+transferring a copy.
+
+ 2. You may modify your copy or copies of the Program or any portion of
+it, and copy and distribute such modifications under the terms of Paragraph
+1 above, provided that you also do the following:
+
+ a) cause the modified files to carry prominent notices stating that
+ you changed the files and the date of any change; and
+
+ b) cause the whole of any work that you distribute or publish, that
+ in whole or in part contains the Program or any part thereof, either
+ with or without modifications, to be licensed at no charge to all
+ third parties under the terms of this General Public License (except
+ that you may choose to grant warranty protection to some or all
+ third parties, at your option).
+
+ c) If the modified program normally reads commands interactively when
+ run, you must cause it, when started running for such interactive use
+ in the simplest and most usual way, to print or display an
+ announcement including an appropriate copyright notice and a notice
+ that there is no warranty (or else, saying that you provide a
+ warranty) and that users may redistribute the program under these
+ conditions, and telling the user how to view a copy of this General
+ Public License.
+
+ d) You may charge a fee for the physical act of transferring a
+ copy, and you may at your option offer warranty protection in
+ exchange for a fee.
+
+Mere aggregation of another independent work with the Program (or its
+derivative) on a volume of a storage or distribution medium does not bring
+the other work under the scope of these terms.
+
+ 3. You may copy and distribute the Program (or a portion or derivative of
+it, under Paragraph 2) in object code or executable form under the terms of
+Paragraphs 1 and 2 above provided that you also do one of the following:
+
+ a) accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of
+ Paragraphs 1 and 2 above; or,
+
+ b) accompany it with a written offer, valid for at least three
+ years, to give any third party free (except for a nominal charge
+ for the cost of distribution) a complete machine-readable copy of the
+ corresponding source code, to be distributed under the terms of
+ Paragraphs 1 and 2 above; or,
+
+ c) accompany it with the information you received as to where the
+ corresponding source code may be obtained. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form alone.)
+
+Source code for a work means the preferred form of the work for making
+modifications to it. For an executable file, complete source code means
+all the source code for all modules it contains; but, as a special
+exception, it need not include source code for modules which are standard
+libraries that accompany the operating system on which the executable
+file runs, or for standard header files or definitions files that
+accompany that operating system.
+
+ 4. You may not copy, modify, sublicense, distribute or transfer the
+Program except as expressly provided under this General Public License.
+Any attempt otherwise to copy, modify, sublicense, distribute or transfer
+the Program is void, and will automatically terminate your rights to use
+the Program under this License. However, parties who have received
+copies, or rights to use copies, from you under this General Public
+License will not have their licenses terminated so long as such parties
+remain in full compliance.
+
+ 5. By copying, distributing or modifying the Program (or any work based
+on the Program) you indicate your acceptance of this license to do so,
+and all its terms and conditions.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these
+terms and conditions. You may not impose any further restrictions on the
+recipients' exercise of the rights granted herein.
+
+ 7. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of the license which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+the license, you may choose any version ever published by the Free Software
+Foundation.
+
+ 8. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to humanity, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these
+terms.
+
+ To do so, attach the following notices to the program. It is safest to
+attach them to the start of each source file to most effectively convey
+the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19xx name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the
+appropriate parts of the General Public License. Of course, the
+commands you use may be called something other than `show w' and `show
+c'; they could even be mouse-clicks or menu items--whatever suits your
+program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ program `Gnomovision' (a program to direct compilers to make passes
+ at assemblers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/support/xetal/README b/support/xetal/README
new file mode 100644
index 0000000000..16a9a7132b
--- /dev/null
+++ b/support/xetal/README
@@ -0,0 +1,20 @@
+Xetal has only been tested on Sun 4. It can be built indifferently with
+lex, flex, yacc or bison (Just make the appropriate changes in the
+makefile).
+
+The tar file contains the following files :
+
+COPYING GNU GENERAL PUBLIC LICENSE
+README This file
+xetal.1 xetal manual in nroff format
+makefile xetal makefile
+
+l.l lexical analyser
+y.y parser
+glbl.h xetal program
+main.c ""
+proto.h ""
+stack.c ""
+stack.h ""
+str.c ""
+str.h ""
diff --git a/support/xetal/glbl.h b/support/xetal/glbl.h
new file mode 100644
index 0000000000..304d5f1faf
--- /dev/null
+++ b/support/xetal/glbl.h
@@ -0,0 +1,64 @@
+/*
+ definitions of global objects used in xetal,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+ * global definitions
+ */
+
+int mode=0; /* current mode 0: normal, 1: math */
+int verbatim=0; /* verbatim mode */
+int d_ok=1; /* display flag */
+long lineno=0L; /* current line in source text */
+long total_lines=0L;/* nb of lines already handled */
+long charpos=0L;/* last char read */
+long linepos=0L;/* last \n read */
+long oldlpos=0L;/* old value of linepos */
+
+int n_nl, N;/* n_nl : numerotation flag, N : interval of numerotation */
+int n_formule=0;/* nb of formulas */
+long c_skipped=0L;/* nb of characters skipped */
+char c_fill=' ';/* replacement character */
+char s_accent='\\';/* character to put before accent */
+
+/*
+ * options flags
+ */
+int d_anything, d_error;
+int d_accent, d_bl, d_bls, d_command, d_comment, d_fname;
+int d_macrodef, d_math, d_mot, d_nl, d_operator, d_punct;
+int d_report, d_slashed, d_special, d_text, d_unknown;
+int d_warning, do_fill, do_fill_acco, do_fill_slash, do_incl;
+
+FILE *devnull; /* rubbish-bin */
+int n_ionly=-1; /* nb of ionly files; -1 : no includeonly instruction */
+char *if_name[F_MAX]; /* includeonly_files */
+char *f_name; /* name of current file */
+FILE **f_in; /* input stream */
+char S[O_LGTH]; /* output buffer */
+
+int n_envrt=0; /* nb of envrt names */
+char *(envrt[M_ENVRT]); /* envrt handled as math */
+
+int n_symbol; /* nb of known symbols */
+symbol_t symbol[M_SYMBOL]; /* symbol list */
+
+int n_adsymbol; /* nb of added symbols */
+symbol_t adsymbol[M_SYMBOL];/* list of added symbols */
diff --git a/support/xetal/l.l b/support/xetal/l.l
new file mode 100644
index 0000000000..f89eeb2a33
--- /dev/null
+++ b/support/xetal/l.l
@@ -0,0 +1,1081 @@
+%{
+
+/*
+ definition of the lexical analyser used in xetal,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <search.h>
+#include "proto.h"
+#include "y.tab.h"
+#include "stack.h"
+
+static long nskip; /* nb of \n in logical line */
+int cmd; /* token of command currently handled */
+
+/*
+ * macros for LEX actions
+ */
+#define R_C0 yylval.y_chr=yytext[0]; charpos++;
+#define R_C1 yylval.y_chr=yytext[1]; charpos+=2;
+#define R_C(c) yylval.y_chr=c; charpos++;
+#define R_W yylval.y_str=yytext; charpos+=yyleng;
+#define RD_W yylval.y_str=strdup(yytext); charpos+=yyleng;
+#define CP charpos++;
+#define CM charpos--;
+#define CY charpos+=yyleng;
+#define C(x) charpos+=x;
+#define B(x) yyless(yyleng-x)
+
+#ifdef FLEX_SCANNER
+
+#undef YY_FATAL_ERROR
+/* report a fatal error */
+#define YY_FATAL_ERROR(msg) \
+ { \
+ if (strcmp(msg, "NULL in input")!=0) {\
+ fputs( msg, stderr ); \
+ putc( '\n', stderr ); \
+ exit( 1 ); \
+ } }
+#undef YY_INPUT
+extern int yy_input1();
+extern int yy_input2();
+char *tmp_buf;
+int (*yy_input)();
+#define YY_INPUT(buf,result,max_size) \
+ result=(*yy_input)(buf, max_size);
+
+#undef YY_NEW_FILE
+#define YY_NEW_FILE { yy_input=yy_input2; goto new_file; }
+
+#endif
+
+#undef yywrap
+
+%}
+
+%a 5000
+%e 500
+%k 500
+%o 6500
+%p 4000
+
+letter [a-zA-Z]
+letterA [a-zA-Z@]
+letterS [a-zA-Z\*]
+letterAS [a-zA-Z@\*]
+digit [0-9]
+letter_or_digit [a-zA-Z_0-9]
+letter_or_digit_or_punct [a-zA-Z_0-9\.\,\`\'\"\;\:]
+fln_car [^ \t\n\}\]\{\[]
+
+reel [0-9]+|[0-9]+\.[0-9]*|[0-9]*\.[0-9]+
+nombre [0-9]+
+lettres {letter_or_digit}+
+caracteres {letter_or_digit_or_punct}+
+filename {fln_car}+
+
+white_space [ \t\n]+
+bl [ \t]
+bls [ \t]+
+obls [ \t]*
+nl [\n]
+blsnl [ \t]*[\n][ \t]*
+blsorblsnl ([ \t]*[\n][ \t]*|[ \t]+)
+
+accent [\`\^\~\=\'\"\.]
+slashed \\[^\`\^\~\=\'\"\.btHudvc\n\t\ ]
+
+anything .*
+any_not_slash [^\\\n]*
+argument {letterS}+
+command \\{letterAS}+|\\{accent}
+ctlseq0 [^=]*
+ctlseq1 [^{=]*
+ctlseq2 [^{]*
+ctlseq3 [^{=][^{=\\]*
+comment \%[^\n]*\n
+
+%START BE_ARG O_ARG
+%START S_ARG S_LET S_NB S_CAR S_REEL
+%START S_FLN SQ0 SQ1 SQ2 SQ3
+%START S_VRB0 S_VRBA S_END
+
+%%
+
+ { nskip=0L; oldlpos=linepos; }
+
+<S_END>{anything} { char *p; R_W; p=yytext; return ANYTHING; }
+
+<S_VRB0>\} { R_C0; BEGIN S_VRBA; return yytext[0]; }
+<S_VRBA>{any_not_slash} { R_W; return ANY_NOT_SLASH; }
+<S_VRBA>\\end\{verbatim { yyless(0); verbatim=-1; start_N(); }
+
+<BE_ARG>{argument} { R_W; start_N(); cmd=s_lookup(yytext);
+ switch(cmd) {
+ case VERBATIM:
+ if (verbatim==0) {
+ BEGIN S_VRB0;
+ verbatim=1;
+ } else {
+ verbatim=0; }
+ break;
+ }
+ return(cmd);
+ }
+
+{bls} { R_W; return BLS; }
+{blsnl} { R_W; nskip++; linepos=charpos; return BLSNL; }
+
+<S_ARG>{letter_or_digit} { R_C0; return LETTER; }
+<SQ0>{ctlseq0} { R_W; return CTLSEQ0; }
+<SQ1>{ctlseq1} { R_W; return CTLSEQ1; }
+<SQ2>{ctlseq2} { R_W; return CTLSEQ2; }
+<SQ3>{ctlseq3} { R_W; return CTLSEQ3; }
+<S_NB>{nombre} { R_W; return NOMBRE; }
+<S_REEL>{reel} { R_W; return REEL; }
+<S_NB,S_CAR,S_FLN,S_LET,O_ARG>{lettres} { R_W; return LETTRES; }
+<S_CAR>{caracteres} { R_W; return CARACTERES; }
+<S_FLN>{filename} { R_W; return FILENAME; }
+
+\$ { R_W; return (mode!=-1 ? DOLLAR : LETTRES); }
+\$\$ { R_W; return (mode!=-1 ? DDOLLAR : LETTRES); }
+\\\( { R_W; return (mode!=-1 ? OPARE : LETTRES); }
+\\\) { R_W; return (mode!=-1 ? CPARE : LETTRES); }
+\\\[ { R_W; return (mode!=-1 ? OBRAC : LETTRES); }
+\\\] { R_W; return (mode!=-1 ? CBRAC : LETTRES); }
+<O_ARG>"[" { R_W; return OBRAC; }
+<O_ARG>"]" { R_W; return CBRAC; }
+"]" { if (is_S_in_stack(O_ARG)) {
+ R_W; return CBRAC;
+ } else {
+ R_C0; return yytext[0];
+ }
+ }
+
+"\\" { R_C0; return SLASH; }
+
+-{1,3} { R_C('-'); CY; CM; return '-'; }
+\\[ /] { yylval.y_str=strcpy(yytext, " ");
+ C(2); return BLS; }
+\\@ { C(2); }
+\\- { C(2); }
+~ { yylval.y_str=strcpy(yytext, " ");
+ C(1); return BLS; }
+
+\\oe { R_C('o'); CP; B(1); return(LETTER); }
+\\OE { R_C('O'); CP; B(1); return(LETTER); }
+\\ae { R_C('a'); CP; B(1); return(LETTER); }
+\\AE { R_C('A'); CP; B(1); return(LETTER); }
+\\aa { R_C('a'); C(2); return(LETTER); }
+\\AA { R_C('A'); C(2); return(LETTER); }
+\\[lL] { R_C1; return(LETTER); }
+\\[oO] { R_C('0'); return(LETTER); }
+\\ss { R_C('s'); C(2); return(LETTER); }
+\?\` { R_C('?'); CP; return(LETTER); }
+\!\` { R_C('!'); CP; return(LETTER); }
+
+{slashed} { R_C1; return SLASHED; }
+
+{command} { R_W;
+ if (mode==-1) cmd=LETTRES;
+ else if (verbatim==1) cmd=ANY_NOT_SLASH;
+ else cmd=s_lookup(yytext);
+ switch (cmd) {
+ case VERB:
+ {
+ char sch;/* flag character for verb */
+ char *p;/* current character */
+ int l;/* nb of added characters */
+
+ l=yyleng; p=yytext+l;
+
+ /* verb command : reading text until verb flag */
+#ifdef FLEX_SCANNER
+ *yy_cp=yy_hold_char;
+ sch=*(p++);l++;
+ while((*(p++))!=sch) {
+ l++;
+ if ( *p == YY_END_OF_BUFFER_CHAR ) {
+ /* input needed */
+ yy_hold_char = *p;
+ yy_c_buf_p=p+1;
+ yy_get_next_buffer();
+ p=yytext+l;
+ } }
+ yy_cp=p;
+ yy_hold_char=*yy_cp;
+ *yy_cp='\0';
+ yy_c_buf_p=yy_cp;
+#else
+ *(p++)=sch=input();
+ while ((*(p++)=input())!=sch) l++;
+ *p='\0';
+#endif
+ yylval.y_str=yytext;charpos+=l;
+ } break;
+ }
+ return cmd; }
+
+{comment} { R_W; nskip++; return COMMENT; }
+
+[\40-\176] { R_C0; return yytext[0]; }
+
+[\14] { R_C0; return FFEED; }
+
+. { R_C0; return OTHER; }
+
+%%
+
+/*
+ * functions called by parser to change lex state
+ */
+
+start_O()
+{
+ S_push(0);
+ BEGIN 0;
+}
+
+start_END()
+{
+ S_push(S_END);
+ BEGIN S_END;
+}
+
+start_N()
+{
+ if (!is_S_stack_empty()) { S_pop(); }
+
+ if (is_S_stack_empty()) {
+ BEGIN S_LET;
+ } else {
+ BEGIN S_read();
+ }
+}
+
+start_O_ARG()
+{
+ S_push(O_ARG);
+ BEGIN O_ARG;
+}
+
+start_BE_ARG()
+{
+ S_push(BE_ARG);
+ BEGIN BE_ARG;
+}
+
+start_ARG()
+{
+ S_push(S_ARG);
+ BEGIN S_ARG;
+}
+
+start_NB()
+{
+ S_push(S_NB);
+ BEGIN S_NB;
+}
+
+start_REEL()
+{
+ S_push(S_REEL);
+ BEGIN S_REEL;
+}
+
+start_CAR()
+{
+ S_push(S_CAR);
+ BEGIN S_CAR;
+}
+
+start_FLN()
+{
+ S_push(S_FLN);
+ BEGIN S_FLN;
+}
+
+start_SQ0()
+{
+ S_push(SQ0);
+ BEGIN SQ0;
+}
+
+start_SQ1()
+{
+ S_push(SQ1);
+ BEGIN SQ1;
+}
+
+start_SQ2()
+{
+ S_push(SQ2);
+ BEGIN SQ2;
+}
+
+start_SQ3()
+{
+ S_push(SQ3);
+ BEGIN SQ3;
+}
+
+start_STATE(s)
+int s;
+{
+ S_push(s);
+ BEGIN s;
+}
+
+/*
+ * lex initialization
+ */
+init_lex()
+{
+ f_in=&yyin;
+#ifdef FLEX_SCANNER
+ yy_input=yy_input1;
+ yy_init=1;
+#endif
+}
+
+#define NAME symbol[n].name
+#define TOKEN symbol[n++].token
+
+/*
+ * compare two symbol_names
+ */
+int symbol_tcmp(s1, s2)
+symbol_t *s1, *s2;
+{
+ return (strcmp(s1->name, s2->name));
+}
+
+/*
+ * initialization of symbol list
+ */
+int init_symbol(envrt, n_envrt)
+char *envrt[];
+int n_envrt;
+{
+ int i, n=0;
+ symbol_t s_fake, *r;
+
+ start_N();
+
+ NAME="\\`"; TOKEN=ACCENT;
+ NAME="\\^"; TOKEN=ACCENT;
+ NAME="\\~"; TOKEN=ACCENT;
+ NAME="\\="; TOKEN=ACCENT;
+ NAME="\\'"; TOKEN=ACCENT;
+ NAME="\\\""; TOKEN=ACCENT;
+ NAME="\\."; TOKEN=ACCENT;
+
+ NAME="\\b"; TOKEN=ACCENT;
+ NAME="\\t"; TOKEN=ACCENT;
+ NAME="\\H"; TOKEN=ACCENT;
+ NAME="\\u"; TOKEN=ACCENT;
+ NAME="\\d"; TOKEN=ACCENT;
+ NAME="\\v"; TOKEN=ACCENT;
+ NAME="\\c"; TOKEN=ACCENT;
+
+ NAME="\\def"; TOKEN=DEF;
+ NAME="\\gdef"; TOKEN=DEF;
+ NAME="\\edef"; TOKEN=DEF;
+ NAME="\\xdef"; TOKEN=DEF;
+
+ NAME="\\toksdef"; TOKEN=ASSIGN;
+
+ NAME="\\catcode"; TOKEN=CATCODE;
+ NAME="\\mathcode"; TOKEN=CATCODE;
+ NAME="\\delcode"; TOKEN=CATCODE;
+ NAME="\\sfcode"; TOKEN=CATCODE;
+
+ NAME="\\let"; TOKEN=ASSIGN;
+ NAME="\\chardef"; TOKEN=ASSIGN;
+ NAME="\\mathchardef"; TOKEN=ASSIGN;
+ NAME="\\countdef"; TOKEN=ASSIGN;
+ NAME="\\dimendef"; TOKEN=ASSIGN;
+ NAME="\\skipdef"; TOKEN=ASSIGN;
+ NAME="\\muskipdef"; TOKEN=ASSIGN;
+
+ NAME="\\read"; TOKEN=READ;
+ NAME="\\setbox"; TOKEN=SETBOX;
+ NAME="\\font"; TOKEN=FONT;
+
+ NAME="\\count"; TOKEN=REGISTER;
+ NAME="\\dimen"; TOKEN=REGISTER;
+ NAME="\\skip"; TOKEN=REGISTER;
+ NAME="\\muskip"; TOKEN=REGISTER;
+ NAME="\\toks"; TOKEN=REGISTER;
+
+ NAME="\\advance"; TOKEN=OPERATION;
+ NAME="\\multiply"; TOKEN=OPERATION;
+ NAME="\\divide"; TOKEN=OPERATION;
+
+ NAME="\\pretolerance"; TOKEN=INT_PAR;
+ NAME="\\tolerance"; TOKEN=INT_PAR;
+ NAME="\\hbadness"; TOKEN=INT_PAR;
+ NAME="\\vbadness"; TOKEN=INT_PAR;
+ NAME="\\linepenalty"; TOKEN=INT_PAR;
+ NAME="\\hyphenpenalty"; TOKEN=INT_PAR;
+ NAME="\\exhyphenpenalty"; TOKEN=INT_PAR;
+ NAME="\\binoppenalty"; TOKEN=INT_PAR;
+ NAME="\\relpenalty"; TOKEN=INT_PAR;
+ NAME="\\clubpenalty"; TOKEN=INT_PAR;
+ NAME="\\widowpenalty"; TOKEN=INT_PAR;
+ NAME="\\displaywidowpenalty"; TOKEN=INT_PAR;
+ NAME="\\brokenpenalty"; TOKEN=INT_PAR;
+ NAME="\\predisplaypenalty"; TOKEN=INT_PAR;
+ NAME="\\postdisplaypenalty"; TOKEN=INT_PAR;
+ NAME="\\interlinepenalty"; TOKEN=INT_PAR;
+ NAME="\\floatingpenalty"; TOKEN=INT_PAR;
+ NAME="\\outputpenalty"; TOKEN=INT_PAR;
+ NAME="\\doublehyphendemerits"; TOKEN=INT_PAR;
+ NAME="\\finalhyphendemerits"; TOKEN=INT_PAR;
+ NAME="\\adjdemerits"; TOKEN=INT_PAR;
+ NAME="\\looseness"; TOKEN=INT_PAR;
+ NAME="\\pausing"; TOKEN=INT_PAR;
+ NAME="\\tracingonline"; TOKEN=INT_PAR;
+ NAME="\\tracingmacros"; TOKEN=INT_PAR;
+ NAME="\\tracingstats"; TOKEN=INT_PAR;
+ NAME="\\tracingparagraphs"; TOKEN=INT_PAR;
+ NAME="\\tracingpages"; TOKEN=INT_PAR;
+ NAME="\\tracingoutput"; TOKEN=INT_PAR;
+ NAME="\\tracinglostchars"; TOKEN=INT_PAR;
+ NAME="\\tracingcommands"; TOKEN=INT_PAR;
+ NAME="\\tracingrestores"; TOKEN=INT_PAR;
+ NAME="\\uchyph"; TOKEN=INT_PAR;
+ NAME="\\globaldefs"; TOKEN=INT_PAR;
+ NAME="\\defaulthyphenchar"; TOKEN=INT_PAR;
+ NAME="\\defaultskewchar"; TOKEN=INT_PAR;
+ NAME="\\escapechar"; TOKEN=INT_PAR;
+ NAME="\\endlinechar"; TOKEN=INT_PAR;
+ NAME="\\newlinechar"; TOKEN=INT_PAR;
+ NAME="\\maxdeadcycles"; TOKEN=INT_PAR;
+ NAME="\\hangafter"; TOKEN=INT_PAR;
+ NAME="\\fam"; TOKEN=INT_PAR;
+ NAME="\\mag"; TOKEN=INT_PAR;
+ NAME="\\delimiterfactor"; TOKEN=INT_PAR;
+ NAME="\\time"; TOKEN=INT_PAR;
+ NAME="\\day"; TOKEN=INT_PAR;
+ NAME="\\month"; TOKEN=INT_PAR;
+ NAME="\\year"; TOKEN=INT_PAR;
+ NAME="\\showboxbreadth"; TOKEN=INT_PAR;
+ NAME="\\showboxdepth"; TOKEN=INT_PAR;
+
+ NAME="\\hfuzz"; TOKEN=DIMEN_PAR;
+ NAME="\\vfuzz"; TOKEN=DIMEN_PAR;
+ NAME="\\overfullrule"; TOKEN=DIMEN_PAR;
+ NAME="\\hsize"; TOKEN=DIMEN_PAR;
+ NAME="\\vsize"; TOKEN=DIMEN_PAR;
+ NAME="\\maxdepth"; TOKEN=DIMEN_PAR;
+ NAME="\\splitmaxdepth"; TOKEN=DIMEN_PAR;
+ NAME="\\boxmaxdepth"; TOKEN=DIMEN_PAR;
+ NAME="\\lineskiplimit"; TOKEN=DIMEN_PAR;
+ NAME="\\delimitershortfall"; TOKEN=DIMEN_PAR;
+ NAME="\\nulldelimiterspace"; TOKEN=DIMEN_PAR;
+ NAME="\\scriptspace"; TOKEN=DIMEN_PAR;
+ NAME="\\mathsurround"; TOKEN=DIMEN_PAR;
+ NAME="\\predisplaysize"; TOKEN=DIMEN_PAR;
+ NAME="\\displaywidth"; TOKEN=DIMEN_PAR;
+ NAME="\\displayindent"; TOKEN=DIMEN_PAR;
+ NAME="\\parindent"; TOKEN=DIMEN_PAR;
+ NAME="\\hangindent"; TOKEN=DIMEN_PAR;
+ NAME="\\hoffset"; TOKEN=DIMEN_PAR;
+ NAME="\\voffset"; TOKEN=DIMEN_PAR;
+
+ NAME="\\baselineskip"; TOKEN=GLUE_PAR;
+ NAME="\\lineskip"; TOKEN=GLUE_PAR;
+ NAME="\\parskip"; TOKEN=GLUE_PAR;
+ NAME="\\abovedisplayskip"; TOKEN=GLUE_PAR;
+ NAME="\\abovedisplayshortskip"; TOKEN=GLUE_PAR;
+ NAME="\\belowdisplayskip"; TOKEN=GLUE_PAR;
+ NAME="\\belowdisplayshortskip"; TOKEN=GLUE_PAR;
+ NAME="\\leftskip"; TOKEN=GLUE_PAR;
+ NAME="\\rightskip"; TOKEN=GLUE_PAR;
+ NAME="\\topskip"; TOKEN=GLUE_PAR;
+ NAME="\\splittoskip"; TOKEN=GLUE_PAR;
+ NAME="\\tabskip"; TOKEN=GLUE_PAR;
+ NAME="\\spaceskip"; TOKEN=GLUE_PAR;
+ NAME="\\xspaceskip"; TOKEN=GLUE_PAR;
+ NAME="\\parfillskip"; TOKEN=GLUE_PAR;
+
+ NAME="\\thinmuskip"; TOKEN=MUGLUE_PAR;
+ NAME="\\medmuskip"; TOKEN=MUGLUE_PAR;
+ NAME="\\thickmuskip"; TOKEN=MUGLUE_PAR;
+
+ NAME="\\output"; TOKEN=TOKEN_PAR;
+ NAME="\\everypar"; TOKEN=TOKEN_PAR;
+ NAME="\\everymath"; TOKEN=TOKEN_PAR;
+ NAME="\\everydisplay"; TOKEN=TOKEN_PAR;
+ NAME="\\everyhbox"; TOKEN=TOKEN_PAR;
+ NAME="\\everyvbox"; TOKEN=TOKEN_PAR;
+ NAME="\\everyjob"; TOKEN=TOKEN_PAR;
+ NAME="\\everycr"; TOKEN=TOKEN_PAR;
+ NAME="\\errhelp"; TOKEN=TOKEN_PAR;
+
+ NAME="\\TeX"; TOKEN=H_COMMAND;
+ NAME="\\LaTeX"; TOKEN=H_COMMAND;
+
+ NAME="\\dag"; TOKEN=H_COMMAND;
+ NAME="\\ddag"; TOKEN=H_COMMAND;
+ NAME="\\S"; TOKEN=H_COMMAND;
+ NAME="\\P"; TOKEN=H_COMMAND;
+ NAME="\\copyright"; TOKEN=H_COMMAND;
+ NAME="\\pounds"; TOKEN=H_COMMAND;
+
+ NAME="\\begin"; TOKEN=BGIN;
+ NAME="\\end"; TOKEN=END;
+
+ NAME="\\input"; TOKEN=INCLUSION;
+ NAME="\\include"; TOKEN=INCLUSION;
+ NAME="\\includeonly"; TOKEN=INCLUDEONLY;
+
+ NAME="math"; TOKEN=MATHENV;
+ NAME="math*"; TOKEN=MATHENV;
+ NAME="displaymath"; TOKEN=MATHENV;
+ NAME="displaymath*"; TOKEN=MATHENV;
+ NAME="equation"; TOKEN=MATHENV;
+ NAME="equation*"; TOKEN=MATHENV;
+ NAME="eqnarray"; TOKEN=MATHENV;
+ NAME="eqnarray*"; TOKEN=MATHENV;
+
+ NAME="\\\\"; TOKEN=HO_COMMAND;
+ NAME="\\\\*"; TOKEN=HO_COMMAND;
+
+ NAME="\\today"; TOKEN=H_COMMAND;
+
+ NAME="\\noindent"; TOKEN=H_COMMAND;
+ NAME="\\indent"; TOKEN=H_COMMAND;
+ NAME="\\par"; TOKEN=H_COMMAND;
+ NAME="\\linewidth"; TOKEN=LATEX_PAR;
+ NAME="\\baselinestretch"; TOKEN=LATEX_PAR;
+
+ NAME="\\footnote"; TOKEN=KO1_COMMAND;
+ NAME="\\footnotemark"; TOKEN=HO_COMMAND;
+ NAME="\\footnotetext"; TOKEN=KO1_COMMAND;
+ NAME="\\footnotesep"; TOKEN=H_COMMAND;
+ NAME="\\footnoterule"; TOKEN=H_COMMAND;
+
+ NAME="\\part"; TOKEN=KO1_COMMAND;
+ NAME="\\chapter"; TOKEN=KO1_COMMAND;
+ NAME="\\section"; TOKEN=KO1_COMMAND;
+ NAME="\\subsection"; TOKEN=KO1_COMMAND;
+ NAME="\\subsubsection"; TOKEN=KO1_COMMAND;
+ NAME="\\paragraph"; TOKEN=KO1_COMMAND;
+ NAME="\\subparagraph"; TOKEN=KO1_COMMAND;
+
+ NAME="\\part*"; TOKEN=K1_COMMAND;
+ NAME="\\chapter*"; TOKEN=K1_COMMAND;
+ NAME="\\section*"; TOKEN=K1_COMMAND;
+ NAME="\\subsection*"; TOKEN=K1_COMMAND;
+ NAME="\\subsubsection*"; TOKEN=K1_COMMAND;
+ NAME="\\paragraph*"; TOKEN=K1_COMMAND;
+ NAME="\\subparagraph*"; TOKEN=K1_COMMAND;
+
+ NAME="\\appendix"; TOKEN=H_COMMAND;
+ NAME="\\tableofcontents"; TOKEN=H_COMMAND;
+ NAME="\\listoffigures"; TOKEN=H_COMMAND;
+ NAME="\\listoftables"; TOKEN=H_COMMAND;
+
+ NAME="\\addcontentsline"; TOKEN=H3_COMMAND;
+ NAME="\\addtocontents"; TOKEN=H2_COMMAND;
+
+ NAME="\\documentstyle"; TOKEN=HO1_COMMAND;
+ NAME="\\bibindent"; TOKEN=LATEX_PAR;
+ NAME="\\columnsep"; TOKEN=LATEX_PAR;
+ NAME="\\columnseprule"; TOKEN=LATEX_PAR;
+ NAME="\\mathindent"; TOKEN=LATEX_PAR;
+
+ NAME="\\pagestyle"; TOKEN=H1_COMMAND;
+ NAME="\\thispagestyle"; TOKEN=H_COMMAND;
+ NAME="\\markright"; TOKEN=H1_COMMAND;
+ NAME="\\markboth"; TOKEN=H2_COMMAND;
+ NAME="\\pagenumbering"; TOKEN=H1_COMMAND;
+ NAME="\\twocolumn"; TOKEN=HO_COMMAND;
+ NAME="\\onecolumn"; TOKEN=H_COMMAND;
+ NAME="\\oddsidemargin"; TOKEN=LATEX_PAR;
+ NAME="\\evensidemargin"; TOKEN=LATEX_PAR;
+ NAME="\\topmargin"; TOKEN=LATEX_PAR;
+ NAME="\\headheight"; TOKEN=LATEX_PAR;
+ NAME="\\headsep"; TOKEN=LATEX_PAR;
+ NAME="\\textheight"; TOKEN=LATEX_PAR;
+ NAME="\\textwidth"; TOKEN=LATEX_PAR;
+ NAME="\\footheight"; TOKEN=LATEX_PAR;
+ NAME="\\footskip"; TOKEN=LATEX_PAR;
+
+ NAME="\\maketitle"; TOKEN=H_COMMAND;
+ NAME="\\title"; TOKEN=K1_COMMAND;
+ NAME="\\author"; TOKEN=K1_COMMAND;
+ NAME="\\date"; TOKEN=K1_COMMAND;
+ NAME="\\thanks"; TOKEN=K1_COMMAND;
+
+ NAME="document"; TOKEN=TEXTENV;
+ NAME="abstract"; TOKEN=TEXTENV;
+ NAME="titlepage"; TOKEN=TEXTENV;
+ NAME="quote"; TOKEN=TEXTENV;
+ NAME="quotation"; TOKEN=TEXTENV;
+ NAME="verse"; TOKEN=TEXTENV;
+ NAME="itemize"; TOKEN=TEXTENV;
+ NAME="enumerate"; TOKEN=TEXTENV;
+ NAME="description"; TOKEN=TEXTENV;
+ NAME="em"; TOKEN=TEXTENV;
+
+ NAME="\\item"; TOKEN=HO_COMMAND;
+
+ NAME="list"; TOKEN=LISTENV;
+ NAME="\\topsep"; TOKEN=LATEX_PAR;
+ NAME="\\partopsep"; TOKEN=LATEX_PAR;
+ NAME="\\itemsep"; TOKEN=LATEX_PAR;
+ NAME="\\parsep"; TOKEN=LATEX_PAR;
+ NAME="\\leftmargin"; TOKEN=LATEX_PAR;
+ NAME="\\rightmargin"; TOKEN=LATEX_PAR;
+ NAME="\\listparindent"; TOKEN=LATEX_PAR;
+ NAME="\\itemindent"; TOKEN=LATEX_PAR;
+ NAME="\\labelsep"; TOKEN=LATEX_PAR;
+ NAME="\\labelwidth"; TOKEN=LATEX_PAR;
+ NAME="\\makelabel"; TOKEN=H1_COMMAND;
+ NAME="\\usecounter"; TOKEN=H1_COMMAND;
+ NAME="trivlist"; TOKEN=LISTENV;
+
+ NAME="\\verb"; TOKEN=VERB;
+ NAME="\\verb*"; TOKEN=VERB;
+ NAME="verbatim"; TOKEN=VERBATIM;
+ NAME="verbatim*"; TOKEN=VERBATIM;
+
+ NAME="\\newcommand"; TOKEN=LATEX_DEF;
+ NAME="\\renewcommand"; TOKEN=LATEX_DEF;
+
+ NAME="\\newenvironment"; TOKEN=LATEX_DEFENV;
+ NAME="\\renewenvironment"; TOKEN=LATEX_DEFENV;
+
+ NAME="\\newtheorem"; TOKEN=H2O_COMMAND;
+ NAME="\\renewtheorem"; TOKEN=H1O1_COMMAND;
+
+ NAME="\\newcounter"; TOKEN=H1O_COMMAND;
+ NAME="\\setcounter"; TOKEN=H2_COMMAND;
+ NAME="\\addtocounter"; TOKEN=H2_COMMAND;
+
+ NAME="\\value"; TOKEN=H1_COMMAND;
+ NAME="\\arabic"; TOKEN=H1_COMMAND;
+ NAME="\\roman"; TOKEN=H1_COMMAND;
+ NAME="\\Roman"; TOKEN=H1_COMMAND;
+ NAME="\\alph"; TOKEN=H1_COMMAND;
+ NAME="\\Alph"; TOKEN=H1_COMMAND;
+ NAME="\\fnsymbol"; TOKEN=H1_COMMAND;
+ NAME="\\stepcounter"; TOKEN=H1_COMMAND;
+ NAME="\\refstepcounter"; TOKEN=H1_COMMAND;
+
+ NAME="figure"; TOKEN=FIGENV;
+ NAME="figure*"; TOKEN=FIGENV;
+ NAME="table"; TOKEN=FIGENV;
+ NAME="table*"; TOKEN=FIGENV;
+
+ NAME="\\caption"; TOKEN=KO1_COMMAND;
+
+ NAME="\\topfraction"; TOKEN=LATEX_PAR;
+ NAME="\\bottomfraction"; TOKEN=LATEX_PAR;
+ NAME="\\textfraction"; TOKEN=LATEX_PAR;
+ NAME="\\floatpagefraction"; TOKEN=LATEX_PAR;
+ NAME="\\dbltopfraction"; TOKEN=LATEX_PAR;
+ NAME="\\dblfloatpagefraction"; TOKEN=LATEX_PAR;
+ NAME="\\floatsep"; TOKEN=LATEX_PAR;
+ NAME="\\textfloatsep"; TOKEN=LATEX_PAR;
+ NAME="\\intextsep"; TOKEN=LATEX_PAR;
+ NAME="\\dblfloatsep"; TOKEN=LATEX_PAR;
+ NAME="\\dbltextfloatsep"; TOKEN=LATEX_PAR;
+
+ NAME="\\marginpar"; TOKEN=HO1_COMMAND;
+ NAME="\\reversemarginpar"; TOKEN=H_COMMAND;
+ NAME="\\normalmarginpar"; TOKEN=H_COMMAND;
+ NAME="\\marginparwidth"; TOKEN=H_COMMAND;
+ NAME="\\marginparsep"; TOKEN=H_COMMAND;
+ NAME="\\marginparpush"; TOKEN=H_COMMAND;
+
+ NAME="tabbing"; TOKEN=TABBENV;
+
+ NAME="array"; TOKEN=TABUENV;
+ NAME="array*"; TOKEN=TABUENV;
+ NAME="tabular"; TOKEN=TABUENV;
+ NAME="tabular*"; TOKEN=TABUENV;
+
+ NAME="\\multicolumn"; TOKEN=H3_COMMAND;
+ NAME="\\vline"; TOKEN=H_COMMAND;
+ NAME="\\hline"; TOKEN=H_COMMAND;
+ NAME="\\cline"; TOKEN=H1_COMMAND;
+
+ NAME="\\arraycolsep"; TOKEN=LATEX_PAR;
+ NAME="\\tabcolsep"; TOKEN=LATEX_PAR;
+ NAME="\\arrayrulewidth"; TOKEN=LATEX_PAR;
+ NAME="\\doublerulesep"; TOKEN=LATEX_PAR;
+ NAME="\\arraystretch"; TOKEN=LATEX_PAR;
+
+ NAME="\\label"; TOKEN=H1_COMMAND;
+ NAME="\\ref"; TOKEN=H1_COMMAND;
+ NAME="\\pageref"; TOKEN=H1_COMMAND;
+
+ NAME="\\bibliography"; TOKEN=H1_COMMAND;
+ NAME="thebibliography"; TOKEN=BIBLENV;
+ NAME="\\bibitem"; TOKEN=HO1_COMMAND;
+ NAME="\\cite"; TOKEN=HO1_COMMAND;
+ NAME="\\nocite"; TOKEN=H1_COMMAND;
+
+ NAME="theindex"; TOKEN=INDENV;
+ NAME="\\makeindex"; TOKEN=H_COMMAND;
+ NAME="\\makeglossary"; TOKEN=H_COMMAND;
+ NAME="\\index"; TOKEN=K1_COMMAND;
+ NAME="\\glossary"; TOKEN=K1_COMMAND;
+
+ NAME="\\typeout"; TOKEN=H1_COMMAND;
+ NAME="\\typein"; TOKEN=HO1_COMMAND;
+
+ NAME="\\linebreak"; TOKEN=HO_COMMAND;
+ NAME="\\nolinebreak"; TOKEN=HO_COMMAND;
+
+ NAME="\\newline"; TOKEN=H_COMMAND;
+ NAME="\\hyphenation"; TOKEN=H1_COMMAND;
+ NAME="\\sloppy"; TOKEN=H_COMMAND;
+ NAME="\\fussy"; TOKEN=H_COMMAND;
+
+ NAME="sloppypar"; TOKEN=SLOPENV;
+
+ NAME="\\pagebreak"; TOKEN=HO_COMMAND;
+ NAME="\\nopagebreak"; TOKEN=HO_COMMAND;
+ NAME="\\samepage"; TOKEN=H_COMMAND;
+ NAME="\\newpage"; TOKEN=H_COMMAND;
+ NAME="\\clearpage"; TOKEN=H_COMMAND;
+ NAME="\\cleardoublepage"; TOKEN=H_COMMAND;
+
+ NAME="\\fill"; TOKEN=H_COMMAND;
+ NAME="\\stretch"; TOKEN=H1_COMMAND;
+ NAME="\\newlength"; TOKEN=H1_COMMAND;
+ NAME="\\setlength"; TOKEN=H2_COMMAND;
+ NAME="\\addtolength"; TOKEN=H2_COMMAND;
+ NAME="\\settowidth"; TOKEN=H2_COMMAND;
+
+ NAME="\\hspace"; TOKEN=H1_COMMAND;
+ NAME="\\hspace*"; TOKEN=H1_COMMAND;
+ NAME="\\vspace"; TOKEN=H1_COMMAND;
+ NAME="\\vspace*"; TOKEN=H1_COMMAND;
+ NAME="\\bigskip"; TOKEN=H_COMMAND;
+ NAME="\\medskip"; TOKEN=H_COMMAND;
+ NAME="\\smallskip"; TOKEN=H_COMMAND;
+ NAME="\\addvspace"; TOKEN=H1_COMMAND;
+
+ NAME="\\mbox"; TOKEN=BOX;
+ NAME="\\hbox"; TOKEN=BOX;
+ NAME="\\vbox"; TOKEN=BOX;
+ NAME="\\htop"; TOKEN=BOX;
+ NAME="\\fbox"; TOKEN=BOX;
+
+ NAME="\\makebox"; TOKEN=HOO1_COMMAND;
+ NAME="\\framebox"; TOKEN=HOO1_COMMAND;
+ NAME="\\newsavebox"; TOKEN=H1_COMMAND;
+ NAME="\\sbox"; TOKEN=H2_COMMAND;
+ NAME="\\savebox"; TOKEN=H1OO1_COMMAND;
+ NAME="\\usebox"; TOKEN=H1_COMMAND;
+ NAME="\\parbox"; TOKEN=HO2_COMMAND;
+
+ NAME="minipage"; TOKEN=MINIENV;
+ NAME="\\rule"; TOKEN=HO2_COMMAND;
+ NAME="\\raisebox"; TOKEN=H1O1O_COMMAND;
+
+ NAME="\\fboxrule"; TOKEN=LATEX_PAR;
+ NAME="\\fboxsep"; TOKEN=LATEX_PAR;
+
+ NAME="picture"; TOKEN=PICTENV;
+
+ NAME="\\rm"; TOKEN=H_COMMAND;
+ NAME="\\em"; TOKEN=H_COMMAND;
+ NAME="\\bf"; TOKEN=H_COMMAND;
+ NAME="\\it"; TOKEN=H_COMMAND;
+ NAME="\\sl"; TOKEN=H_COMMAND;
+ NAME="\\sf"; TOKEN=H_COMMAND;
+ NAME="\\sc"; TOKEN=H_COMMAND;
+ NAME="\\tt"; TOKEN=H_COMMAND;
+
+ NAME="\\tiny"; TOKEN=H_COMMAND;
+ NAME="\\small"; TOKEN=H_COMMAND;
+ NAME="\\large"; TOKEN=H_COMMAND;
+ NAME="\\huge"; TOKEN=H_COMMAND;
+ NAME="\\scriptsize"; TOKEN=H_COMMAND;
+ NAME="\\normalsize"; TOKEN=H_COMMAND;
+ NAME="\\Large"; TOKEN=H_COMMAND;
+ NAME="\\Huge"; TOKEN=H_COMMAND;
+ NAME="\\footnotesize"; TOKEN=H_COMMAND;
+ NAME="\\LARGE"; TOKEN=H_COMMAND;
+
+ NAME="\\quad"; TOKEN=H_COMMAND;
+ NAME="\\qquad"; TOKEN=H_COMMAND;
+ NAME="\\dots"; TOKEN=H_COMMAND;
+ NAME="\\ldots"; TOKEN=H_COMMAND;
+ NAME="\\centering"; TOKEN=H_COMMAND;
+ NAME="\\raggedright"; TOKEN=H_COMMAND;
+ NAME="\\raggedleft"; TOKEN=H_COMMAND;
+ NAME="\\break"; TOKEN=H_COMMAND;
+ NAME="\\kill"; TOKEN=H_COMMAND;
+
+ NAME="\\newfont"; TOKEN=H2_COMMAND;
+ NAME="\\symbol"; TOKEN=H1_COMMAND;
+ NAME="\\load"; TOKEN=H2_COMMAND;
+
+ NAME="\\displaystyle"; TOKEN=H_COMMAND;
+ NAME="\\textstyle"; TOKEN=H_COMMAND;
+ NAME="\\scriptstyle"; TOKEN=H_COMMAND;
+ NAME="\\scriptscriptstyle"; TOKEN=H_COMMAND;
+ NAME="\\boldmath"; TOKEN=H_COMMAND;
+ NAME="\\unboldmath"; TOKEN=H_COMMAND;
+
+ NAME="\\dotfill"; TOKEN=H_COMMAND;
+
+ NAME="\\line"; TOKEN=H1_COMMAND;
+ NAME="\\hfil"; TOKEN=H_COMMAND;
+ NAME="\\hfill"; TOKEN=H_COMMAND;
+ NAME="\\vfil"; TOKEN=H_COMMAND;
+ NAME="\\vfill"; TOKEN=H_COMMAND;
+ NAME="\\vskip"; TOKEN=H1_COMMAND;
+ NAME="\\eject"; TOKEN=H_COMMAND;
+ NAME="\\bye"; TOKEN=H_COMMAND;
+ NAME="\\centerline"; TOKEN=H1_COMMAND;
+ NAME="\\nopagenumbers"; TOKEN=H_COMMAND;
+
+ NAME="$"; TOKEN=DOLLAR;
+ NAME="$$"; TOKEN=DDOLLAR;
+ NAME="\\("; TOKEN=OPARE;
+ NAME="\\)"; TOKEN=CPARE;
+ NAME="\\["; TOKEN=OBRAC;
+ NAME="\\]"; TOKEN=CBRAC;
+
+ n_symbol=n;
+ /* sort list */
+ qsort((char *)symbol, n_symbol, sizeof(symbol_t), symbol_tcmp);
+
+ /* envrt names given with -e option */
+
+ /* search for already existing names */
+ for (i=0; i<n_envrt; i++) {
+ s_fake.name=envrt[i];
+ s_fake.token=UNKNOWN;
+ r=(symbol_t *)
+bsearch(&s_fake, symbol, n_symbol, sizeof(symbol_t), symbol_tcmp);
+ if (r!=(symbol_t *)NULL) {
+ r->token=MATHENV;
+ envrt[i]=(char *)NULL;
+ }
+ }
+
+ /* add new names */
+ n_adsymbol=0;
+ for (i=0; i<n_envrt; i++) {
+ if (envrt[i]!=(char *)NULL) {
+ symbol[n].name=strdup(envrt[i]);
+ symbol[n++].token=MATHENV;
+
+ adsymbol[n_adsymbol].name=symbol[n].name;
+ adsymbol[n_adsymbol++].token=MATHENV;
+ }
+ }
+ n_symbol=n;
+ qsort((char *)symbol, n_symbol, sizeof(symbol_t), symbol_tcmp);
+}
+
+/*
+ * add a new symbol to list
+ */
+int add_symbol(s)
+symbol_t *s;
+{
+ int i;
+
+ symbol[n_symbol].name=strdup(s->name);
+ symbol[n_symbol++].token=s->token;
+ adsymbol[n_adsymbol].name=symbol[n_symbol-1].name;
+ adsymbol[n_adsymbol++].token=s->token;
+
+ qsort((char *)symbol, n_symbol, sizeof(symbol_t), symbol_tcmp);
+ return(n_symbol);
+}
+
+/*
+ * search command s in list
+ */
+int s_lookup(s)
+char *s;
+{
+ int i, t;
+ symbol_t s_fake, *r;
+
+ s_fake.name=s;
+ s_fake.token=UNKNOWN;
+
+ r=(symbol_t *)
+bsearch(&s_fake, symbol, n_symbol, sizeof(symbol_t), symbol_tcmp);
+
+ if (r!=(symbol_t *)NULL) {
+ t=r->token;
+ } else {
+ t=UNKNOWN;
+ if (mode!=1) {
+ add_symbol(&s_fake);
+ if (d_unknown) {
+ if (s[0]=='\\')
+ fprintf(stderr, "unknown command: %s\n", s);
+ else
+ fprintf(stderr, "unknown keyword: %s\n", s);
+ }
+ } }
+
+ return (t);
+}
+
+/*
+ * supplied yywrap function
+ */
+int yywrap()
+{
+ char *last_string;
+ char last_char;
+
+ fclose(*f_in);
+ total_lines+=lineno;
+ if (d_report) {
+ if (strcmp("", f_name)!=0) {
+ fprintf(stderr, "%s: %d lines\n", f_name, lineno);
+ } }
+ if (strcmp("", f_name)!=0)
+ str_destroy(fich_name(f_read()));
+#ifdef FLEX_SCANNER
+ last_string=(f_read())->last_string;
+#else
+ last_char=(f_read())->last_char;
+#endif
+ lineno=fich_line(f_pop());
+ if (d_fname==0) d_fname=-1;
+ if (is_f_stack_empty()) {
+ return(1);
+ } else {
+ *f_in=fich_fd(f_read());
+ f_name=fich_name(f_read());
+#ifdef FLEX_SCANNER
+ if (last_string!=(char *)NULL) {
+ tmp_buf=strdup(last_string);
+ free(last_string);
+ }
+#else
+ if (last_char!=(char)NULL) unput(last_char);
+#endif
+ /*yy_ch_buf[0]=last_char;*/
+ /*lineno=fich_line(f_read());*/
+ return(0);
+ }
+}
+
+
+
+#ifdef FLEX_SCANNER
+char *Input() {
+ char *r;
+
+ *yy_c_buf_p=yy_hold_char;
+ r=strdup(yy_c_buf_p);
+ *yy_c_buf_p='\0';
+ return(r);
+}
+
+/*
+ * input function normally used with flex
+ * yy_input1 is not a macro, but with flex input is bufferized
+ */
+int yy_input1(buf, max_size)
+char *buf;
+int max_size;
+{
+ int result;
+
+ if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) {
+ perror((char *)NULL);
+ YY_FATAL_ERROR( "read() in flex scanner failed" );
+ }
+ return (result);
+}
+
+/*
+ * input function used when, having finished to read an included
+ * file, flex come back and retrieve the precedent file
+ */
+int yy_input2(buf, max_size)
+char *buf;
+int max_size;
+{
+ int l;
+
+ l=strlen(tmp_buf);
+ if (l>0) strcpy(buf, tmp_buf);
+ free(tmp_buf);
+ yy_input=yy_input1;
+ return(l);
+}
+
+/*
+ * this procedure is a portion of the lex.yy.c program generated by flex
+ * its aim is to initialize the buffer before starting reading a new file
+ * (it corresponds to action done by YY_NEW_FILE)
+ */
+inclusion_file()
+{
+ /* this is where we enter upon encountering an end-of-file and
+ * yywrap() indicating that we should continue processing
+ */
+
+ /* we put in the '\n' and start reading from [1] so that an
+ * initial match-at-newline will be true.
+ */
+
+ yy_ch_buf[0] = '\n';
+ yy_n_chars = 1;
+
+ /* we always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+ yy_eof_has_been_seen = 0;
+
+ yytext = yy_c_buf_p = &yy_ch_buf[1];
+ yy_hold_char = *yy_c_buf_p;
+ yy_init = 0;
+}
+
+#else
+
+/*
+ * read next input character
+ */
+char Input() {
+ return input();
+}
+
+inclusion_file()
+{}
+
+#endif
diff --git a/support/xetal/main.c b/support/xetal/main.c
new file mode 100644
index 0000000000..25b7855eee
--- /dev/null
+++ b/support/xetal/main.c
@@ -0,0 +1,344 @@
+/*
+ main function of xetal,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "proto.h"
+
+/*
+ * main
+ */
+
+main(argc, argv)
+int argc;
+char **argv;
+{
+ extern char *optarg;
+ extern int optind;
+
+ int i, j, c;
+ /* option flags */
+ int Aflg, aflg, bflg, Cflg, cflg, dflg;
+ int eflg, Eflg, errflg, Fflg, fflg, gflg, hflg;
+ int iflg, jflg, Mflg, mflg, Nflg, nflg;
+ int oflg, pflg, rflg, Sflg, sflg, tflg;
+ int uflg, wflg, zflg;
+ char *nN, *el;
+ char i_name[W_LGTH];
+
+
+#ifdef MALDEBUG
+ malloc_debug(2);
+#endif
+
+ if ((devnull=fopen("/dev/null", "w"))==(FILE *)NULL) {
+ fprintf(stderr, "Can't open /dev/null\n");
+ exit(2);
+ }
+
+/*
+ * default options
+ */
+
+ d_accent=0;
+ d_bl=1;
+ d_bls=1;
+ d_comment=0;
+ d_command=0;
+ d_error=1;
+ d_fname=1;
+ d_macrodef=0;
+ d_math=0;
+ d_mot=1;
+ d_nl=1;
+ d_operator=1;
+ d_punct=1;
+ d_report=0;
+ d_slashed=1;
+ d_special=1;
+ d_text=1;
+ d_unknown=0;
+ d_warning=1;
+ do_fill=1;
+ do_fill_acco=0;
+ do_fill_slash=0;
+ do_incl=1;
+ c_fill=' ';
+ s_accent=(char)0;
+ n_nl=0;N=0;
+
+/*
+ * options handling
+ */
+
+ Aflg=aflg=bflg=Cflg=cflg=dflg=eflg=Eflg=errflg=0;
+ Fflg=fflg=gflg=hflg=iflg=jflg=Mflg=mflg=Nflg=0;
+ nflg=oflg=pflg=rflg=Sflg=sflg=tflg=uflg=wflg=0;
+ zflg=0;
+while ((c = getopt(argc, argv, "a:AbcCde:Ef:FghijmMn:oNpsSrtuwz")) != -1)
+ switch (c) {
+ case 'A':
+ Aflg=1;
+ break;
+ case 'a':
+ aflg=1;
+ s_accent = optarg[0];
+ break;
+ case 'b':
+ bflg=1;
+ break;
+ case 'C':
+ Cflg=1;
+ break;
+ case 'c':
+ cflg=1;
+ break;
+ case 'd':
+ dflg=1;
+ break;
+ case 'e':
+ eflg=1;
+ el=strdup(optarg);
+ break;
+ case 'E':
+ Eflg=1;
+ break;
+ case 'F':
+ Fflg=1;
+ break;
+ case 'f':
+ fflg=1;
+ c_fill = optarg[0];
+ break;
+ case 'g':
+ gflg=1;
+ break;
+ case 'h':
+ hflg=1;
+ break;
+ case 'i':
+ iflg=1;
+ break;
+ case 'j':
+ jflg=1;
+ break;
+ case 'M':
+ Mflg=1;
+ break;
+ case 'm':
+ mflg=1;
+ break;
+ case 'N':
+ Nflg=1;
+ break;
+ case 'n':
+ nflg=1;
+ nN = optarg;
+ break;
+ case 'o':
+ oflg=1;
+ break;
+ case 'p':
+ pflg=1;
+ break;
+ case 'r':
+ rflg=1;
+ break;
+ case 'S':
+ Sflg=1;
+ break;
+ case 's':
+ sflg=1;
+ break;
+ case 't':
+ tflg=1;
+ break;
+ case 'u':
+ uflg=1;
+ break;
+ case 'w':
+ wflg=1;
+ break;
+ case 'z':
+ zflg=1;
+ break;
+ case '?':
+ errflg++;
+ }
+ if (hflg) {
+ fprintf(stderr, "usage:");
+ fprintf(stderr,
+ "xetal \-\[a:AbcCde:Ef:FghijmMn:oNpsSrtuwz\] \[file1\] \[file2\] ...\n");
+ exit (2);
+ }
+
+ /* test for .tex suffix */
+ for (i=optind; i < argc; i++) {
+ strcpy(i_name, argv[i]);strcat(i_name, ".tex");
+ if (access(argv[i], R_OK) && access(i_name, R_OK)) {
+ fprintf(stderr,"Can't access file: %s\n", argv[i]);
+ exit(2);
+ }
+ }
+
+ if (Aflg) { d_accent=!d_accent; s_accent=(char)NULL; }
+ if (aflg) d_accent=!d_accent;
+ if (bflg) d_bls=!d_bls;
+ if (cflg) d_command=!d_command;
+ if (Cflg) d_comment=!d_comment;
+ if (Eflg) d_error=!d_error;
+ if (Fflg) do_fill=0;
+ if (gflg) do_fill_acco=1;
+ if (iflg) do_incl=0;
+ if (jflg);
+ if (mflg) d_math=!d_math;
+ if (Nflg) d_fname=-1;
+ if (nflg) { N=atoi(nN); n_nl=1; if (N==0) n_nl=0; }
+ if (oflg) d_macrodef=!d_macrodef;
+ if (pflg) d_punct=!d_punct;
+ if (rflg) d_report=!d_report;
+ if (sflg) d_special=!d_special;
+ if (tflg) d_text=!d_text;
+ if (uflg) d_unknown=1;
+ if (wflg) d_warning=0;
+ if (zflg) d_anything=!d_anything;
+
+ if (eflg) {
+ char *p=el;
+ if ((envrt[n_envrt++]=strtok(p, ","))!=(char *)NULL) {
+ p=(char *)NULL;
+ while ((envrt[n_envrt++]=strtok(p, ","))!=(char *)NULL);
+ n_envrt--;
+ }
+ }
+ if (Sflg) {
+ d_text=d_command=d_comment=d_accent=0;
+ d_punct=d_special=d_slashed=d_math=0;
+ d_operator=d_bl=d_nl=d_mot=d_punct=0;
+ d_bls=do_fill=n_nl=0;
+ }
+
+/*
+ * initialization of lexical analyzer
+ */
+ init_lex();
+
+/*
+ * initialization of symbol list
+ */
+
+ init_symbol(envrt, n_envrt);
+
+/*
+ * begining of program
+ */
+
+ if (dflg)
+#ifdef YYDEBUG
+ yydebug=1;
+#else
+ {
+fprintf(stderr, "You little joker ! The manual said don't try -d ...\n");
+ exit(2);
+ }
+#endif
+
+#ifdef MALDEBUG
+ if (Mflg) { fprintf(stderr, "mallocmap\n");mallocmap(); }
+#else
+ if (Mflg) { fprintf(stderr, "Sorry, mallocmap not available\n"); }
+#endif
+
+ if (optind==argc) {
+ /* only one file name in argument line */
+ fich_t n_fich;
+ n_fich.name="";
+ n_fich.fd=stdin;
+ n_fich.line=0L;
+ n_fich.last_string=(char *)NULL;
+ n_fich.last_char=(char)NULL;
+ f_push(&n_fich);
+
+ *f_in=stdin;
+ f_name="";
+ lineno=0L;
+
+ if (dflg) fprintf(stderr, "yyparse()==%d\n",yyparse());
+ else yyparse();
+
+ for (j=0; j<n_ionly; j++) {
+ str_destroy(if_name[j]);
+ }
+ n_ionly=-1;
+ } else {
+
+ /* several file names in argument line */
+ for (i=optind; i < argc; i++) {
+ strcpy(i_name, argv[i]);strcat(i_name, ".tex");
+ if ((*f_in=fopen(argv[i], "r"))==(FILE *)NULL) {
+ if ((*f_in=fopen(i_name, "r"))==(FILE *)NULL) {
+ if (d_warning)
+ fprintf(stderr, "\nCan't open file: %s\n", argv[i]);
+ }
+ }
+ if (*f_in!=(FILE *)NULL) {
+ fich_t n_fich;
+
+ n_fich.name=strdup(argv[i]);
+ n_fich.fd=*f_in;
+ n_fich.line=lineno;
+ n_fich.last_string=(char *)NULL;
+ n_fich.last_char=(char)NULL;
+ f_push(&n_fich);
+
+ f_name=n_fich.name;
+ lineno=0L;
+
+ init_lex();
+ if (dflg) fprintf(stderr, "yyparse()==%d\n",yyparse());
+ else yyparse();
+
+ }
+ for (j=0; j<n_ionly; j++) {
+ str_destroy(if_name[j]);
+ }
+ n_ionly=-1;
+ } /* for */
+
+ } /* else */
+
+ for (i=0; i<n_adsymbol; i++) {
+ str_destroy(adsymbol[i].name);
+ }
+
+#ifdef MALDEBUG
+ if (Mflg) { fprintf(stderr, "mallocmap\n");mallocmap(); }
+#else
+ if (Mflg) { fprintf(stderr, "Sorry, mallocmap not available\n"); }
+#endif
+
+ if (d_report) {
+ fprintf(stderr, "*** xetal report ***\n");
+ fprintf(stderr, "%d lines, %d characters\n", total_lines, charpos);
+ fprintf(stderr, "%d formulas\n", n_formule);
+ fprintf(stderr, "%d charaters skipped\n", c_skipped);
+ }
+
+ fclose(devnull);
+}
diff --git a/support/xetal/makefile b/support/xetal/makefile
new file mode 100644
index 0000000000..a2b22bf45d
--- /dev/null
+++ b/support/xetal/makefile
@@ -0,0 +1,91 @@
+# makefile for xetal,
+# Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+# This file is part of xetal.
+
+# This program 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 1, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# 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 this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+# C compiler
+CC=cc
+# Flags for compiler
+# CFLAGS= -g
+CFLAGS= -O -sun4
+
+# Lexical analyser
+LEX=lex
+# LEX=flex
+# Flag to use when with flex
+LEXPGM=
+# LEXPGM=-DFLEX_SCANNER
+# Flags for lexical analyser
+LEXFLAGS=
+# LEXFLAGS=-f
+
+# Parser
+PARSER=yacc
+# PARSER=bison
+# Flags for parser
+PARSFLAGS=-dv
+
+CLIBS=
+# variables to use for debugging
+# FLAGS1=-DYYDEBUG -DMALDEBUG
+FLAGS1=
+# MALLOC=/usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o
+MALLOC=
+
+# object files
+COBJ=str.o stack.o y.tab.o lex.yy.o main.o
+
+# where xetal goes for installation
+BINDIR=/java/home1/cerf/def
+
+all : xetal
+
+install: xetal
+ strip xetal
+ cp xetal xetal.1 $(BINDIR)
+
+clean:
+ rm *.o y.tab.[ch] lex.yy.c y.output xetal
+
+tar:
+ tar cf xetal.tar str.c str.h stack.c stack.h \
+ proto.h glbl.h main.c \
+ l.l y.y makefile xetal.1 \
+ COPYING README
+
+xetal: $(COBJ)
+ $(CC) $(COBJ) $(MALLOC) -ll $(CLIBS) -o xetal
+
+lex.yy.o: l.l y.tab.c
+ $(LEX) $(LEXFLAGS) l.l
+ $(CC) -c lex.yy.c $(CFLAGS) $(FLAGS1)
+
+y.tab.c: y.y proto.h
+ $(PARSER) $(PARSFLAGS) y.y
+
+y.tab.o: y.tab.c
+ $(CC) -c y.tab.c $(CFLAGS) $(FLAGS1) $(LEXPGM)
+
+str.o: str.c str.h proto.h
+ $(CC) -c str.c $(CFLAGS)
+
+stack.o:stack.c stack.h proto.h
+ $(CC) -c stack.c $(CFLAGS)
+
+main.o: main.c proto.h
+ $(CC) -c main.c $(CFLAGS) $(FLAGS1) $(LEXPGM)
diff --git a/support/xetal/proto.h b/support/xetal/proto.h
new file mode 100644
index 0000000000..eb24c5d83b
--- /dev/null
+++ b/support/xetal/proto.h
@@ -0,0 +1,97 @@
+/*
+ declarations of global objects used in xetal,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <malloc.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+
+#define W_LGTH 50 /* maximal word length */
+
+#ifdef FLEX_SCANNER
+extern char *yytext;
+#else
+extern char yytext[];
+#endif
+
+extern int yydebug;
+
+extern int mode; /* current mode 0: normal, 1: math */
+extern int verbatim; /* verbatim mode */
+extern int d_ok; /* display flag */
+extern long lineno; /* current line in source text */
+extern long total_lines;/* total nb of lines handled */
+extern long charpos; /* last char read */
+extern long linepos; /* last \n read */
+extern long oldlpos; /* old value of linepos */
+
+/* output macros here */
+
+extern int n_nl, N;
+extern int n_formule;
+extern long c_skipped;
+extern char c_fill;
+extern char s_accent;
+
+/* options flags */
+extern int d_anything, d_error;
+extern int d_accent, d_bl, d_bls, d_command, d_comment, d_fname;
+extern int d_macrodef, d_math, d_mot, d_nl, d_operator, d_punct;
+extern int d_report, d_slashed, d_special, d_text, d_unknown;
+extern int d_warning, do_fill, do_fill_acco, do_fill_slash, do_incl;
+
+#define O_LGTH 1024
+extern char S[O_LGTH]; /* output buffer */
+
+extern FILE *devnull; /* rubbish-bin */
+
+typedef struct {
+ char *name;
+ FILE *fd;
+ long line;
+ char *last_string;
+ char last_char;
+} fich_t; /* included file */
+
+/* maximal nb of included files */
+#define F_MAX 100
+extern int n_ionly;/* nb of ionly files */
+extern char *if_name[F_MAX]; /* includeonly_files */
+extern char *f_name; /* name of current file */
+extern FILE **f_in; /* input stream */
+
+/* maximal nb of envrt names given with -e option */
+#define M_ENVRT 1000
+extern int n_envrt;
+extern char *(envrt[M_ENVRT]);
+
+/* maximal nb for symbols in list */
+#define M_SYMBOL 10000
+extern int n_symbol;
+typedef struct {
+ char *name;
+ int token;
+} symbol_t;
+extern symbol_t symbol[M_SYMBOL];
+extern int symbol_tcmp();
+
+extern int n_adsymbol;
+extern symbol_t adsymbol[M_SYMBOL];
diff --git a/support/xetal/stack.c b/support/xetal/stack.c
new file mode 100644
index 0000000000..4abc8bd01b
--- /dev/null
+++ b/support/xetal/stack.c
@@ -0,0 +1,135 @@
+/*
+ implementation of two stacks used in xetal,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "proto.h"
+#include "stack.h"
+
+/*
+ * file stack
+ */
+
+char *fich_name(e)
+fich_t *e;
+{
+ return(e->name);
+}
+
+FILE *fich_fd(e)
+fich_t *e;
+{
+ return(e->fd);
+}
+
+long fich_line(e)
+fich_t *e;
+{
+ return(e->line);
+}
+
+fich_t f_stack[F_MAX];
+int f_top=0;
+
+int is_f_stack_empty() {
+ return(f_top==0);
+}
+
+int is_f_stack_full() {
+ return(f_top==F_MAX-1);
+}
+
+fich_t *f_pop() {
+ return( &(f_stack[--f_top]) );
+}
+
+void f_push(e)
+fich_t *e;
+{
+ f_stack[f_top++]=*e;
+}
+
+fich_t *f_read()
+{
+ if (f_top==0) return((fich_t *)0);
+ else return(f_stack+f_top-1);
+
+}
+
+void f_display() {
+ int i;
+ printf("%d elements\n", f_top);
+ for (i=0; i<f_top; i++)
+ printf("%s : %d", fich_name(f_stack+i), fich_line(f_stack+i));
+ printf("\n");
+}
+
+/*
+ * LEX states stack
+ */
+
+int S_stack[S_MAX];
+int S_top=0;
+
+int empty_S_stack() {
+ while(S_top>0) S_pop();
+}
+
+int is_S_stack_empty() {
+ return(S_top==0);
+}
+
+int is_S_stack_full() {
+ return(S_top==S_MAX-1);
+}
+
+int is_S_in_stack(e)
+int e;
+{
+ int i;
+ for (i=0; i<S_top; i++) {
+ if (S_stack[i]==e) break;
+ }
+ if (i<S_top) return 1;
+ else return 0;
+}
+
+int S_pop() {
+ return( S_stack[--S_top] );
+}
+
+void S_push(e)
+int e;
+{
+ S_stack[S_top++]=e;
+}
+
+int S_read()
+{
+ if (S_top==0) return(0);
+ else return(*(S_stack+S_top-1));
+}
+
+void S_display() {
+ int i;
+ printf("%d elements\n", S_top);
+ for (i=0; i<S_top; i++)
+ printf("%d", *(S_stack+i));
+ printf("\n");
+}
diff --git a/support/xetal/stack.h b/support/xetal/stack.h
new file mode 100644
index 0000000000..43e5f0e8eb
--- /dev/null
+++ b/support/xetal/stack.h
@@ -0,0 +1,46 @@
+/*
+ declarations of objects built in stack.c,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#define F_MAX 100 /* max nb of recursively included files */
+
+/* functions to handle the fich_t type */
+extern char *fich_name();
+extern FILE *fich_fd();
+extern long fich_line();
+
+/* classical stack functions */
+extern int is_f_stack_empty();
+extern int is_f_stack_full();
+extern void f_push();
+extern fich_t *f_pop();
+extern fich_t *f_read();
+extern void f_display();
+
+#define S_MAX 100 /* max nb of successive states */
+/* classical stack functions */
+extern int empty_S_stack();
+extern int is_S_stack_empty();
+extern int is_S_stack_full();
+extern int is_S_in_stack();
+extern void S_push();
+extern int S_pop();
+extern int S_read();
+extern void S_display();
diff --git a/support/xetal/str.c b/support/xetal/str.c
new file mode 100644
index 0000000000..ed82c521c2
--- /dev/null
+++ b/support/xetal/str.c
@@ -0,0 +1,49 @@
+/*
+ elementary strings handling,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "str.h"
+
+/*
+ * strings handling
+ */
+
+char *str_create(l)
+int l;
+{
+ return((char *)malloc(l*sizeof(char)));
+}
+
+int str_destroy(s)
+char *s;
+{
+ free(s);
+}
+
+int show_array(a, n)
+char *a[];
+int n;
+{
+ int i;
+
+ for (i=0; i<n; i++) {
+ printf("%d:%s\n", i, a[i]);
+ }
+}
diff --git a/support/xetal/str.h b/support/xetal/str.h
new file mode 100644
index 0000000000..824b7bdacf
--- /dev/null
+++ b/support/xetal/str.h
@@ -0,0 +1,24 @@
+/*
+ declarations of strings functions in str.c,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+extern int show_array();
+extern char *str_create();
+extern int str_destroy();
diff --git a/support/xetal/xetal.1 b/support/xetal/xetal.1
new file mode 100644
index 0000000000..1d033b6eb4
--- /dev/null
+++ b/support/xetal/xetal.1
@@ -0,0 +1,106 @@
+.TH XETAL 1 "1/17/92" "Version 1.2"
+.de BP
+.sp
+.ti -.2i
+\(**
+..
+.SH NAME
+xetal \- a detexifier
+.SH SYNOPSIS
+.B xetal
+[ options ] [ files ]
+.SH DESCRIPTION
+.I XETAL
+removes all commands and mathematical formulas from tex and latex files.
+If no files are specified, xetal reads from its standard input.
+Xetal can also be used to perform elementary syntax checks on tex files.
+It recognizes some basic tex and latex commands.
+.P
+.SH OPTIONS
+.TP
+.B \-a character
+Don't remove accents. Accents will be preceded by "character".
+.TP
+.B \-A
+Don't remove accents. Don't put escape character before accents.
+.TP
+.B \-b
+Replace consecutive blanks by one blank.
+.TP
+.B \-c
+Don't remove commands.
+.TP
+.B \-C
+Don't remove comments.
+.TP
+.B \-d
+Debugging mode. Don't try !
+.TP
+.B \-e label1,label2,...,last_label
+Handle environnements label1, label2, ... as mathematical environnements.
+.TP
+.B \-E
+Disable error messages.
+.TP
+.B \-f character
+Replace deleted words and formulas with "character".
+Default is space.
+.TP
+.B \-F
+Don't replace deleted commands and formulas.
+.TP
+.B \-g
+Replace deleted '{' and '}' by blank or specified replacement character.
+.TP
+.B \-i
+Don't execute \include and \input commands.
+.TP
+.B \-m
+Don't remove mathematical formulas.
+.TP
+.B \-n number
+Numerotate output text every "number" lines. Use -n0 to remove
+numerotation. Default is -n0.
+.TP
+.B \-N
+Write filename only for the first line of each file.
+.TP
+.B \-o
+Display macros definitions.
+.TP
+.B \-p
+Remove punctuation.
+.TP
+.B \-r
+Generate a succint report for the job done.
+.TP
+.B \-S
+Silent mode: no output is produced. This option overrides every other
+output option.
+.TP
+.B \-t
+Remove text.
+.TP
+.B \-u
+Output unknown (non-mathematical) commands.
+.TP
+.B \-w
+Disable warning messages.
+.TP
+.B \-z
+Display text after \\end.
+.sp
+.SH WARNING
+.TP
+Macros definitions are read, but they are not interpreted by xetal.
+Here is the kind of things xetal won't appreciate :
+.sp
+ \\documentstyle[\\docsty}
+.sp
+ {\\obeyspaces\\global\\let =\\ }
+.sp
+Error handling is very crude. In particular, line numbers in error \
+messages aren't very reliable.
+.sp
+.SH BUGS
+Bugs should be reported to cerf (e_mail: cerf@ens.ens.fr).
diff --git a/support/xetal/y.y b/support/xetal/y.y
new file mode 100644
index 0000000000..cb2ecc4d93
--- /dev/null
+++ b/support/xetal/y.y
@@ -0,0 +1,1031 @@
+%{
+
+/*
+ grammar used to build the parser,
+ Copyright (C) 1991 Raphael Cerf (e-mail: cerf@ens.ens.fr)
+
+ This file is part of xetal.
+
+ This program 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 1, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <search.h>
+#include "proto.h"
+#include "glbl.h"
+#include "str.h"
+#include "stack.h"
+
+/* output macros */
+
+/* flag for output */
+#define out (mode!=-1 || d_macrodef) && (mode!=1 || d_math) && d_ok
+
+/* deleted text */
+#define noprint(x) { int i; char *p=S; \
+ sprintf x ; \
+ c_skipped+=strlen(S); \
+ if (do_fill) { \
+ while ((*p!=(char)NULL)) { \
+ if (*p=='\n') ; \
+ else if (*p=='\t') ; \
+ else { \
+ *p=c_fill; \
+ } \
+ p++; \
+ } \
+ fprintf(stdout, "%s", S); \
+ } \
+ }
+
+/* displayed text */
+#define doprint(x) { sprintf x; fprintf(stdout, "%s", S); }
+
+/* general output macro */
+#define print(x, v) { if (out && v) doprint(x) \
+ else noprint(x) }
+
+%}
+
+/*
+ * shift-reduces expected
+ */
+
+/*%expect 108*/
+
+/*
+ * stack type
+ */
+
+%union {
+ char *y_str; /* string */
+ char y_chr; /* character */
+ int y_int; /* integer */
+}
+
+/*
+ * terminal symbols
+ */
+
+%token SLASH
+%token NULL_COMMAND
+%token FFEED OTHER
+%token <y_chr> '{' '}' '[' ']'
+%token <y_str> BLS BLSNL
+%token <y_chr> LETTER DIGIT
+%token <y_chr> SLASHED
+%token <y_str> BGIN END INCLUSION COMMAND UNKNOWN COMMENT
+%token <y_str> VERB VERBATIM
+%token <y_str> DEF CTLSEQ0 CTLSEQ1 CTLSEQ2 CTLSEQ3 CATCODE
+%token <y_str> LATEX_DEF LATEX_DEFENV
+%token <y_str> READ SETBOX FONT
+%token <y_str> ASSIGN
+%token <y_str> LATEX_PAR
+%token <y_str> INT_PAR DIMEN_PAR GLUE_PAR MUGLUE_PAR TOKEN_PAR
+%token <y_str> REGISTER
+%token <y_str> OPERATION
+%token <y_str> BOX
+%token <y_str> DOLLAR DDOLLAR OPARE CPARE OBRAC CBRAC
+%token <y_str> ANYTHING ANY_NOT_SLASH
+%token <y_str> NOMBRE LETTRES CARACTERES REEL FILENAME
+%token <y_str> ACCENT
+%token <y_str> H1O1O_COMMAND
+%token <y_str> H1O1_COMMAND H1O2_COMMAND
+%token <y_str> H1OO1_COMMAND
+%token <y_str> H1O_COMMAND H2O_COMMAND
+%token <y_str> H2_COMMAND H3_COMMAND
+%token <y_str> HO1_COMMAND HO2_COMMAND
+%token <y_str> HOO1_COMMAND
+%token <y_str> HO_COMMAND
+%token <y_str> INCLUDEONLY
+%token <y_str> INDENV SLOPENV MINIENV PICTENV
+%token <y_str> K1_COMMAND H1_COMMAND
+%token <y_str> KO1_COMMAND
+%token <y_str> K_COMMAND H_COMMAND
+%token <y_str> LISTENV FIGENV TABBENV TABUENV BIBLENV
+%token <y_str> MATHENV TEXTENV
+
+/*
+ * non terminal symbols
+ */
+
+%type <y_chr> r_accent
+%type <y_int> def_mode
+%type <y_str> environnement
+%type <y_str> environnement_name
+%type <y_str> lettres, fln
+%type <y_str> filename
+%type <y_str> math_environnement
+%type <y_int> math_mode
+%type <y_chr> operator
+%type <y_chr> signe_ponctuation
+%type <y_chr> special
+%type <y_int> text_mode
+
+%%
+
+tex
+ : start lignes nl
+ | start lignes end start_END lignes start_N
+ ;
+
+start
+ :
+ { start_file(); }
+ ;
+
+lignes
+ :
+ | entites
+ ;
+
+entites
+ : entite
+ | entites entite
+ ;
+
+entite
+ : anything
+ | any_not_slash
+ | mot
+ | phrase
+ | lettre
+ | ponctuation
+ | macro
+ | assignment
+ | catcode_def
+ | commande
+ | commentaire
+ | groupe
+ | separateur
+ | reste
+ | error
+ { empty_S_stack(); mode=0; start_N(); }
+ ;
+
+anything
+ : ANYTHING
+ {
+ print((S, "%s", $1), d_anything);
+ }
+ ;
+
+any_not_slash
+ : ANY_NOT_SLASH
+ {
+ print_seq($1, d_mot && (mode!=0 || d_text));
+ }
+ ;
+
+mot
+ : LETTRES
+ {
+ print((S, "%s", $1), d_mot && (mode!=0 || d_text))
+ }
+ ;
+
+phrase
+ : CARACTERES
+ {
+ print((S, "%s", $1), d_mot && (mode!=0 || d_text))
+ }
+ ;
+
+lettre
+ : LETTER
+ {
+ print((S, "%c", $1), d_mot && (mode!=0 || d_text))
+ }
+ ;
+
+ponctuation
+ : signe_ponctuation
+ {
+ print((S, "%c", $1), d_punct && (mode!=0 || d_text))
+ }
+ ;
+
+signe_ponctuation
+ : '.' { $$='.'; }
+ | ',' { $$=','; }
+ | ';' { $$=';'; }
+ | ':' { $$=':'; }
+ | '!' { $$='!'; }
+ | '?' { $$='?'; }
+ | '`' { $$='`'; }
+ | '\'' { $$='\''; }
+ | SLASH { $$='\\'; }
+ | '\"' { $$='\"'; }
+ ;
+
+macro
+ : start_SQ2 def o_spnl ctlseq o_spnl start_N def_mode oa lignes ca
+ { mode=$7; }
+ | latex_def start_ARG o_spnl hg_argument def_mode ho_argument hg_argument start_N
+ { mode=$5; }
+ | latex_defenv start_ARG o_spnl hg_argument def_mode ho_argument hg_argument o_spnl hg_argument start_N
+ { mode=$5; }
+ ;
+
+start_SQ2
+ :
+ { start_SQ2(); }
+ ;
+
+def
+ : DEF
+ { print((S, "%s", $1), d_command) }
+ ;
+
+o_spnl
+ :
+ | spaces
+ | spaces_newline
+ ;
+
+spaces
+ : BLS
+ { if (d_bls) print((S, "%s", $1), d_bl)
+ else print((S, "%s", " "), d_bl) }
+ ;
+
+spaces_newline
+ : BLSNL
+ { print_blnl($1); }
+ ;
+
+ctlseq
+ : CTLSEQ0
+ { print_seq($1, d_command); }
+ | CTLSEQ1
+ { print_seq($1, d_command); }
+ | CTLSEQ2
+ { print_seq($1, d_command); }
+ | CTLSEQ3
+ { print_seq($1, d_command); }
+ | slashed o_ctlseq
+ ;
+
+slashed
+ : SLASHED
+ { if (!do_fill_slash) print((S, "%c", $1), d_slashed)
+ else print((S, "%c%c", '\\', $1), d_slashed) }
+ ;
+
+o_ctlseq
+ :
+ | ctlseq
+ ;
+
+start_N
+ :
+ { start_N(); }
+ ;
+
+def_mode
+ :
+ { $$=mode; mode=-1; }
+
+oa
+ : '{'
+ { if (do_fill_acco) print((S, "%c", $1), d_command) }
+ ;
+
+ca
+ : '}'
+ { if (do_fill_acco) print((S, "%c", $1), d_command) }
+ ;
+
+latex_def
+ : LATEX_DEF
+ { print((S, "%s", $1), d_command) }
+ ;
+
+start_ARG
+ :
+ { start_ARG(); }
+ ;
+
+hg_argument
+ : d_no entite d_yes
+ ;
+
+ho_argument
+ : o_spnl
+ | o_spnl ob start_O_ARG d_no lignes d_yes cbrac start_N o_spnl
+ ;
+
+start_O_ARG
+ :
+ { start_O_ARG(); }
+ ;
+
+ob
+ : '['
+ { print((S, "%c", '['), d_command) }
+ ;
+
+d_no
+ :
+ { d_ok=0; }
+ ;
+
+d_yes
+ :
+ { d_ok=1; }
+ ;
+
+cbrac
+ : CBRAC
+ { print((S, "%c", ']'), d_command) }
+ ;
+
+latex_defenv
+ : LATEX_DEFENV
+ { print((S, "%s", $1), d_command) }
+ ;
+
+assignment
+ : variable start_CAR def_mode o_spnl equal o_spnl value start_N
+ { mode=$3; }
+ | variable start_CAR def_mode o_spnl start_N
+ { mode=$3; }
+ | operation o_spnl variable start_CAR def_mode o_by value start_N
+ { mode=$5; }
+ | start_SQ1 read o_spnl ctlseq start_N
+ | start_SQ1 setbox o_spnl ctlseq start_N o_spnl o_equal o_spnl entite
+ | start_SQ1 font o_spnl ctlseq start_N o_spnl equal o_spnl filename
+ { str_destroy($9); }
+ | start_SQ3 assign o_spnl o_ctlseq start_N o_spnl def_mode o_equal entite
+ { mode=$7; }
+ ;
+
+variable
+ : LATEX_PAR
+ { print((S, "%s", $1), d_command) }
+ | INT_PAR
+ { print((S, "%s", $1), d_command) }
+ | DIMEN_PAR
+ { print((S, "%s", $1), d_command) }
+ | GLUE_PAR
+ { print((S, "%s", $1), d_command) }
+ | MUGLUE_PAR
+ { print((S, "%s", $1), d_command) }
+ | TOKEN_PAR
+ { print((S, "%s", $1), d_command) }
+ | start_NB register nombre_unknown start_N
+ ;
+
+start_NB
+ :
+ { start_NB(); }
+ ;
+
+register
+ : REGISTER
+ { print((S, "%s", $1), d_command) }
+ ;
+
+nombre_unknown
+ : nombre
+ | unknown_command
+ ;
+
+nombre
+ : NOMBRE
+ { print((S, "%s", $1), d_command) }
+ ;
+
+unknown_command
+ : UNKNOWN
+ { print((S, "%s", $1), d_command) }
+ ;
+
+start_CAR
+ :
+ { start_CAR(); }
+ ;
+
+equal
+ : '='
+ { print((S, "%s", "="), d_command) }
+ ;
+
+value
+ : entite
+ ;
+
+operation
+ : OPERATION
+ { print((S, "%s", $1), d_command) }
+ ;
+
+o_by
+ : o_spnl
+ | o_spnl by o_spnl
+ ;
+
+by
+ : LETTRES
+ {
+ if (strcmp($1, "by")!=0) {
+ fprintf(stderr, "by expected\n");
+ }
+ print((S, "%s", $1), d_command)
+ }
+ ;
+
+start_SQ1
+ :
+ { start_SQ1(); }
+ ;
+
+read
+ : READ
+ { print((S, "%s", $1), d_command) }
+ ;
+
+setbox
+ : SETBOX
+ { print((S, "%s", $1), d_command) }
+ ;
+
+font
+ : FONT
+ { print((S, "%s", $1), d_command) }
+ ;
+
+start_SQ3
+ :
+ { start_SQ3(); }
+ ;
+
+assign
+ : ASSIGN
+ { print((S, "%s", $1), d_command) }
+ ;
+
+o_equal
+ : o_spnl
+ | o_spnl equal o_spnl
+ ;
+
+catcode_def
+ : start_SQ0 catcode ctlseq start_N def_mode o_spnl equal o_spnl value
+ { mode=$5; }
+ ;
+
+start_SQ0
+ :
+ { start_SQ0(); }
+ ;
+
+catcode
+ : CATCODE
+ { print((S, "%s", $1), d_command) }
+ ;
+
+commande
+ : begin_end_section
+ | verb
+ | math
+ | box
+ | accent
+ | s_command
+ | k_command
+ | h_command
+ | ho_command start_ARG ho_argument start_N
+ | k1_command start_ARG o_spnl kg_argument start_N
+ | ko1_command start_ARG ho_argument kg_argument start_N
+ | h1_command start_ARG o_spnl hg_argument start_N
+ | h2_command start_ARG o_spnl hg_argument o_spnl hg_argument start_N
+ | h3_command start_ARG o_spnl hg_argument o_spnl hg_argument o_spnl hg_argument start_N
+ | ho1_command start_ARG ho_argument hg_argument start_N
+ | ho2_command start_ARG ho_argument hg_argument o_spnl hg_argument start_N
+ | h1o1_command start_ARG o_spnl hg_argument ho_argument hg_argument start_N
+ | h1o2_command start_ARG o_spnl hg_argument ho_argument hg_argument o_spnl hg_argument start_N
+ | h1o_command start_ARG o_spnl hg_argument ho_argument start_N
+ | h2o_command start_ARG o_spnl hg_argument o_spnl hg_argument ho_argument start_N
+ | hoo1_command start_ARG ho_argument ho_argument hg_argument start_N
+ | h1oo1_command start_ARG o_spnl hg_argument ho_argument ho_argument hg_argument start_N
+ | h1o1o_command start_ARG o_spnl hg_argument ho_argument hg_argument ho_argument start_N
+ | inclusion
+ | unknown_command
+ ;
+
+begin_end_section
+ : bgin start_BE_ARG o_spnl oa environnement ca lignes end start_BE_ARG o_spnl oa environnement ca
+ { if (strcmp($5, $12)!=0) {
+ fprintf(stderr, "%s | %s not matching in begin_end\n", $5, $12);
+ exit(2);
+ }
+ str_destroy($5);
+ str_destroy($12);
+ }
+ ;
+
+bgin
+ : BGIN
+ { print((S, "%s", $1), d_command) }
+ ;
+
+start_BE_ARG
+ :
+ { start_BE_ARG(); }
+ ;
+
+environnement
+ : environnement_name
+ { $$=strdup($1);
+ print((S, "%s", $1), d_command) }
+ ;
+
+environnement_name
+ : TEXTENV
+ | LISTENV
+ | FIGENV
+ | TABBENV
+ | TABUENV
+ | BIBLENV
+ | INDENV
+ | SLOPENV
+ | MINIENV
+ | PICTENV
+ | VERBATIM
+ | UNKNOWN
+ ;
+
+end
+ : END
+ { print((S, "%s", $1), d_command) }
+ ;
+
+verb
+ : VERB
+ { char *p, sch, o;
+ int l;
+ p=$1+5;/* suppress \verb in string p */
+ if (*p=='*') p++;
+ sch=*p;p++;o=*p;*p=(char)NULL;
+ print((S, "%s", $1), d_command)
+ *p=o;l=strlen(p);
+ *(p+l-1)=(char)NULL;
+ print_seq(p, d_mot && (mode!=0 || d_text));
+ print((S, "%c", sch), d_command)
+ }
+ ;
+
+math
+ : bgin start_BE_ARG o_spnl oa math_environnement ca math_mode entites end start_BE_ARG o_spnl oa math_environnement ca
+ { mode=$7;
+ if (strcmp($5, $13)!=0) {
+ fprintf(stderr, "%s | %s not matching in begin_end\n", $5, $13);
+ exit(2);
+ }
+ str_destroy($5);
+ str_destroy($13);
+ }
+ | math_mode dollar entites dollar
+ { mode=$1; }
+ | math_mode ddollar entites ddollar
+ { mode=$1; }
+ | math_mode opare entites cpare
+ { mode=$1; }
+ | math_mode obrac entites cbrac
+ { mode=$1; }
+ ;
+
+math_environnement
+ : MATHENV
+ { $$=strdup($1);
+ print((S, "%s", $1), d_command) }
+ ;
+
+math_mode :
+ { $$=mode; mode=1; n_formule++; }
+ ;
+
+dollar
+ : DOLLAR
+ { print((S, "%c", '$'), d_command) }
+ ;
+
+ddollar
+ : DDOLLAR
+ { print((S, "%c%c", '$', '$'), d_command) }
+ ;
+
+opare
+ : OPARE
+ { print((S, "%c", '('), d_command) }
+ ;
+
+cpare
+ : CPARE
+ { print((S, "%c", ')'), d_command) }
+ ;
+
+obrac
+ : OBRAC
+ { print((S, "%c", '['), d_command) }
+ ;
+
+box
+ : start_SQ1 box_name text_mode start_N groupe
+ { mode=$3; }
+ | start_SQ1 box_name o_spnl ctlseq start_N text_mode groupe
+ { mode=$6; }
+ ;
+
+box_name
+ : BOX
+ { print((S, "%s", $1), d_command) }
+ ;
+
+text_mode
+ : o_spnl
+ { $$=mode; if (mode!=-1) mode=0; }
+ ;
+
+groupe
+ : oa lignes ca
+ ;
+
+accent
+ : r_accent o_spnl
+ {
+ if (d_accent) {
+ if (s_accent==(char)NULL) {
+ print((S, "%c", $1), (mode!=0 || d_text))
+ } else {
+ print((S, "%c%c", s_accent, $1), (mode!=0 || d_text))
+ } } }
+ ;
+
+r_accent
+ : ACCENT
+ { $$=$1[1]; }
+
+s_command
+ : COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+k_command
+ : K_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h_command
+ : H_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+ho_command
+ : HO_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+k1_command
+ : K1_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+kg_argument
+ : entite
+ ;
+
+ko1_command
+ : KO1_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h1_command
+ : H1_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h2_command
+ : H2_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h3_command
+ : H3_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+ho1_command
+ : HO1_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+ho2_command
+ : HO2_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h1o1_command
+ : H1O1_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h1o2_command
+ : H1O2_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h1o_command
+ : H1O_COMMAND
+ { print((S, "%s", $1), d_command) }
+
+h2o_command
+ : H2O_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+hoo1_command
+ : HOO1_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h1oo1_command
+ : H1OO1_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+h1o1o_command
+ : H1O1O_COMMAND
+ { print((S, "%s", $1), d_command) }
+ ;
+
+inclusion
+ : INCLUDEONLY start_FLN filename start_N
+ { char *p=$3;int i, old_n_ionly;
+ if (n_ionly==-1) n_ionly=0;
+ old_n_ionly=n_ionly;
+ if ((if_name[n_ionly++]=strtok(p, ","))!=(char *)NULL) {
+ p=(char *)NULL;
+ while ((if_name[n_ionly++]=strtok(p, ","))!=(char *)NULL);
+ n_ionly--;
+ for (i=old_n_ionly; i<n_ionly; i++) {
+ if_name[i]=strdup(if_name[i]);
+ } }
+ str_destroy($3);
+ }
+ | inclusion_command start_FLN filename start_N
+ { int i;
+ if (do_incl) {
+
+ FILE *fd=(FILE *)NULL;
+ char i_name[W_LGTH];
+
+ strcpy(i_name, $3);
+ for (i=0; i<n_ionly; i++) {
+ if (strcmp(i_name,if_name[i])==0) break;
+ }
+ if (i==n_ionly) {
+ if (d_warning)
+ fprintf(stderr, "%s not included\n", i_name);
+ } else {
+ strcat(i_name, ".tex");
+ if ((fd=fopen($3, "r"))==(FILE *)NULL) {
+ if ((fd=fopen(i_name, "r"))==(FILE *)NULL) {
+ if (d_warning)
+ fprintf(stderr, "Can't read file: %s\n", $3);
+ }
+ } }
+ if (fd!=(FILE *)NULL) {
+ fich_t n_fich;
+
+ n_fich.name=strdup($3);
+ n_fich.fd=fd;
+ n_fich.line=lineno;
+#ifdef FLEX_SCANNER
+ n_fich.last_string=(char *)Input();
+#else
+ n_fich.last_char=(char)Input();
+#endif
+ f_push(&n_fich);
+ *f_in=fd;
+ f_name=n_fich.name;
+ lineno=0L;
+ if (d_fname==0) d_fname=-1;
+ if (d_nl) doprint((S, "%s", "\n"))
+ start_file();
+ inclusion_file();
+ } }
+ str_destroy($3);
+ }
+ ;
+
+start_FLN
+ :
+ { start_FLN(); }
+ ;
+
+filename
+ : oa lettres ca
+ { $$=$2; }
+ | oa fln ca
+ { $$=$2; }
+ | o_spnl lettres
+ { $$=$2; }
+ | o_spnl fln
+ { $$=$2; }
+ | o_spnl UNKNOWN
+ { $$=strdup($2); }
+ ;
+
+lettres
+ : LETTRES
+ { $$=strdup($1); }
+ ;
+
+fln
+ : FILENAME
+ { $$=strdup($1); }
+ ;
+
+inclusion_command
+ : INCLUSION
+ { print((S, "%s", $1), d_command) }
+ ;
+
+commentaire
+ : COMMENT
+ {
+ $1[strlen($1)-1]=(char)NULL;
+ print((S, "%s", $1), d_comment)
+ print_nl();
+ }
+ ;
+
+separateur
+ : spaces
+ | spaces_newline
+ ;
+
+reste
+ : operator
+ { print((S, "%c", $1), d_operator) }
+ | special
+ { print((S, "%c", $1), d_special) }
+ | slashed
+ | other
+ ;
+
+operator
+ : '+' { $$='+'; }
+ | '-' { $$='-'; }
+ | '*' { $$='*'; }
+ | '/' { $$='/'; }
+ | '=' { $$='='; }
+ | '|' { $$='|'; }
+ | '<' { $$='<'; }
+ | '>' { $$='>'; }
+ | '(' { $$='('; }
+ | ')' { $$=')'; }
+ | '@' { $$='@'; }
+ | '[' { $$='['; }
+ | ']' { $$=']'; }
+ ;
+
+special
+ : '#' { $$='#'; }
+ | '%' { $$='%'; }
+ | '&' { $$='&'; }
+ | '\\' { $$='\\'; }
+ | '^' { $$='^'; }
+ | '_' { $$='_'; }
+ | '~' { $$='~'; }
+ ;
+
+other
+ : OTHER
+ { print((S, "\\ASCII:%d ", yylval.y_chr), d_warning) }
+ | FFEED
+ { print((S, "%c", 12), d_mot && (mode!=0 || d_text)) }
+ ;
+
+nl
+ :
+ { if (d_nl) doprint((S, "%s", "\n")) }
+ ;
+
+start_END
+ :
+ { start_END(); }
+ ;
+%%
+
+/*
+ * yyerror function for LEX
+ */
+yyerror(s)
+char *s;
+{
+ if (d_error) {
+
+ if ((strcmp("", f_name)!=0))
+ fprintf(stderr, "[%s:%d] %s\n", f_name, lineno+1, s);
+ else fprintf(stderr, "[%d] %s", lineno+1, s);
+
+ }
+}
+
+/*
+ * display new file name
+ */
+int start_file()
+{
+ if (n_nl && ((lineno+1) % N == 0)) {
+ if ((strcmp("", f_name)==0) || (d_fname==0))
+ doprint((S, "[%d] ", lineno+1))
+ else {
+ if (d_fname==-1) d_fname=0;
+ doprint((S, "[%s:%d] ", f_name, lineno+1))
+ } } else if (n_nl) {
+ if (d_fname==-1) d_fname=0;
+ if (strcmp("", f_name)!=0) doprint((S, "[%s] ", f_name))
+ }
+}
+
+/*
+ * ouput a \n with line number if necessary
+ */
+print_nl()
+{
+ if (d_nl) doprint((S, "%s", "\n"))
+ if (n_nl && ((lineno+2) % N == 0)) {
+ if ((strcmp("", f_name)==0) || (d_fname==0))
+ doprint((S, "[%d] ", lineno+2))
+ else {
+ if (d_fname==-1) d_fname=0;
+ doprint((S, "[%s:%d] ", f_name, lineno+2))
+ } }
+ lineno++;
+}
+
+/*
+ * output a sequence containing blanks
+ * and possibly a \n
+ */
+print_blnl(s)
+char *s;
+{
+ char *p=strchr(s, '\n');
+
+ *p=(char)NULL;
+ if (strlen(s)>0)
+ if (d_bls) print((S, "%s", s), d_bl)
+ else print((S, "%s", " "), d_bl)
+ *p='\n';
+ if (d_nl) doprint((S, "%s", "\n"))
+ if (n_nl && ((lineno+2) % N == 0)) {
+ if ((strcmp("", f_name)==0) || (d_fname==0)) {
+ doprint((S, "[%d] ", lineno+2))
+ } else {
+ if (d_fname==-1) d_fname=0;
+ doprint((S, "[%s:%d] ", f_name, lineno+2))
+ } }
+ if (*(p+1)!=(char)NULL)
+ if (d_bls) print((S, "%s", p+1), d_bl)
+ else print((S, "%s", " "), d_bl)
+ lineno++;
+}
+
+/*
+ * output a sequence of characters
+ * eventually containing several \n
+ */
+print_seq(p, flg)
+char *p;
+int flg;
+{
+ char *q;
+
+ q=p;
+ while (*q!=(char)NULL) {
+
+ while (*q!='\n' && *q!=(char)NULL) q++;
+ if (*q=='\n') {
+ *q=(char)NULL;
+ if (strlen(p)>0) print((S, "%s", p), flg)
+ print_nl();
+ p=++q;
+ } else {
+ if (strlen(p)>0) print((S, "%s", p), flg)
+ } }
+}