home *** CD-ROM | disk | FTP | other *** search
/ ftp.shrubbery.net / 2015-02-07.ftp.shrubbery.net.tar / ftp.shrubbery.net / pub / foad / foad-0.3.tar.gz / foad-0.3.tar / foad-0.3 / parser.c < prev    next >
C/C++ Source or Header  |  2003-09-22  |  38KB  |  1,472 lines

  1. /* A Bison parser, made from parser.y
  2.    by GNU bison 1.34.  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. # define    T_BCC    257
  7. # define    T_BCC_CONT    258
  8. # define    T_FROM    259
  9. # define    T_CC    260
  10. # define    T_CC_CONT    261
  11. # define    T_TO    262
  12. # define    T_TO_CONT    263
  13. # define    T_CONT    264
  14. # define    T_LINE    265
  15.  
  16. #line 1 "parser.y"
  17.  
  18. #include "foad.h"
  19.  
  20. #include <sys/stat.h>
  21.  
  22. extern    char    *progname,            /* program's name */
  23.         *c_bcc,
  24.         *c_from,
  25.         *c_cc,
  26.         *c_to;
  27. extern    s_addresses    bcc,
  28.         from,
  29.         cc,
  30.         to;
  31. extern    int    debug,
  32.         negate;
  33.  
  34. #define    YYDEBUG 1                /* include debugging */
  35. #define    YYERROR_VERBOSE 1
  36.  
  37. #define    Y_DEBUG        (debug > 1)
  38.  
  39. #line 25 "parser.y"
  40. #ifndef YYSTYPE
  41. typedef union {
  42.     char        *cptr;
  43. } yystype;
  44. # define YYSTYPE yystype
  45. #endif
  46. #ifndef YYDEBUG
  47. # define YYDEBUG 0
  48. #endif
  49.  
  50.  
  51.  
  52. #define    YYFINAL        38
  53. #define    YYFLAG        -32768
  54. #define    YYNTBASE    13
  55.  
  56. /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
  57. #define YYTRANSLATE(x) ((unsigned)(x) <= 265 ? yytranslate[x] : 25)
  58.  
  59. /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
  60. static const char yytranslate[] =
  61. {
  62.        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  63.       12,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  64.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  65.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  66.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  67.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  68.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  69.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  70.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  71.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  72.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  73.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  74.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  75.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  76.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  77.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  78.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  79.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  80.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  81.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  82.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  83.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  84.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  85.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  86.        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  87.        2,     2,     2,     2,     2,     2,     1,     3,     4,     5,
  88.        6,     7,     8,     9,    10,    11
  89. };
  90.  
  91. #if YYDEBUG
  92. static const short yyprhs[] =
  93. {
  94.        0,     0,     2,     4,     7,     9,    11,    13,    15,    17,
  95.       19,    21,    24,    27,    30,    32,    35,    38,    41,    44,
  96.       46,    49,    52,    55,    57,    60,    63
  97. };
  98. static const short yyrhs[] =
  99. {
  100.       14,     0,    15,     0,    14,    15,     0,    18,     0,    20,
  101.        0,    23,     0,    21,     0,    16,     0,    12,     0,    17,
  102.        0,    16,    17,     0,    11,    12,     0,    10,    12,     0,
  103.       19,     0,    18,    19,     0,     3,    12,     0,     4,    12,
  104.        0,     5,    12,     0,    22,     0,    21,    22,     0,     6,
  105.       12,     0,     7,    12,     0,    24,     0,    23,    24,     0,
  106.        8,    12,     0,     9,    12,     0
  107. };
  108.  
  109. #endif
  110.  
  111. #if YYDEBUG
  112. /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
  113. static const short yyrline[] =
  114. {
  115.        0,    38,    43,    44,    47,    48,    49,    50,    51,    52,
  116.       55,    56,    58,    63,    70,    71,    73,    82,    91,   100,
  117.      101,   104,   113,   122,   123,   125,   134
  118. };
  119. #endif
  120.  
  121.  
  122. #if (YYDEBUG) || defined YYERROR_VERBOSE
  123.  
  124. /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
  125. static const char *const yytname[] =
  126. {
  127.   "$", "error", "$undefined.", "T_BCC", "T_BCC_CONT", "T_FROM", "T_CC", 
  128.   "T_CC_CONT", "T_TO", "T_TO_CONT", "T_CONT", "T_LINE", "'\\n'", 
  129.   "headers", "stmts", "stmt", "lines", "line", "bcc_stmt", "bcc_bits", 
  130.   "from_stmt", "cc_stmt", "cc_bits", "to_stmt", "to_bits", 0
  131. };
  132. #endif
  133.  
  134. /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  135. static const short yyr1[] =
  136. {
  137.        0,    13,    14,    14,    15,    15,    15,    15,    15,    15,
  138.       16,    16,    17,    17,    18,    18,    19,    19,    20,    21,
  139.       21,    22,    22,    23,    23,    24,    24
  140. };
  141.  
  142. /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  143. static const short yyr2[] =
  144. {
  145.        0,     1,     1,     2,     1,     1,     1,     1,     1,     1,
  146.        1,     2,     2,     2,     1,     2,     2,     2,     2,     1,
  147.        2,     2,     2,     1,     2,     2,     2
  148. };
  149.  
  150. /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
  151.    doesn't specify something else to do.  Zero means the default is an
  152.    error. */
  153. static const short yydefact[] =
  154. {
  155.        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  156.        9,     1,     2,     8,    10,     4,    14,     5,     7,    19,
  157.        6,    23,    16,    17,    18,    21,    22,    25,    26,    13,
  158.       12,     3,    11,    15,    20,    24,     0,     0,     0
  159. };
  160.  
  161. static const short yydefgoto[] =
  162. {
  163.       36,    11,    12,    13,    14,    15,    16,    17,    18,    19,
  164.       20,    21
  165. };
  166.  
  167. static const short yypact[] =
  168. {
  169.       -3,     4,     5,    11,    12,    13,    14,    15,    16,    17,
  170.   -32768,    -3,-32768,     0,-32768,     9,-32768,-32768,     8,-32768,
  171.       10,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  172.   -32768,-32768,-32768,-32768,-32768,-32768,    20,    21,-32768
  173. };
  174.  
  175. static const short yypgoto[] =
  176. {
  177.   -32768,-32768,    19,-32768,    18,-32768,     7,-32768,-32768,    22,
  178.   -32768,    23
  179. };
  180.  
  181.  
  182. #define    YYLAST        43
  183.  
  184.  
  185. static const short yytable[] =
  186. {
  187.        1,     2,     3,     4,     5,     6,     7,     8,     9,    10,
  188.        8,     9,     1,     2,     4,     5,    22,    23,     6,     7,
  189.       37,    38,    33,    24,    25,    26,    27,    28,    29,    30,
  190.       31,    32,     0,     0,     0,     0,     0,     0,     0,     0,
  191.       34,     0,     0,    35
  192. };
  193.  
  194. static const short yycheck[] =
  195. {
  196.        3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
  197.       10,    11,     3,     4,     6,     7,    12,    12,     8,     9,
  198.        0,     0,    15,    12,    12,    12,    12,    12,    12,    12,
  199.       11,    13,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
  200.       18,    -1,    -1,    20
  201. };
  202. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  203. #line 3 "/usr/pkg/share/bison/bison.simple"
  204.  
  205. /* Skeleton output parser for bison,
  206.  
  207.    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
  208.    Foundation, Inc.
  209.  
  210.    This program is free software; you can redistribute it and/or modify
  211.    it under the terms of the GNU General Public License as published by
  212.    the Free Software Foundation; either version 2, or (at your option)
  213.    any later version.
  214.  
  215.    This program is distributed in the hope that it will be useful,
  216.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  217.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  218.    GNU General Public License for more details.
  219.  
  220.    You should have received a copy of the GNU General Public License
  221.    along with this program; if not, write to the Free Software
  222.    Foundation, Inc., 59 Temple Place - Suite 330,
  223.    Boston, MA 02111-1307, USA.  */
  224.  
  225. /* As a special exception, when this file is copied by Bison into a
  226.    Bison output file, you may use that output file without restriction.
  227.    This special exception was added by the Free Software Foundation
  228.    in version 1.24 of Bison.  */
  229.  
  230. /* This is the parser code that is written into each bison parser when
  231.    the %semantic_parser declaration is not specified in the grammar.
  232.    It was written by Richard Stallman by simplifying the hairy parser
  233.    used when %semantic_parser is specified.  */
  234.  
  235. /* All symbols defined below should begin with yy or YY, to avoid
  236.    infringing on user name space.  This should be done even for local
  237.    variables, as they might otherwise be expanded by user macros.
  238.    There are some unavoidable exceptions within include files to
  239.    define necessary library symbols; they are noted "INFRINGES ON
  240.    USER NAME SPACE" below.  */
  241.  
  242. #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
  243.  
  244. /* The parser invokes alloca or malloc; define the necessary symbols.  */
  245.  
  246. # if YYSTACK_USE_ALLOCA
  247. #  define YYSTACK_ALLOC alloca
  248. # else
  249. #  ifndef YYSTACK_USE_ALLOCA
  250. #   if defined (alloca) || defined (_ALLOCA_H)
  251. #    define YYSTACK_ALLOC alloca
  252. #   else
  253. #    ifdef __GNUC__
  254. #     define YYSTACK_ALLOC __builtin_alloca
  255. #    endif
  256. #   endif
  257. #  endif
  258. # endif
  259.  
  260. # ifdef YYSTACK_ALLOC
  261.    /* Pacify GCC's `empty if-body' warning. */
  262. #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  263. # else
  264. #  if defined (__STDC__) || defined (__cplusplus)
  265. #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  266. #   define YYSIZE_T size_t
  267. #  endif
  268. #  define YYSTACK_ALLOC malloc
  269. #  define YYSTACK_FREE free
  270. # endif
  271.  
  272. /* A type that is properly aligned for any stack member.  */
  273. union yyalloc
  274. {
  275.   short yyss;
  276.   YYSTYPE yyvs;
  277. # if YYLSP_NEEDED
  278.   YYLTYPE yyls;
  279. # endif
  280. };
  281.  
  282. /* The size of the maximum gap between one aligned stack and the next.  */
  283. # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
  284.  
  285. /* The size of an array large to enough to hold all stacks, each with
  286.    N elements.  */
  287. # if YYLSP_NEEDED
  288. #  define YYSTACK_BYTES(N) \
  289.      ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))    \
  290.       + 2 * YYSTACK_GAP_MAX)
  291. # else
  292. #  define YYSTACK_BYTES(N) \
  293.      ((N) * (sizeof (short) + sizeof (YYSTYPE))                \
  294.       + YYSTACK_GAP_MAX)
  295. # endif
  296.  
  297. /* Relocate the TYPE STACK from its old location to the new one.  The
  298.    local variables YYSIZE and YYSTACKSIZE give the old and new number of
  299.    elements in the stack, and YYPTR gives the new location of the
  300.    stack.  Advance YYPTR to a properly aligned location for the next
  301.    stack.  */
  302. # define YYSTACK_RELOCATE(Type, Stack)                    \
  303.     do                                    \
  304.       {                                    \
  305.     YYSIZE_T yynewbytes;                        \
  306.     yymemcpy ((char *) yyptr, (char *) (Stack),            \
  307.           yysize * (YYSIZE_T) sizeof (Type));            \
  308.     Stack = &yyptr->Stack;                        \
  309.     yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;    \
  310.     yyptr += yynewbytes / sizeof (*yyptr);                \
  311.       }                                    \
  312.     while (0)
  313.  
  314. #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
  315.  
  316.  
  317. #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
  318. # define YYSIZE_T __SIZE_TYPE__
  319. #endif
  320. #if ! defined (YYSIZE_T) && defined (size_t)
  321. # define YYSIZE_T size_t
  322. #endif
  323. #if ! defined (YYSIZE_T)
  324. # if defined (__STDC__) || defined (__cplusplus)
  325. #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  326. #  define YYSIZE_T size_t
  327. # endif
  328. #endif
  329. #if ! defined (YYSIZE_T)
  330. # define YYSIZE_T unsigned int
  331. #endif
  332.  
  333. #define yyerrok        (yyerrstatus = 0)
  334. #define yyclearin    (yychar = YYEMPTY)
  335. #define YYEMPTY        -2
  336. #define YYEOF        0
  337. #define YYACCEPT    goto yyacceptlab
  338. #define YYABORT     goto yyabortlab
  339. #define YYERROR        goto yyerrlab1
  340. /* Like YYERROR except do call yyerror.  This remains here temporarily
  341.    to ease the transition to the new meaning of YYERROR, for GCC.
  342.    Once GCC version 2 has supplanted version 1, this can go.  */
  343. #define YYFAIL        goto yyerrlab
  344. #define YYRECOVERING()  (!!yyerrstatus)
  345. #define YYBACKUP(Token, Value)                    \
  346. do                                \
  347.   if (yychar == YYEMPTY && yylen == 1)                \
  348.     {                                \
  349.       yychar = (Token);                        \
  350.       yylval = (Value);                        \
  351.       yychar1 = YYTRANSLATE (yychar);                \
  352.       YYPOPSTACK;                        \
  353.       goto yybackup;                        \
  354.     }                                \
  355.   else                                \
  356.     {                                 \
  357.       yyerror ("syntax error: cannot back up");            \
  358.       YYERROR;                            \
  359.     }                                \
  360. while (0)
  361.  
  362. #define YYTERROR    1
  363. #define YYERRCODE    256
  364.  
  365.  
  366. /* YYLLOC_DEFAULT -- Compute the default location (before the actions
  367.    are run).
  368.  
  369.    When YYLLOC_DEFAULT is run, CURRENT is set the location of the
  370.    first token.  By default, to implement support for ranges, extend
  371.    its range to the last symbol.  */
  372.  
  373. #ifndef YYLLOC_DEFAULT
  374. # define YYLLOC_DEFAULT(Current, Rhs, N)           \
  375.    Current.last_line   = Rhs[N].last_line;    \
  376.    Current.last_column = Rhs[N].last_column;
  377. #endif
  378.  
  379.  
  380. /* YYLEX -- calling `yylex' with the right arguments.  */
  381.  
  382. #if YYPURE
  383. # if YYLSP_NEEDED
  384. #  ifdef YYLEX_PARAM
  385. #   define YYLEX        yylex (&yylval, &yylloc, YYLEX_PARAM)
  386. #  else
  387. #   define YYLEX        yylex (&yylval, &yylloc)
  388. #  endif
  389. # else /* !YYLSP_NEEDED */
  390. #  ifdef YYLEX_PARAM
  391. #   define YYLEX        yylex (&yylval, YYLEX_PARAM)
  392. #  else
  393. #   define YYLEX        yylex (&yylval)
  394. #  endif
  395. # endif /* !YYLSP_NEEDED */
  396. #else /* !YYPURE */
  397. # define YYLEX            yylex ()
  398. #endif /* !YYPURE */
  399.  
  400.  
  401. /* Enable debugging if requested.  */
  402. #if YYDEBUG
  403.  
  404. # ifndef YYFPRINTF
  405. #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
  406. #  define YYFPRINTF fprintf
  407. # endif
  408.  
  409. # define YYDPRINTF(Args)            \
  410. do {                        \
  411.   if (yydebug)                    \
  412.     YYFPRINTF Args;                \
  413. } while (0)
  414. /* Nonzero means print parse trace.  It is left uninitialized so that
  415.    multiple parsers can coexist.  */
  416. int yydebug;
  417. #else /* !YYDEBUG */
  418. # define YYDPRINTF(Args)
  419. #endif /* !YYDEBUG */
  420.  
  421. /* YYINITDEPTH -- initial size of the parser's stacks.  */
  422. #ifndef    YYINITDEPTH
  423. # define YYINITDEPTH 200
  424. #endif
  425.  
  426. /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
  427.    if the built-in stack extension method is used).
  428.  
  429.    Do not make this value too large; the results are undefined if
  430.    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
  431.    evaluated with infinite-precision integer arithmetic.  */
  432.  
  433. #if YYMAXDEPTH == 0
  434. # undef YYMAXDEPTH
  435. #endif
  436.  
  437. #ifndef YYMAXDEPTH
  438. # define YYMAXDEPTH 10000
  439. #endif
  440.  
  441. #if ! defined (yyoverflow) && ! defined (yymemcpy)
  442. # if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  443. #  define yymemcpy __builtin_memcpy
  444. # else                /* not GNU C or C++ */
  445.  
  446. /* This is the most reliable way to avoid incompatibilities
  447.    in available built-in functions on various systems.  */
  448. static void
  449. #  if defined (__STDC__) || defined (__cplusplus)
  450. yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
  451. #  else
  452. yymemcpy (yyto, yyfrom, yycount)
  453.      char *yyto;
  454.      const char *yyfrom;
  455.      YYSIZE_T yycount;
  456. #  endif
  457. {
  458.   register const char *yyf = yyfrom;
  459.   register char *yyt = yyto;
  460.   register YYSIZE_T yyi = yycount;
  461.  
  462.   while (yyi-- != 0)
  463.     *yyt++ = *yyf++;
  464. }
  465. # endif
  466. #endif
  467.  
  468. #ifdef YYERROR_VERBOSE
  469.  
  470. # ifndef yystrlen
  471. #  if defined (__GLIBC__) && defined (_STRING_H)
  472. #   define yystrlen strlen
  473. #  else
  474. /* Return the length of YYSTR.  */
  475. static YYSIZE_T
  476. #   if defined (__STDC__) || defined (__cplusplus)
  477. yystrlen (const char *yystr)
  478. #   else
  479. yystrlen (yystr)
  480.      const char *yystr;
  481. #   endif
  482. {
  483.   register const char *yys = yystr;
  484.  
  485.   while (*yys++ != '\0')
  486.     continue;
  487.  
  488.   return yys - yystr - 1;
  489. }
  490. #  endif
  491. # endif
  492.  
  493. # ifndef yystpcpy
  494. #  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
  495. #   define yystpcpy stpcpy
  496. #  else
  497. /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
  498.    YYDEST.  */
  499. static char *
  500. #   if defined (__STDC__) || defined (__cplusplus)
  501. yystpcpy (char *yydest, const char *yysrc)
  502. #   else
  503. yystpcpy (yydest, yysrc)
  504.      char *yydest;
  505.      const char *yysrc;
  506. #   endif
  507. {
  508.   register char *yyd = yydest;
  509.   register const char *yys = yysrc;
  510.  
  511.   while ((*yyd++ = *yys++) != '\0')
  512.     continue;
  513.  
  514.   return yyd - 1;
  515. }
  516. #  endif
  517. # endif
  518. #endif
  519.  
  520. #line 319 "/usr/pkg/share/bison/bison.simple"
  521.  
  522.  
  523. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  524.    into yyparse.  The argument should have type void *.
  525.    It should actually point to an object.
  526.    Grammar actions can access the variable by casting it
  527.    to the proper pointer type.  */
  528.  
  529. #ifdef YYPARSE_PARAM
  530. # if defined (__STDC__) || defined (__cplusplus)
  531. #  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  532. #  define YYPARSE_PARAM_DECL
  533. # else
  534. #  define YYPARSE_PARAM_ARG YYPARSE_PARAM
  535. #  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  536. # endif
  537. #else /* !YYPARSE_PARAM */
  538. # define YYPARSE_PARAM_ARG
  539. # define YYPARSE_PARAM_DECL
  540. #endif /* !YYPARSE_PARAM */
  541.  
  542. /* Prevent warning if -Wstrict-prototypes.  */
  543. #ifdef __GNUC__
  544. # ifdef YYPARSE_PARAM
  545. int yyparse (void *);
  546. # else
  547. int yyparse (void);
  548. # endif
  549. #endif
  550.  
  551. /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
  552.    variables are global, or local to YYPARSE.  */
  553.  
  554. #define YY_DECL_NON_LSP_VARIABLES            \
  555. /* The lookahead symbol.  */                \
  556. int yychar;                        \
  557.                             \
  558. /* The semantic value of the lookahead symbol. */    \
  559. YYSTYPE yylval;                        \
  560.                             \
  561. /* Number of parse errors so far.  */            \
  562. int yynerrs;
  563.  
  564. #if YYLSP_NEEDED
  565. # define YY_DECL_VARIABLES            \
  566. YY_DECL_NON_LSP_VARIABLES            \
  567.                         \
  568. /* Location data for the lookahead symbol.  */    \
  569. YYLTYPE yylloc;
  570. #else
  571. # define YY_DECL_VARIABLES            \
  572. YY_DECL_NON_LSP_VARIABLES
  573. #endif
  574.  
  575.  
  576. /* If nonreentrant, generate the variables here. */
  577.  
  578. #if !YYPURE
  579. YY_DECL_VARIABLES
  580. #endif  /* !YYPURE */
  581.  
  582. int
  583. yyparse (YYPARSE_PARAM_ARG)
  584.      YYPARSE_PARAM_DECL
  585. {
  586.   /* If reentrant, generate the variables here. */
  587. #if YYPURE
  588.   YY_DECL_VARIABLES
  589. #endif  /* !YYPURE */
  590.  
  591.   register int yystate;
  592.   register int yyn;
  593.   int yyresult;
  594.   /* Number of tokens to shift before error messages enabled.  */
  595.   int yyerrstatus;
  596.   /* Lookahead token as an internal (translated) token number.  */
  597.   int yychar1 = 0;
  598.  
  599.   /* Three stacks and their tools:
  600.      `yyss': related to states,
  601.      `yyvs': related to semantic values,
  602.      `yyls': related to locations.
  603.  
  604.      Refer to the stacks thru separate pointers, to allow yyoverflow
  605.      to reallocate them elsewhere.  */
  606.  
  607.   /* The state stack. */
  608.   short    yyssa[YYINITDEPTH];
  609.   short *yyss = yyssa;
  610.   register short *yyssp;
  611.  
  612.   /* The semantic value stack.  */
  613.   YYSTYPE yyvsa[YYINITDEPTH];
  614.   YYSTYPE *yyvs = yyvsa;
  615.   register YYSTYPE *yyvsp;
  616.  
  617. #if YYLSP_NEEDED
  618.   /* The location stack.  */
  619.   YYLTYPE yylsa[YYINITDEPTH];
  620.   YYLTYPE *yyls = yylsa;
  621.   YYLTYPE *yylsp;
  622. #endif
  623.  
  624. #if YYLSP_NEEDED
  625. # define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  626. #else
  627. # define YYPOPSTACK   (yyvsp--, yyssp--)
  628. #endif
  629.  
  630.   YYSIZE_T yystacksize = YYINITDEPTH;
  631.  
  632.  
  633.   /* The variables used to return semantic value and location from the
  634.      action routines.  */
  635.   YYSTYPE yyval;
  636. #if YYLSP_NEEDED
  637.   YYLTYPE yyloc;
  638. #endif
  639.  
  640.   /* When reducing, the number of symbols on the RHS of the reduced
  641.      rule. */
  642.   int yylen;
  643.  
  644.   YYDPRINTF ((stderr, "Starting parse\n"));
  645.  
  646.   yystate = 0;
  647.   yyerrstatus = 0;
  648.   yynerrs = 0;
  649.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  650.  
  651.   /* Initialize stack pointers.
  652.      Waste one element of value and location stack
  653.      so that they stay on the same level as the state stack.
  654.      The wasted elements are never initialized.  */
  655.  
  656.   yyssp = yyss;
  657.   yyvsp = yyvs;
  658. #if YYLSP_NEEDED
  659.   yylsp = yyls;
  660. #endif
  661.   goto yysetstate;
  662.  
  663. /*------------------------------------------------------------.
  664. | yynewstate -- Push a new state, which is found in yystate.  |
  665. `------------------------------------------------------------*/
  666.  yynewstate:
  667.   /* In all cases, when you get here, the value and location stacks
  668.      have just been pushed. so pushing a state here evens the stacks.
  669.      */
  670.   yyssp++;
  671.  
  672.  yysetstate:
  673.   *yyssp = yystate;
  674.  
  675.   if (yyssp >= yyss + yystacksize - 1)
  676.     {
  677.       /* Get the current used size of the three stacks, in elements.  */
  678.       YYSIZE_T yysize = yyssp - yyss + 1;
  679.  
  680. #ifdef yyoverflow
  681.       {
  682.     /* Give user a chance to reallocate the stack. Use copies of
  683.        these so that the &'s don't force the real ones into
  684.        memory.  */
  685.     YYSTYPE *yyvs1 = yyvs;
  686.     short *yyss1 = yyss;
  687.  
  688.     /* Each stack pointer address is followed by the size of the
  689.        data in use in that stack, in bytes.  */
  690. # if YYLSP_NEEDED
  691.     YYLTYPE *yyls1 = yyls;
  692.     /* This used to be a conditional around just the two extra args,
  693.        but that might be undefined if yyoverflow is a macro.  */
  694.     yyoverflow ("parser stack overflow",
  695.             &yyss1, yysize * sizeof (*yyssp),
  696.             &yyvs1, yysize * sizeof (*yyvsp),
  697.             &yyls1, yysize * sizeof (*yylsp),
  698.             &yystacksize);
  699.     yyls = yyls1;
  700. # else
  701.     yyoverflow ("parser stack overflow",
  702.             &yyss1, yysize * sizeof (*yyssp),
  703.             &yyvs1, yysize * sizeof (*yyvsp),
  704.             &yystacksize);
  705. # endif
  706.     yyss = yyss1;
  707.     yyvs = yyvs1;
  708.       }
  709. #else /* no yyoverflow */
  710.       /* Extend the stack our own way.  */
  711.       if (yystacksize >= YYMAXDEPTH)
  712.     goto yyoverflowlab;
  713.       yystacksize *= 2;
  714.       if (yystacksize > YYMAXDEPTH)
  715.     yystacksize = YYMAXDEPTH;
  716.  
  717.       {
  718.     short *yyss1 = yyss;
  719.     union yyalloc *yyptr =
  720.       (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
  721.     if (! yyptr)
  722.       goto yyoverflowlab;
  723.     YYSTACK_RELOCATE (short, yyss);
  724.     YYSTACK_RELOCATE (YYSTYPE, yyvs);
  725. # if YYLSP_NEEDED
  726.     YYSTACK_RELOCATE (YYLTYPE, yyls);
  727. # endif
  728. # undef YYSTACK_RELOCATE
  729.     if (yyss1 != yyssa)
  730.       YYSTACK_FREE (yyss1);
  731.       }
  732. #endif /* no yyoverflow */
  733.  
  734.       yyssp = yyss + yysize - 1;
  735.       yyvsp = yyvs + yysize - 1;
  736. #if YYLSP_NEEDED
  737.       yylsp = yyls + yysize - 1;
  738. #endif
  739.  
  740.       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
  741.           (unsigned long int) yystacksize));
  742.  
  743.       if (yyssp >= yyss + yystacksize - 1)
  744.     YYABORT;
  745.     }
  746.  
  747.   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
  748.  
  749.   goto yybackup;
  750.  
  751.  
  752. /*-----------.
  753. | yybackup.  |
  754. `-----------*/
  755. yybackup:
  756.  
  757. /* Do appropriate processing given the current state.  */
  758. /* Read a lookahead token if we need one and don't already have one.  */
  759. /* yyresume: */
  760.  
  761.   /* First try to decide what to do without reference to lookahead token.  */
  762.  
  763.   yyn = yypact[yystate];
  764.   if (yyn == YYFLAG)
  765.     goto yydefault;
  766.  
  767.   /* Not known => get a lookahead token if don't already have one.  */
  768.  
  769.   /* yychar is either YYEMPTY or YYEOF
  770.      or a valid token in external form.  */
  771.  
  772.   if (yychar == YYEMPTY)
  773.     {
  774.       YYDPRINTF ((stderr, "Reading a token: "));
  775.       yychar = YYLEX;
  776.     }
  777.  
  778.   /* Convert token to internal form (in yychar1) for indexing tables with */
  779.  
  780.   if (yychar <= 0)        /* This means end of input. */
  781.     {
  782.       yychar1 = 0;
  783.       yychar = YYEOF;        /* Don't call YYLEX any more */
  784.  
  785.       YYDPRINTF ((stderr, "Now at end of input.\n"));
  786.     }
  787.   else
  788.     {
  789.       yychar1 = YYTRANSLATE (yychar);
  790.  
  791. #if YYDEBUG
  792.      /* We have to keep this `#if YYDEBUG', since we use variables
  793.     which are defined only if `YYDEBUG' is set.  */
  794.       if (yydebug)
  795.     {
  796.       YYFPRINTF (stderr, "Next token is %d (%s",
  797.              yychar, yytname[yychar1]);
  798.       /* Give the individual parser a way to print the precise
  799.          meaning of a token, for further debugging info.  */
  800. # ifdef YYPRINT
  801.       YYPRINT (stderr, yychar, yylval);
  802. # endif
  803.       YYFPRINTF (stderr, ")\n");
  804.     }
  805. #endif
  806.     }
  807.  
  808.   yyn += yychar1;
  809.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  810.     goto yydefault;
  811.  
  812.   yyn = yytable[yyn];
  813.  
  814.   /* yyn is what to do for this token type in this state.
  815.      Negative => reduce, -yyn is rule number.
  816.      Positive => shift, yyn is new state.
  817.        New state is final state => don't bother to shift,
  818.        just return success.
  819.      0, or most negative number => error.  */
  820.  
  821.   if (yyn < 0)
  822.     {
  823.       if (yyn == YYFLAG)
  824.     goto yyerrlab;
  825.       yyn = -yyn;
  826.       goto yyreduce;
  827.     }
  828.   else if (yyn == 0)
  829.     goto yyerrlab;
  830.  
  831.   if (yyn == YYFINAL)
  832.     YYACCEPT;
  833.  
  834.   /* Shift the lookahead token.  */
  835.   YYDPRINTF ((stderr, "Shifting token %d (%s), ",
  836.           yychar, yytname[yychar1]));
  837.  
  838.   /* Discard the token being shifted unless it is eof.  */
  839.   if (yychar != YYEOF)
  840.     yychar = YYEMPTY;
  841.  
  842.   *++yyvsp = yylval;
  843. #if YYLSP_NEEDED
  844.   *++yylsp = yylloc;
  845. #endif
  846.  
  847.   /* Count tokens shifted since error; after three, turn off error
  848.      status.  */
  849.   if (yyerrstatus)
  850.     yyerrstatus--;
  851.  
  852.   yystate = yyn;
  853.   goto yynewstate;
  854.  
  855.  
  856. /*-----------------------------------------------------------.
  857. | yydefault -- do the default action for the current state.  |
  858. `-----------------------------------------------------------*/
  859. yydefault:
  860.   yyn = yydefact[yystate];
  861.   if (yyn == 0)
  862.     goto yyerrlab;
  863.   goto yyreduce;
  864.  
  865.  
  866. /*-----------------------------.
  867. | yyreduce -- Do a reduction.  |
  868. `-----------------------------*/
  869. yyreduce:
  870.   /* yyn is the number of a rule to reduce with.  */
  871.   yylen = yyr2[yyn];
  872.  
  873.   /* If YYLEN is nonzero, implement the default value of the action:
  874.      `$$ = $1'.
  875.  
  876.      Otherwise, the following line sets YYVAL to the semantic value of
  877.      the lookahead token.  This behavior is undocumented and Bison
  878.      users should not rely upon it.  Assigning to YYVAL
  879.      unconditionally makes the parser a bit smaller, and it avoids a
  880.      GCC warning that YYVAL may be used uninitialized.  */
  881.   yyval = yyvsp[1-yylen];
  882.  
  883. #if YYLSP_NEEDED
  884.   /* Similarly for the default location.  Let the user run additional
  885.      commands if for instance locations are ranges.  */
  886.   yyloc = yylsp[1-yylen];
  887.   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
  888. #endif
  889.  
  890. #if YYDEBUG
  891.   /* We have to keep this `#if YYDEBUG', since we use variables which
  892.      are defined only if `YYDEBUG' is set.  */
  893.   if (yydebug)
  894.     {
  895.       int yyi;
  896.  
  897.       YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
  898.          yyn, yyrline[yyn]);
  899.  
  900.       /* Print the symbols being reduced, and their result.  */
  901.       for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
  902.     YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
  903.       YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  904.     }
  905. #endif
  906.  
  907.   switch (yyn) {
  908.  
  909. case 1:
  910. #line 39 "parser.y"
  911. {
  912.     }
  913.     break;
  914. case 12:
  915. #line 59 "parser.y"
  916. {
  917.       if (Y_DEBUG)
  918.         fprintf(stderr, "%s: parser line\n", progname);
  919.     }
  920.     break;
  921. case 13:
  922. #line 64 "parser.y"
  923. {
  924.       if (Y_DEBUG)
  925.         fprintf(stderr, "%s: parser continue\n", progname);
  926.     }
  927.     break;
  928. case 16:
  929. #line 74 "parser.y"
  930. {
  931.       if (c_bcc)
  932.         append(&c_bcc, ",");
  933.       append(&c_bcc, yyvsp[-1].cptr);
  934.       if (Y_DEBUG)
  935.         fprintf(stderr, "%s: parser BCC: %s\n", progname, yyvsp[-1].cptr);
  936.       free(yyvsp[-1].cptr);
  937.     }
  938.     break;
  939. case 17:
  940. #line 83 "parser.y"
  941. {
  942.       append(&c_bcc, yyvsp[-1].cptr);
  943.       if (Y_DEBUG)
  944.         fprintf(stderr, "%s: parser BCC continue: %s\n", progname, yyvsp[-1].cptr);
  945.       free(yyvsp[-1].cptr);
  946.     }
  947.     break;
  948. case 18:
  949. #line 92 "parser.y"
  950. {
  951.       append(&c_from, yyvsp[-1].cptr);
  952.       if (Y_DEBUG)
  953.         fprintf(stderr, "%s: parser FROM: %s\n", progname, yyvsp[-1].cptr);
  954.       free(yyvsp[-1].cptr);
  955.     }
  956.     break;
  957. case 21:
  958. #line 105 "parser.y"
  959. {
  960.       if (c_cc)
  961.         append(&c_cc, ",");
  962.       append(&c_cc, yyvsp[-1].cptr);
  963.       if (Y_DEBUG)
  964.         fprintf(stderr, "%s: parser CC: %s\n", progname, yyvsp[-1].cptr);
  965.       free(yyvsp[-1].cptr);
  966.     }
  967.     break;
  968. case 22:
  969. #line 114 "parser.y"
  970. {
  971.       append(&c_cc, yyvsp[-1].cptr);
  972.       if (Y_DEBUG)
  973.         fprintf(stderr, "%s: parser CC continue: %s\n", progname, yyvsp[-1].cptr);
  974.       free(yyvsp[-1].cptr);
  975.     }
  976.     break;
  977. case 25:
  978. #line 126 "parser.y"
  979. {
  980.       if (c_to)
  981.         append(&c_to, ",");
  982.       append(&c_to, yyvsp[-1].cptr);
  983.       if (Y_DEBUG)
  984.         fprintf(stderr, "%s: parser TO: %s\n", progname, yyvsp[-1].cptr);
  985.       free(yyvsp[-1].cptr);
  986.     }
  987.     break;
  988. case 26:
  989. #line 135 "parser.y"
  990. {
  991.       append(&c_to, yyvsp[-1].cptr);
  992.       if (Y_DEBUG)
  993.         fprintf(stderr, "%s: parser TO continue: %s\n", progname, yyvsp[-1].cptr);
  994.       free(yyvsp[-1].cptr);
  995.     }
  996.     break;
  997. }
  998.  
  999. #line 705 "/usr/pkg/share/bison/bison.simple"
  1000.  
  1001.  
  1002.   yyvsp -= yylen;
  1003.   yyssp -= yylen;
  1004. #if YYLSP_NEEDED
  1005.   yylsp -= yylen;
  1006. #endif
  1007.  
  1008. #if YYDEBUG
  1009.   if (yydebug)
  1010.     {
  1011.       short *yyssp1 = yyss - 1;
  1012.       YYFPRINTF (stderr, "state stack now");
  1013.       while (yyssp1 != yyssp)
  1014.     YYFPRINTF (stderr, " %d", *++yyssp1);
  1015.       YYFPRINTF (stderr, "\n");
  1016.     }
  1017. #endif
  1018.  
  1019.   *++yyvsp = yyval;
  1020. #if YYLSP_NEEDED
  1021.   *++yylsp = yyloc;
  1022. #endif
  1023.  
  1024.   /* Now `shift' the result of the reduction.  Determine what state
  1025.      that goes to, based on the state we popped back to and the rule
  1026.      number reduced by.  */
  1027.  
  1028.   yyn = yyr1[yyn];
  1029.  
  1030.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1031.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1032.     yystate = yytable[yystate];
  1033.   else
  1034.     yystate = yydefgoto[yyn - YYNTBASE];
  1035.  
  1036.   goto yynewstate;
  1037.  
  1038.  
  1039. /*------------------------------------.
  1040. | yyerrlab -- here on detecting error |
  1041. `------------------------------------*/
  1042. yyerrlab:
  1043.   /* If not already recovering from an error, report this error.  */
  1044.   if (!yyerrstatus)
  1045.     {
  1046.       ++yynerrs;
  1047.  
  1048. #ifdef YYERROR_VERBOSE
  1049.       yyn = yypact[yystate];
  1050.  
  1051.       if (yyn > YYFLAG && yyn < YYLAST)
  1052.     {
  1053.       YYSIZE_T yysize = 0;
  1054.       char *yymsg;
  1055.       int yyx, yycount;
  1056.  
  1057.       yycount = 0;
  1058.       /* Start YYX at -YYN if negative to avoid negative indexes in
  1059.          YYCHECK.  */
  1060.       for (yyx = yyn < 0 ? -yyn : 0;
  1061.            yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
  1062.         if (yycheck[yyx + yyn] == yyx)
  1063.           yysize += yystrlen (yytname[yyx]) + 15, yycount++;
  1064.       yysize += yystrlen ("parse error, unexpected ") + 1;
  1065.       yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
  1066.       yymsg = (char *) YYSTACK_ALLOC (yysize);
  1067.       if (yymsg != 0)
  1068.         {
  1069.           char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
  1070.           yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
  1071.  
  1072.           if (yycount < 5)
  1073.         {
  1074.           yycount = 0;
  1075.           for (yyx = yyn < 0 ? -yyn : 0;
  1076.                yyx < (int) (sizeof (yytname) / sizeof (char *));
  1077.                yyx++)
  1078.             if (yycheck[yyx + yyn] == yyx)
  1079.               {
  1080.             const char *yyq = ! yycount ? ", expecting " : " or ";
  1081.             yyp = yystpcpy (yyp, yyq);
  1082.             yyp = yystpcpy (yyp, yytname[yyx]);
  1083.             yycount++;
  1084.               }
  1085.         }
  1086.           yyerror (yymsg);
  1087.           YYSTACK_FREE (yymsg);
  1088.         }
  1089.       else
  1090.         yyerror ("parse error; also virtual memory exhausted");
  1091.     }
  1092.       else
  1093. #endif /* defined (YYERROR_VERBOSE) */
  1094.     yyerror ("parse error");
  1095.     }
  1096.   goto yyerrlab1;
  1097.  
  1098.  
  1099. /*--------------------------------------------------.
  1100. | yyerrlab1 -- error raised explicitly by an action |
  1101. `--------------------------------------------------*/
  1102. yyerrlab1:
  1103.   if (yyerrstatus == 3)
  1104.     {
  1105.       /* If just tried and failed to reuse lookahead token after an
  1106.      error, discard it.  */
  1107.  
  1108.       /* return failure if at end of input */
  1109.       if (yychar == YYEOF)
  1110.     YYABORT;
  1111.       YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
  1112.           yychar, yytname[yychar1]));
  1113.       yychar = YYEMPTY;
  1114.     }
  1115.  
  1116.   /* Else will try to reuse lookahead token after shifting the error
  1117.      token.  */
  1118.  
  1119.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1120.  
  1121.   goto yyerrhandle;
  1122.  
  1123.  
  1124. /*-------------------------------------------------------------------.
  1125. | yyerrdefault -- current state does not do anything special for the |
  1126. | error token.                                                       |
  1127. `-------------------------------------------------------------------*/
  1128. yyerrdefault:
  1129. #if 0
  1130.   /* This is wrong; only states that explicitly want error tokens
  1131.      should shift them.  */
  1132.  
  1133.   /* If its default is to accept any token, ok.  Otherwise pop it.  */
  1134.   yyn = yydefact[yystate];
  1135.   if (yyn)
  1136.     goto yydefault;
  1137. #endif
  1138.  
  1139.  
  1140. /*---------------------------------------------------------------.
  1141. | yyerrpop -- pop the current state because it cannot handle the |
  1142. | error token                                                    |
  1143. `---------------------------------------------------------------*/
  1144. yyerrpop:
  1145.   if (yyssp == yyss)
  1146.     YYABORT;
  1147.   yyvsp--;
  1148.   yystate = *--yyssp;
  1149. #if YYLSP_NEEDED
  1150.   yylsp--;
  1151. #endif
  1152.  
  1153. #if YYDEBUG
  1154.   if (yydebug)
  1155.     {
  1156.       short *yyssp1 = yyss - 1;
  1157.       YYFPRINTF (stderr, "Error: state stack now");
  1158.       while (yyssp1 != yyssp)
  1159.     YYFPRINTF (stderr, " %d", *++yyssp1);
  1160.       YYFPRINTF (stderr, "\n");
  1161.     }
  1162. #endif
  1163.  
  1164. /*--------------.
  1165. | yyerrhandle.  |
  1166. `--------------*/
  1167. yyerrhandle:
  1168.   yyn = yypact[yystate];
  1169.   if (yyn == YYFLAG)
  1170.     goto yyerrdefault;
  1171.  
  1172.   yyn += YYTERROR;
  1173.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1174.     goto yyerrdefault;
  1175.  
  1176.   yyn = yytable[yyn];
  1177.   if (yyn < 0)
  1178.     {
  1179.       if (yyn == YYFLAG)
  1180.     goto yyerrpop;
  1181.       yyn = -yyn;
  1182.       goto yyreduce;
  1183.     }
  1184.   else if (yyn == 0)
  1185.     goto yyerrpop;
  1186.  
  1187.   if (yyn == YYFINAL)
  1188.     YYACCEPT;
  1189.  
  1190.   YYDPRINTF ((stderr, "Shifting error token, "));
  1191.  
  1192.   *++yyvsp = yylval;
  1193. #if YYLSP_NEEDED
  1194.   *++yylsp = yylloc;
  1195. #endif
  1196.  
  1197.   yystate = yyn;
  1198.   goto yynewstate;
  1199.  
  1200.  
  1201. /*-------------------------------------.
  1202. | yyacceptlab -- YYACCEPT comes here.  |
  1203. `-------------------------------------*/
  1204. yyacceptlab:
  1205.   yyresult = 0;
  1206.   goto yyreturn;
  1207.  
  1208. /*-----------------------------------.
  1209. | yyabortlab -- YYABORT comes here.  |
  1210. `-----------------------------------*/
  1211. yyabortlab:
  1212.   yyresult = 1;
  1213.   goto yyreturn;
  1214.  
  1215. /*---------------------------------------------.
  1216. | yyoverflowab -- parser overflow comes here.  |
  1217. `---------------------------------------------*/
  1218. yyoverflowlab:
  1219.   yyerror ("parser stack overflow");
  1220.   yyresult = 2;
  1221.   /* Fall through.  */
  1222.  
  1223. yyreturn:
  1224. #ifndef yyoverflow
  1225.   if (yyss != yyssa)
  1226.     YYSTACK_FREE (yyss);
  1227. #endif
  1228.   return yyresult;
  1229. }
  1230. #line 143 "parser.y"
  1231.  
  1232.  
  1233. /* C */
  1234.  
  1235. /*   
  1236.       function: int read_header()
  1237.    description: use the parser to read the mail headers from stdin, then
  1238.         split() them
  1239.        returns: non-zero on parser error
  1240.  */
  1241. int
  1242. read_header(void)
  1243. {
  1244.     extern FILE    *yyin;
  1245.     int        val = 0;
  1246.  
  1247.     yyin = stdin;
  1248.     val = yyparse();
  1249.  
  1250.     if (debug) {
  1251.     if (c_from)
  1252.         fprintf(stderr, " c_from = %s\n", c_from);
  1253.     if (c_to)
  1254.         fprintf(stderr, "   c_to = %s\n", c_to);
  1255.     if (c_cc)
  1256.         fprintf(stderr, "   c_cc = %s\n", c_cc);
  1257.     if (c_bcc)
  1258.         fprintf(stderr, "  c_bcc = %s\n", c_bcc);
  1259.     }
  1260.     if (! val) {
  1261.     split(c_from, &from);
  1262.     split(c_to, &to);
  1263.     split(c_cc, &cc);
  1264.     split(c_bcc, &bcc);
  1265.     }
  1266.  
  1267.     return(val);
  1268. }
  1269.  
  1270. /*   
  1271.       function: int append(dest string **, string *)
  1272.    description: append string to the of dest string
  1273.        returns: NULL on error
  1274.  */
  1275. int
  1276. append(char **dst, char *s)
  1277. {
  1278.     char    *new;
  1279.     int        len;
  1280.  
  1281.     if (s == NULL)
  1282.     return(0);
  1283.  
  1284.     while (*s == ' ' || *s == '\t') { s++; }
  1285.  
  1286.     if (*dst == NULL)
  1287.     len = strlen(s) + 2;
  1288.     else
  1289.     len = strlen(*dst) + strlen(s) + 2;
  1290.  
  1291.     if ((new = malloc(len)) == NULL) {
  1292.     fprintf(stderr, "%s: malloc failure: %s\n", progname, strerror(errno));
  1293.     exit(1 ^ negate);
  1294.     }
  1295.     bzero(new, len);
  1296.  
  1297.     if (*dst != NULL)
  1298.     strcpy(new, *dst);
  1299.     strcat(new, s);
  1300.  
  1301.     free(*dst);
  1302.     *dst = new;
  1303.  
  1304.     return(0);
  1305. }
  1306.  
  1307. /*   
  1308.       function: int lappend(linked list *, node *)
  1309.    description: append a linked list node to linked list
  1310.        returns: NULL on error
  1311.  */
  1312. int
  1313. lappend(struct s_addresses *dst, node *n)
  1314. {
  1315.     node    *next;
  1316.  
  1317.     if (dst->next == NULL) {
  1318.     dst->next = n;
  1319.     } else {
  1320.     next = dst->next;
  1321.     while (next) {
  1322.         if (next->next == NULL) {
  1323.         next->next = n;
  1324.         break;
  1325.         } else
  1326.         next = next->next;
  1327.     }
  1328.     }
  1329.     return(0);
  1330. }
  1331.  
  1332. /*   
  1333.       function: int split(header string *, per-header linked list *)
  1334.    description: split a header (from/to/cc/bcc) into the address portion
  1335.         only and add it to the linked list (for the header)
  1336.        returns: exit on error
  1337.  */
  1338. int
  1339. split(char *a, s_addresses *dst)
  1340. {
  1341.     char    *comma,
  1342.         *left,
  1343.         *quote;
  1344.     int        end;
  1345.     node    *new = NULL;
  1346.  
  1347.     if (a == NULL)
  1348.     return(0);
  1349.  
  1350.     /* string quoted "strings" */
  1351.     for (;;) {
  1352.     if ((quote = index(a, '"')) == NULL)
  1353.         break;
  1354.     if ((comma = index(quote + 1, '"')) == NULL) {
  1355.         fprintf(stderr, "%s: apparent address format error, unmatched \"s:"
  1356.         " %s\n", progname, a);
  1357.         exit(1 ^ negate);
  1358.     }
  1359.     strcpy(quote, comma + 1);
  1360.     }
  1361.     /* string quoted (strings) */
  1362.     for (;;) {
  1363.     if ((quote = index(a, '(')) == NULL)
  1364.         break;
  1365.     if ((comma = index(quote + 1, ')')) == NULL) {
  1366.         fprintf(stderr, "%s: apparent address format error, unmatched ()s:"
  1367.         " %s\n", progname, a);
  1368.         exit(1 ^ negate);
  1369.     }
  1370.     strcpy(quote, comma + 1);
  1371.     }
  1372.     /* strip ' ;' or ': ;' constructs */
  1373.     left = a;
  1374.     for (;;) {
  1375.     if ((comma = index(left, ';')) == NULL)
  1376.         break;
  1377.     quote = comma;
  1378.     /* backup until we find a ':' */
  1379.     while (quote > a && *(quote - 1) != ':') {
  1380.         quote--;
  1381.     }
  1382.     if (quote > a && *(quote - 1) == ':') {
  1383.         /* strip ": ;" */
  1384.         strcpy(quote, comma);
  1385.         *quote = ',';
  1386.         left = quote;
  1387.     } else {
  1388.         /* strip ";" */
  1389.         strcpy(comma, comma + 1);
  1390.         left = comma;
  1391.     }
  1392.     }
  1393.     /* strip spaces at EOL and before commas */
  1394.     end = strlen(a) - 1;
  1395.     while (*(a + end) == ' ' || *(a + end) == '\t') {
  1396.     *(a + end) = '\0';
  1397.     end--;
  1398.     }
  1399.     left = a;
  1400.     while ((comma = index(left, ',')) != NULL) {
  1401.     quote = comma;
  1402.     while (*(quote - 1) == ' ' || *(quote - 1) == '\t') {
  1403.         quote--;
  1404.     }
  1405.     if (*quote == ' ' || *quote == '\t')
  1406.         strcpy(quote, comma);
  1407.     left = quote + 1;
  1408.     }
  1409.  
  1410.     /* split *a into individual addresses */
  1411.     end = 0;
  1412.     for (;;) {
  1413.     /* skip leading space */
  1414.     while (*a == ' ' || *a == '\t') { a++; }
  1415.     if (a == NULL)
  1416.         break;
  1417.  
  1418.     /* new space */
  1419.     if (new == NULL) {
  1420.         if ((new = malloc(sizeof(node))) == NULL) {
  1421.         fprintf(stderr, "%s: malloc failure: %s\n", progname,
  1422.             strerror(errno));
  1423.         exit(1 ^ negate);
  1424.         }
  1425.         bzero((void *) new, sizeof(node));
  1426.     }
  1427.  
  1428.     /* should be left with addresses separated by commas */
  1429.     if ((comma = index(a, ',')) != NULL) {
  1430.         *comma = '\0';
  1431.     } else {
  1432.         comma = a + strlen(a);
  1433.         end = 1;
  1434.     }
  1435.     
  1436.     if (*(comma - 1) == '>') {
  1437.         *(comma - 1) = '\0';
  1438.         if ((left = strrchr(a, '<')) == NULL) {
  1439.         fprintf(stderr, "%s: apparent address format error: %s\n",
  1440.             progname, a);
  1441.         exit(1 ^ negate);
  1442.         }
  1443.         left++;
  1444.         if (comma - left <= 0)
  1445.         goto SKIP;
  1446.     } else if ((left = strrchr(a, ' ')) != NULL) {
  1447.         left++;
  1448.     }
  1449.  
  1450.     if (left == NULL)
  1451.         left = a;
  1452.  
  1453.     if (strlen(left) == 0)
  1454.         goto SKIP;
  1455.  
  1456.     if (debug > 1)
  1457.         fprintf(stderr, "%s: split() adding: %s\n", progname, left);
  1458.  
  1459.     new->addr = strdup(left);
  1460.     lappend(dst, new);  new = NULL;
  1461.  
  1462. SKIP:    if (end)
  1463.         break;
  1464.     a = comma + 1;
  1465.     }
  1466.  
  1467.     if (new)
  1468.     free(new);
  1469.  
  1470.     return(0);
  1471. }
  1472.