home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libstyle / csstab.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  73.5 KB  |  2,404 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /*  A Bison parser, made from css.y
  20.  by  GNU Bison version 1.25
  21.   */
  22.  
  23. #define YYBISON 1  /* Identify Bison output.  */
  24.  
  25. #define yyparse css_parse
  26. #define yylex css_lex
  27. #define yyerror css_error
  28. #define yylval css_lval
  29. #define yychar css_char
  30. #define yydebug css_debug
  31. #define yynerrs css_nerrs
  32. #define    NUMBER    258
  33. #define    STRING    259
  34. #define    PERCENTAGE    260
  35. #define    LENGTH    261
  36. #define    EMS    262
  37. #define    EXS    263
  38. #define    IDENT    264
  39. #define    HEXCOLOR    265
  40. #define    URL    266
  41. #define    RGB    267
  42. #define    CDO    268
  43. #define    CDC    269
  44. #define    IMPORTANT_SYM    270
  45. #define    IMPORT_SYM    271
  46. #define    DOT_AFTER_IDENT    272
  47. #define    DOT    273
  48. #define    LINK_PSCLASS    274
  49. #define    VISITED_PSCLASS    275
  50. #define    ACTIVE_PSCLASS    276
  51. #define    LEADING_LINK_PSCLASS    277
  52. #define    LEADING_VISITED_PSCLASS    278
  53. #define    LEADING_ACTIVE_PSCLASS    279
  54. #define    FIRST_LINE    280
  55. #define    FIRST_LETTER    281
  56. #define    WILD    282
  57. #define    BACKGROUND    283
  58. #define    BG_COLOR    284
  59. #define    BG_IMAGE    285
  60. #define    BG_REPEAT    286
  61. #define    BG_ATTACHMENT    287
  62. #define    BG_POSITION    288
  63. #define    FONT    289
  64. #define    FONT_STYLE    290
  65. #define    FONT_VARIANT    291
  66. #define    FONT_WEIGHT    292
  67. #define    FONT_SIZE    293
  68. #define    FONT_NORMAL    294
  69. #define    LINE_HEIGHT    295
  70. #define    LIST_STYLE    296
  71. #define    LS_TYPE    297
  72. #define    LS_NONE    298
  73. #define    LS_POSITION    299
  74. #define    BORDER    300
  75. #define    BORDER_STYLE    301
  76. #define    BORDER_WIDTH    302
  77. #define    FONT_SIZE_PROPERTY    303
  78. #define    FONTDEF    304
  79.  
  80.  
  81.  
  82. #include <stdio.h>
  83. #include "cssI.h"
  84.  
  85.  
  86. typedef union {
  87.   css_node binary_node;
  88. } YYSTYPE;
  89.  
  90.  
  91.                  /* Background Shorthand Property */
  92.  
  93. typedef struct backgroundShorthandRecord {
  94.     css_node color;
  95.     css_node image;
  96.     css_node repeat;
  97.     css_node attachment;
  98.     css_node position;
  99.     int    parse_error;
  100. } BackgroundShorthandRecord, *BackgroundShorthand;
  101.  
  102. #define BackgroundColor      1
  103. #define BackgroundImage      2
  104. #define BackgroundRepeat     3
  105. #define BackgroundAttachment 4
  106. #define BackgroundPosition   5
  107.  
  108. static void ClearBackground(void);
  109. static void AddBackground(int node_type, css_node node);
  110. static css_node AssembleBackground(void);
  111.  
  112. static BackgroundShorthandRecord bg;
  113.  
  114. /* background property names */
  115. static char * bg_image = "background-image";
  116. static char * bg_color = "background-color";
  117. static char * bg_repeat = "background-repeat";
  118. static char * bg_attachment = "background-attachment";
  119. static char * bg_position = "background-position";
  120. /* background property initial values */
  121. static char * css_none = "none";
  122. static char * css_transparent = "transparent";
  123. static char * css_repeat = "repeat";
  124. static char * css_scroll = "scroll";
  125. static char * css_origin = "0% 0%";
  126.  
  127.  
  128.                     /* Font Shorthand Property */
  129.  
  130. typedef struct fontShorthandRecord {
  131.     css_node style;
  132.     css_node variant;
  133.     css_node weight;
  134.     css_node size;
  135.     css_node leading;
  136.     css_node family;
  137.     int normal_count;
  138.     int parse_error;
  139. } FontShorthandRecord, *FontShorthand;
  140.  
  141. #define FontStyle    6
  142. #define FontVariant  7
  143. #define FontWeight   8
  144. #define FontNormal   9
  145. #define FontSize    10
  146. #define FontLeading 11
  147. #define FontFamily  12
  148.  
  149. static void ClearFont(void);
  150. static void AddFont(int node_type, css_node node);
  151. static css_node AssembleFont(void);
  152.  
  153. static FontShorthandRecord font;
  154.  
  155. /* font property names */
  156. static char * line_height = "line-height";
  157. static char * font_family = "font-family";
  158. static char * font_style = "font-style";
  159. static char * font_variant = "font-variant";
  160. static char * font_weight = "font-weight";
  161. static char * font_size = "font-size";
  162. /* font property initial values */
  163. static char * css_normal = "normal";
  164.  
  165.  
  166.                  /* List-Style Shorthand Property */
  167.  
  168. typedef struct listStyleShorthandRecord {
  169.     css_node marker;
  170.     css_node image;
  171.     css_node position;
  172.     int none_count;
  173.     int parse_error;
  174. } ListStyleShorthandRecord, *ListStyleShorthand;
  175.  
  176. #define ListStyleMarker        13
  177. #define ListStyleImage        14
  178. #define ListStylePosition    15
  179. #define ListStyleNone        16
  180.  
  181. static void ClearListStyle(void);
  182. static void AddListStyle(int node_type, css_node node);
  183. static css_node AssembleListStyle(void);
  184.  
  185. static ListStyleShorthandRecord ls;
  186.  
  187. /* list-style property names */
  188. static char * list_style_type = "list-style-type";
  189. static char * list_style_image = "list-style-image";
  190. static char * list_style_position = "list-style-position";
  191. /* list-style initial values */
  192. static char * css_disc = "disc";
  193. static char * css_outside = "outside";
  194.  
  195.  
  196.                    /* Border Shorthand Property */
  197.  
  198. typedef struct borderShorthandRecord {
  199.     css_node width;
  200.     css_node style;
  201.     css_node color;
  202.     int parse_error;
  203. } BorderShorthandRecord, *BorderShorthand;
  204.  
  205. #define BorderWidth    17
  206. #define BorderStyle    18
  207. #define BorderColor    19
  208.  
  209. static void ClearBorder(void);
  210. static void AddBorder(int node_type, css_node node);
  211. static css_node AssembleBorder(void);
  212.  
  213. static BorderShorthandRecord border;
  214.  
  215. /* border property names */
  216. static char * border_width = "border-width";
  217. static char * border_style = "border-style";
  218. static char * border_color = "border-color";
  219. /* border initial values */
  220. static char * css_medium = "medium";
  221.  
  222.  
  223. /* Define yyoverflow and the forward declarations for bison. */
  224. #define yyoverflow css_overflow
  225. static void css_overflow(const char *message, short **yyss1, int yyss1_size, 
  226.                          YYSTYPE **yyvs1, int yyvs1_size, int *yystacksize);
  227. static css_node NewNode(int node_id, char *ss, css_node left, css_node right);
  228. static void LeftAppendNode(css_node head, css_node new_node);
  229. static css_node NewDeclarationNode(int node_id, char *ss, char *prop);
  230. static css_node NewComponentNode(css_node value, char *prop);
  231.  
  232. css_node css_tree_root;
  233.  
  234. /* pseudo-classes */
  235. static char * css_link = "link";
  236. static char * css_visited = "visited";
  237. static char * css_active = "active";
  238.  
  239. #ifdef CSS_PARSE_DEBUG
  240. #define TRACE1(str) trace1(str)
  241. #define TRACE2(format, str) trace2(format, str)
  242. static trace1(const char * str)
  243. {
  244.     printf("%s", str);
  245. }
  246.  
  247. static trace2(const char *fmt, char *str)
  248. {
  249.     printf(fmt, str);
  250. }
  251. #else
  252. #define TRACE1(str)
  253. #define TRACE2(format, str)
  254. #endif
  255.  
  256. int css_error(const char * diagnostic)
  257. {
  258. #ifdef CSS_PARSE_REPORT_ERRORS
  259.     char * identifier = "CSS1 parser message:";
  260.     (void) fprintf(stderr,
  261.                    "%s error, text ='%s', diagnostic ='%s'\n",
  262.                    identifier, css_text, diagnostic ? diagnostic : "");
  263. #endif
  264.     return 1;
  265. }
  266.  
  267.  
  268. int css_wrap(void)
  269. {
  270. #ifdef CSS_PARSE_DEBUG
  271.     printf("css_wrap() was called.\n");
  272. #endif
  273.     return 1;
  274. }
  275.  
  276. #include <stdio.h>
  277.  
  278. #ifndef __cplusplus
  279. #ifndef __STDC__
  280. #define const
  281. #endif
  282. #endif
  283.  
  284.  
  285.  
  286. #define    YYFINAL        173
  287. #define    YYFLAG        -32768
  288. #define    YYNTBASE    59
  289.  
  290. #define YYTRANSLATE(x) ((unsigned)(x) <= 304 ? yytranslate[x] : 115)
  291.  
  292. static const char yytranslate[] = {     0,
  293.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  294.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  295.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  296.      2,     2,     2,     2,    57,     2,     2,     2,     2,     2,
  297.      2,     2,    52,    54,    51,     2,    53,     2,     2,     2,
  298.      2,     2,     2,     2,     2,     2,     2,    58,    50,     2,
  299.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  300.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  301.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  302.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  303.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  304.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  305.      2,     2,    55,     2,    56,     2,     2,     2,     2,     2,
  306.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  307.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  308.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  309.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  310.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  311.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  312.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  313.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  314.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  315.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  316.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  317.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  318.      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
  319.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  320.     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
  321.     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
  322.     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  323.     46,    47,    48,    49
  324. };
  325.  
  326. #if YYDEBUG != 0
  327. static const short yyprhs[] = {     0,
  328.      0,     1,     4,     7,    10,    13,    16,    18,    20,    24,
  329.     28,    30,    32,    34,    36,    37,    39,    41,    43,    45,
  330.     47,    49,    51,    53,    58,    60,    64,    66,    69,    71,
  331.     74,    77,    79,    82,    84,    87,    89,    93,    96,   101,
  332.    105,   107,   109,   111,   113,   116,   118,   120,   122,   124,
  333.    126,   128,   130,   132,   134,   138,   139,   144,   149,   154,
  334.    159,   164,   169,   170,   172,   174,   176,   180,   182,   184,
  335.    186,   188,   190,   192,   195,   197,   199,   202,   204,   206,
  336.    208,   210,   212,   214,   216,   218,   220,   222,   224,   227,
  337.    230,   234,   236,   239,   241,   243,   245,   247,   249,   251,
  338.    253,   255,   257,   260,   262,   265,   267,   271,   277,   278,
  339.    280,   282,   284,   288,   289,   292,   294,   296,   298,   300,
  340.    302,   304,   307,   309,   311,   313,   315,   318,   320,   322,
  341.    324,   326,   328,   331,   333,   335,   337,   339
  342. };
  343.  
  344. static const short yyrhs[] = {    -1,
  345.     59,    13,     0,    59,    60,     0,    59,    72,     0,    59,
  346.     14,     0,    59,     1,     0,    61,     0,    62,     0,    16,
  347.     63,    50,     0,    49,    63,    50,     0,     4,     0,    95,
  348.      0,    51,     0,    52,     0,     0,    53,     0,    54,     0,
  349.      9,     0,    48,     0,    28,     0,    34,     0,    41,     0,
  350.     45,     0,    73,    55,    84,    56,     0,    74,     0,    73,
  351.     54,    74,     0,    77,     0,    77,    83,     0,    75,     0,
  352.     75,    83,     0,    76,    77,     0,    77,     0,    76,    77,
  353.      0,    78,     0,    18,    79,     0,    80,     0,    78,    17,
  354.     79,     0,    78,    81,     0,    78,    17,    79,    81,     0,
  355.     18,    79,    81,     0,    82,     0,    27,     0,     9,     0,
  356.      9,     0,    57,     9,     0,    19,     0,    20,     0,    21,
  357.      0,    22,     0,    23,     0,    24,     0,    25,     0,    26,
  358.      0,    85,     0,    84,    50,    85,     0,     0,    66,    58,
  359.     88,    86,     0,    67,    58,   109,    86,     0,    68,    58,
  360.     97,    86,     0,    69,    58,   103,    86,     0,    70,    58,
  361.    111,    86,     0,    71,    58,   113,    86,     0,     0,    87,
  362.      0,    15,     0,    89,     0,    88,    65,    89,     0,    94,
  363.      0,    96,     0,    95,     0,    92,     0,    90,     0,    91,
  364.      0,    64,    91,     0,     3,     0,    93,     0,    64,    93,
  365.      0,     5,     0,     6,     0,     7,     0,     8,     0,     4,
  366.      0,     9,     0,    11,     0,    10,     0,    12,     0,    98,
  367.      0,   100,     0,    98,   100,     0,   100,    98,     0,    98,
  368.    100,    98,     0,    99,     0,    98,    99,     0,    11,     0,
  369.     30,     0,    96,     0,     9,     0,    29,     0,    31,     0,
  370.     32,     0,   101,     0,    92,     0,    92,    92,     0,   102,
  371.      0,   102,   102,     0,    33,     0,   107,   109,   105,     0,
  372.    107,   109,    53,   110,   105,     0,     0,    54,     0,   106,
  373.      0,    94,     0,   106,   104,    94,     0,     0,   107,   108,
  374.      0,    35,     0,    36,     0,    37,     0,    39,     0,    93,
  375.      0,    38,     0,    52,    93,     0,    92,     0,    90,     0,
  376.     40,     0,   112,     0,   111,   112,     0,    42,     0,    43,
  377.      0,    44,     0,    95,     0,   114,     0,   113,   114,     0,
  378.     46,     0,    47,     0,    92,     0,    96,     0,     9,     0
  379. };
  380.  
  381. #endif
  382.  
  383. #if YYDEBUG != 0
  384. static const short yyrline[] = { 0,
  385.    268,   271,   275,   284,   296,   300,   307,   310,   316,   322,
  386.    328,   331,   339,   343,   350,   354,   358,   365,   372,   378,
  387.    387,   396,   404,   412,   419,   423,   437,   441,   445,   449,
  388.    461,   468,   472,   479,   483,   487,   491,   495,   499,   506,
  389.    510,   517,   523,   530,   537,   544,   547,   550,   556,   559,
  390.    562,   568,   572,   579,   583,   595,   599,   605,   611,   618,
  391.    625,   628,   634,   635,   639,   646,   650,   665,   666,   667,
  392.    668,   669,   673,   674,   682,   688,   689,   696,   699,   702,
  393.    705,   711,   714,   721,   727,   730,   736,   737,   738,   739,
  394.    740,   744,   745,   749,   753,   757,   761,   765,   769,   773,
  395.    780,   790,   793,   802,   805,   817,   823,   830,   842,   846,
  396.    853,   862,   866,   881,   884,   890,   895,   900,   905,   911,
  397.    912,   915,   922,   923,   924,   934,   935,   939,   944,   948,
  398.    953,   961,   962,   966,   971,   976,   981,   986
  399. };
  400. #endif
  401.  
  402.  
  403. #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
  404.  
  405. static const char * const yytname[] = {   "$","error","$undefined.","NUMBER",
  406. "STRING","PERCENTAGE","LENGTH","EMS","EXS","IDENT","HEXCOLOR","URL","RGB","CDO",
  407. "CDC","IMPORTANT_SYM","IMPORT_SYM","DOT_AFTER_IDENT","DOT","LINK_PSCLASS","VISITED_PSCLASS",
  408. "ACTIVE_PSCLASS","LEADING_LINK_PSCLASS","LEADING_VISITED_PSCLASS","LEADING_ACTIVE_PSCLASS",
  409. "FIRST_LINE","FIRST_LETTER","WILD","BACKGROUND","BG_COLOR","BG_IMAGE","BG_REPEAT",
  410. "BG_ATTACHMENT","BG_POSITION","FONT","FONT_STYLE","FONT_VARIANT","FONT_WEIGHT",
  411. "FONT_SIZE","FONT_NORMAL","LINE_HEIGHT","LIST_STYLE","LS_TYPE","LS_NONE","LS_POSITION",
  412. "BORDER","BORDER_STYLE","BORDER_WIDTH","FONT_SIZE_PROPERTY","FONTDEF","';'",
  413. "'-'","'+'","'/'","','","'{'","'}'","'#'","':'","stylesheet","atrule","import",
  414. "fontdef","import_value","unary_operator","operator","property","font_size_property",
  415. "background_property","font_property","list_style_property","border_property",
  416. "ruleset","selector_list","selector","contextual_selector","contextual_selector_list",
  417. "simple_selector","element_name","class","id","pseudo_class","leading_pseudo_class",
  418. "pseudo_element","declaration_list","declaration","optional_priority","prio",
  419. "expr","term","numeric_const","unsigned_numeric_const","numeric_unit","unsigned_numeric_unit",
  420. "unsigned_symbol","url","color_code","background_values_list","background_values",
  421. "background_value","background_position_value","background_position_expr","background_position_keyword",
  422. "font_values_list","font_family_operator","font_family_value","font_family_expr",
  423. "font_optional_values_list","font_optional_value","font_size_value","line_height_value",
  424. "list_style_values_list","list_style_value","border_values_list","border_value", NULL
  425. };
  426. #endif
  427.  
  428. static const short yyr1[] = {     0,
  429.     59,    59,    59,    59,    59,    59,    60,    60,    61,    62,
  430.     63,    63,    64,    64,    65,    65,    65,    66,    67,    68,
  431.     69,    70,    71,    72,    73,    73,    74,    74,    74,    74,
  432.     75,    76,    76,    77,    77,    77,    77,    77,    77,    77,
  433.     77,    77,    78,    79,    80,    81,    81,    81,    82,    82,
  434.     82,    83,    83,    84,    84,    85,    85,    85,    85,    85,
  435.     85,    85,    86,    86,    87,    88,    88,    89,    89,    89,
  436.     89,    89,    90,    90,    91,    92,    92,    93,    93,    93,
  437.     93,    94,    94,    95,    96,    96,    97,    97,    97,    97,
  438.     97,    98,    98,    99,    99,    99,    99,    99,    99,    99,
  439.    100,   101,   101,   101,   101,   102,   103,   103,   104,   104,
  440.    105,   106,   106,   107,   107,   108,   108,   108,   108,   109,
  441.    109,   109,   110,   110,   110,   111,   111,   112,   112,   112,
  442.    112,   113,   113,   114,   114,   114,   114,   114
  443. };
  444.  
  445. static const short yyr2[] = {     0,
  446.      0,     2,     2,     2,     2,     2,     1,     1,     3,     3,
  447.      1,     1,     1,     1,     0,     1,     1,     1,     1,     1,
  448.      1,     1,     1,     4,     1,     3,     1,     2,     1,     2,
  449.      2,     1,     2,     1,     2,     1,     3,     2,     4,     3,
  450.      1,     1,     1,     1,     2,     1,     1,     1,     1,     1,
  451.      1,     1,     1,     1,     3,     0,     4,     4,     4,     4,
  452.      4,     4,     0,     1,     1,     1,     3,     1,     1,     1,
  453.      1,     1,     1,     2,     1,     1,     2,     1,     1,     1,
  454.      1,     1,     1,     1,     1,     1,     1,     1,     2,     2,
  455.      3,     1,     2,     1,     1,     1,     1,     1,     1,     1,
  456.      1,     1,     2,     1,     2,     1,     3,     5,     0,     1,
  457.      1,     1,     3,     0,     2,     1,     1,     1,     1,     1,
  458.      1,     2,     1,     1,     1,     1,     2,     1,     1,     1,
  459.      1,     1,     2,     1,     1,     1,     1,     1
  460. };
  461.  
  462. static const short yydefact[] = {     1,
  463.      0,     6,    43,     2,     5,     0,     0,    49,    50,    51,
  464.     42,     0,     0,     3,     7,     8,     4,     0,    25,    29,
  465.      0,    32,    34,    36,    41,    11,    84,     0,    12,    44,
  466.     35,     0,    45,     0,    56,    52,    53,    30,    33,    28,
  467.      0,    46,    47,    48,    38,     9,    40,    10,    26,    18,
  468.     20,    21,    22,    23,    19,     0,     0,     0,     0,     0,
  469.      0,     0,    54,    37,     0,     0,     0,   114,     0,     0,
  470.     56,    24,    39,    75,    82,    78,    79,    80,    81,    83,
  471.     85,    86,    13,    14,     0,    15,    66,    72,    73,    71,
  472.     76,    68,    70,    69,   121,     0,   120,    63,    97,    94,
  473.     98,    95,    99,   100,   106,     0,   102,    96,    63,    87,
  474.     92,    88,   101,   104,    63,     0,   128,   129,   130,   131,
  475.     63,   126,   138,   134,   135,   136,   137,    63,   132,    55,
  476.     74,    77,    65,    16,    17,     0,    57,    64,   122,    58,
  477.    103,    59,    93,    89,    90,   105,    60,   116,   117,   118,
  478.    119,   115,     0,    61,   127,    62,   133,    67,    91,     0,
  479.    112,   107,   111,   125,   124,   123,     0,   110,     0,   108,
  480.    113,     0,     0
  481. };
  482.  
  483. static const short yydefgoto[] = {     1,
  484.     14,    15,    16,    28,   106,   136,    56,    57,    58,    59,
  485.     60,    61,    17,    18,    19,    20,    21,    22,    23,    31,
  486.     24,    45,    25,    38,    62,    63,   137,   138,    86,    87,
  487.     88,    89,    90,    91,    92,    29,   108,   109,   110,   111,
  488.    112,   113,   114,   115,   169,   162,   163,   116,   152,    98,
  489.    167,   121,   122,   128,   129
  490. };
  491.  
  492. static const short yypact[] = {-32768,
  493.     10,-32768,-32768,-32768,-32768,    11,     0,-32768,-32768,-32768,
  494. -32768,    11,    18,-32768,-32768,-32768,-32768,   -37,-32768,    38,
  495.     78,   -12,   150,-32768,-32768,-32768,-32768,   -14,-32768,-32768,
  496.    155,   -10,-32768,    78,   170,-32768,-32768,-32768,   180,-32768,
  497.      0,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  498. -32768,-32768,-32768,-32768,-32768,    -2,    14,    27,    30,    31,
  499.     35,   -25,-32768,   155,    72,   121,   101,-32768,   103,   131,
  500.    170,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  501. -32768,-32768,-32768,-32768,   223,   134,-32768,-32768,-32768,-32768,
  502. -32768,-32768,-32768,-32768,-32768,   231,-32768,    53,-32768,-32768,
  503. -32768,-32768,-32768,-32768,-32768,   231,    40,-32768,    53,   101,
  504. -32768,   213,-32768,    36,    53,   158,-32768,-32768,-32768,-32768,
  505.    157,-32768,-32768,-32768,-32768,-32768,-32768,   110,-32768,-32768,
  506. -32768,-32768,-32768,-32768,-32768,    72,-32768,-32768,-32768,-32768,
  507. -32768,-32768,-32768,   213,   213,-32768,-32768,-32768,-32768,-32768,
  508. -32768,-32768,    12,-32768,-32768,-32768,-32768,-32768,   213,    46,
  509. -32768,-32768,     3,-32768,-32768,-32768,    26,-32768,    26,-32768,
  510. -32768,    99,-32768
  511. };
  512.  
  513. static const short yypgoto[] = {-32768,
  514. -32768,-32768,-32768,    91,   -65,-32768,-32768,-32768,-32768,-32768,
  515. -32768,-32768,-32768,-32768,    87,-32768,-32768,   127,-32768,   109,
  516. -32768,   -26,-32768,   120,-32768,    80,    93,-32768,-32768,    19,
  517.     -6,    95,   -66,   -46,    -9,   -63,   -62,-32768,   -83,   -55,
  518.     71,-32768,    75,-32768,-32768,    25,-32768,-32768,-32768,    69,
  519. -32768,-32768,    65,-32768,    79
  520. };
  521.  
  522.  
  523. #define    YYLAST        245
  524.  
  525.  
  526. static const short yytable[] = {    85,
  527.    107,    93,    94,   126,    47,   120,  -109,   127,    30,   172,
  528.      2,  -109,    36,    37,    26,    75,    34,    35,     3,    97,
  529.     80,    27,     4,     5,    71,     6,    33,     7,   145,    75,
  530.     72,     8,     9,    10,    80,    46,    11,    73,   132,    48,
  531.    141,   -27,   -27,   107,    76,    77,    78,    79,    74,   139,
  532.     76,    77,    78,    79,   143,    65,   168,   120,    12,   132,
  533.    159,   126,    36,    37,   160,   127,    13,   133,   105,    97,
  534.     85,    66,    93,    94,    74,    75,    76,    77,    78,    79,
  535.     80,    81,    27,    82,    67,   164,     3,    68,    69,   143,
  536.     83,    84,    70,   166,    85,     7,    83,    84,   173,     8,
  537.      9,    10,    32,   143,    11,    76,    77,    78,    79,    99,
  538.     81,   100,    82,    27,    76,    77,    78,    79,   123,    81,
  539.     49,    82,    83,    84,   133,    76,    77,    78,    79,   101,
  540.    102,   103,   104,   105,    13,    76,    77,    78,    79,   123,
  541.     81,    40,    82,   161,   117,   118,   119,    39,   133,    64,
  542.    130,    83,    84,   165,   158,   124,   125,   161,    95,   171,
  543.     83,    84,    76,    77,    78,    79,    41,    27,    42,    43,
  544.     44,   133,    96,    42,    43,    44,   124,   125,    50,   131,
  545.    144,    83,    84,   -63,   153,   155,   134,   135,   146,   -63,
  546.    140,   170,   148,   149,   150,    95,   151,    51,   117,   118,
  547.    119,   142,     0,    52,   -31,   -31,   157,   147,     0,    96,
  548.     53,     0,     0,   154,    54,     0,     0,    55,     0,     0,
  549.    156,    99,    81,   100,    82,    74,     0,    76,    77,    78,
  550.     79,     0,     0,   -31,   -31,    76,    77,    78,    79,     0,
  551.      0,   101,   102,   103,   104
  552. };
  553.  
  554. static const short yycheck[] = {    65,
  555.     67,    65,    65,    70,    31,    69,     4,    70,     9,     0,
  556.      1,     9,    25,    26,     4,     4,    54,    55,     9,    66,
  557.      9,    11,    13,    14,    50,    16,     9,    18,   112,     4,
  558.     56,    22,    23,    24,     9,    50,    27,    64,    85,    50,
  559.    107,    54,    55,   110,     5,     6,     7,     8,     3,    96,
  560.      5,     6,     7,     8,   110,    58,    54,   121,    49,   106,
  561.    144,   128,    25,    26,    53,   128,    57,    15,    33,   116,
  562.    136,    58,   136,   136,     3,     4,     5,     6,     7,     8,
  563.      9,    10,    11,    12,    58,    40,     9,    58,    58,   145,
  564.     51,    52,    58,   160,   160,    18,    51,    52,     0,    22,
  565.     23,    24,    12,   159,    27,     5,     6,     7,     8,     9,
  566.     10,    11,    12,    11,     5,     6,     7,     8,     9,    10,
  567.     34,    12,    51,    52,    15,     5,     6,     7,     8,    29,
  568.     30,    31,    32,    33,    57,     5,     6,     7,     8,     9,
  569.     10,    22,    12,   153,    42,    43,    44,    21,    15,    41,
  570.     71,    51,    52,   160,   136,    46,    47,   167,    38,   169,
  571.     51,    52,     5,     6,     7,     8,    17,    11,    19,    20,
  572.     21,    15,    52,    19,    20,    21,    46,    47,     9,    85,
  573.    110,    51,    52,    50,   116,   121,    53,    54,   114,    56,
  574.     98,   167,    35,    36,    37,    38,    39,    28,    42,    43,
  575.     44,   109,    -1,    34,    25,    26,   128,   115,    -1,    52,
  576.     41,    -1,    -1,   121,    45,    -1,    -1,    48,    -1,    -1,
  577.    128,     9,    10,    11,    12,     3,    -1,     5,     6,     7,
  578.      8,    -1,    -1,    54,    55,     5,     6,     7,     8,    -1,
  579.     -1,    29,    30,    31,    32
  580. };
  581. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  582.  
  583.  
  584. /* Skeleton output parser for bison,
  585.    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
  586.  
  587.    This program is free software; you can redistribute it and/or modify
  588.    it under the terms of the GNU General Public License as published by
  589.    the Free Software Foundation; either version 2, or (at your option)
  590.    any later version.
  591.  
  592.    This program is distributed in the hope that it will be useful,
  593.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  594.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  595.    GNU General Public License for more details.
  596.  
  597.    You should have received a copy of the GNU General Public License
  598.    along with this program; if not, write to the Free Software
  599.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  600.  
  601. /* As a special exception, when this file is copied by Bison into a
  602.    Bison output file, you may use that output file without restriction.
  603.    This special exception was added by the Free Software Foundation
  604.    in version 1.24 of Bison.  */
  605.  
  606. #ifndef alloca
  607. #ifdef __GNUC__
  608. #define alloca __builtin_alloca
  609. #else /* not GNU C.  */
  610. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
  611. #include <alloca.h>
  612. #else /* not sparc */
  613. #if defined (MSDOS) && !defined (__TURBOC__)
  614. #include <malloc.h>
  615. #else /* not MSDOS, or __TURBOC__ */
  616. #if defined(_AIX)
  617. #include <malloc.h>
  618.  #pragma alloca
  619. #else /* not MSDOS, __TURBOC__, or _AIX */
  620. #ifdef __hpux
  621. #ifdef __cplusplus
  622. extern "C" {
  623. void *alloca (unsigned int);
  624. };
  625. #else /* not __cplusplus */
  626. void *alloca ();
  627. #endif /* not __cplusplus */
  628. #endif /* __hpux */
  629. #endif /* not _AIX */
  630. #endif /* not MSDOS, or __TURBOC__ */
  631. #endif /* not sparc.  */
  632. #endif /* not GNU C.  */
  633. #endif /* alloca not defined.  */
  634.  
  635. /* This is the parser code that is written into each bison parser
  636.   when the %semantic_parser declaration is not specified in the grammar.
  637.   It was written by Richard Stallman by simplifying the hairy parser
  638.   used when %semantic_parser is specified.  */
  639.  
  640. /* Note: there must be only one dollar sign in this file.
  641.    It is replaced by the list of actions, each action
  642.    as one case of the switch.  */
  643.  
  644. #define yyerrok        (yyerrstatus = 0)
  645. #define yyclearin    (yychar = YYEMPTY)
  646. #define YYEMPTY        -2
  647. #define YYEOF        0
  648. #define YYACCEPT    return(0)
  649. #define YYABORT     return(1)
  650. #define YYERROR        goto yyerrlab1
  651. /* Like YYERROR except do call yyerror.
  652.    This remains here temporarily to ease the
  653.    transition to the new meaning of YYERROR, for GCC.
  654.    Once GCC version 2 has supplanted version 1, this can go.  */
  655. #define YYFAIL        goto yyerrlab
  656. #define YYRECOVERING()  (!!yyerrstatus)
  657. #define YYBACKUP(token, value) \
  658. do                                \
  659.   if (yychar == YYEMPTY && yylen == 1)                \
  660.     { yychar = (token), yylval = (value);            \
  661.       yychar1 = YYTRANSLATE (yychar);                \
  662.       YYPOPSTACK;                        \
  663.       goto yybackup;                        \
  664.     }                                \
  665.   else                                \
  666.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  667. while (0)
  668.  
  669. #define YYTERROR    1
  670. #define YYERRCODE    256
  671.  
  672. #ifndef YYPURE
  673. #define YYLEX        yylex()
  674. #endif
  675.  
  676. #ifdef YYPURE
  677. #ifdef YYLSP_NEEDED
  678. #ifdef YYLEX_PARAM
  679. #define YYLEX        yylex(&yylval, &yylloc, YYLEX_PARAM)
  680. #else
  681. #define YYLEX        yylex(&yylval, &yylloc)
  682. #endif
  683. #else /* not YYLSP_NEEDED */
  684. #ifdef YYLEX_PARAM
  685. #define YYLEX        yylex(&yylval, YYLEX_PARAM)
  686. #else
  687. #define YYLEX        yylex(&yylval)
  688. #endif
  689. #endif /* not YYLSP_NEEDED */
  690. #endif
  691.  
  692. /* If nonreentrant, generate the variables here */
  693.  
  694. #ifndef YYPURE
  695.  
  696. int    yychar;            /*  the lookahead symbol        */
  697. YYSTYPE    yylval;            /*  the semantic value of the        */
  698.                 /*  lookahead symbol            */
  699.  
  700. #ifdef YYLSP_NEEDED
  701. YYLTYPE yylloc;            /*  location data for the lookahead    */
  702.                 /*  symbol                */
  703. #endif
  704.  
  705. int yynerrs;            /*  number of parse errors so far       */
  706. #endif  /* not YYPURE */
  707.  
  708. #if YYDEBUG != 0
  709. int yydebug;            /*  nonzero means print parse trace    */
  710. /* Since this is uninitialized, it does not stop multiple parsers
  711.    from coexisting.  */
  712. #endif
  713.  
  714. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  715.  
  716. #ifndef    YYINITDEPTH
  717. #define YYINITDEPTH 200
  718. #endif
  719.  
  720. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  721.     (effective only if the built-in stack extension method is used).  */
  722.  
  723. #if YYMAXDEPTH == 0
  724. #undef YYMAXDEPTH
  725. #endif
  726.  
  727. #ifndef YYMAXDEPTH
  728. #define YYMAXDEPTH 10000
  729. #endif
  730.  
  731. /* Prevent warning if -Wstrict-prototypes.  */
  732. #ifdef __GNUC__
  733. int yyparse (void);
  734. #endif
  735.  
  736. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  737. #define __yy_memcpy(TO,FROM,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  738. #else                /* not GNU C or C++ */
  739. #ifndef __cplusplus
  740.  
  741. /* This is the most reliable way to avoid incompatibilities
  742.    in available built-in functions on various systems.  */
  743. static void
  744. __yy_memcpy (to, from, count)
  745.      char *to;
  746.      char *from;
  747.      int count;
  748. {
  749.   register char *f = from;
  750.   register char *t = to;
  751.   register int i = count;
  752.  
  753.   while (i-- > 0)
  754.     *t++ = *f++;
  755. }
  756.  
  757. #else /* __cplusplus */
  758.  
  759. /* This is the most reliable way to avoid incompatibilities
  760.    in available built-in functions on various systems.  */
  761. static void
  762. __yy_memcpy (char *to, char *from, int count)
  763. {
  764.   register char *f = from;
  765.   register char *t = to;
  766.   register int i = count;
  767.  
  768.   while (i-- > 0)
  769.     *t++ = *f++;
  770. }
  771.  
  772. #endif
  773. #endif
  774.  
  775.  
  776.  
  777. /* The user can define YYPARSE_PARAM as the name of an argument to be passed
  778.    into yyparse.  The argument should have type void *.
  779.    It should actually point to an object.
  780.    Grammar actions can access the variable by casting it
  781.    to the proper pointer type.  */
  782.  
  783. #ifdef YYPARSE_PARAM
  784. #ifdef __cplusplus
  785. #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
  786. #define YYPARSE_PARAM_DECL
  787. #else /* not __cplusplus */
  788. #define YYPARSE_PARAM_ARG YYPARSE_PARAM
  789. #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
  790. #endif /* not __cplusplus */
  791. #else /* not YYPARSE_PARAM */
  792. #define YYPARSE_PARAM_ARG
  793. #define YYPARSE_PARAM_DECL
  794. #endif /* not YYPARSE_PARAM */
  795.  
  796. int
  797. yyparse(YYPARSE_PARAM_ARG)
  798.      YYPARSE_PARAM_DECL
  799. {
  800.   register int yystate;
  801.   register int yyn;
  802.   register short *yyssp;
  803.   register YYSTYPE *yyvsp;
  804.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  805.   int yychar1 = 0;        /*  lookahead token as an internal (translated) token number */
  806.  
  807.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  808.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  809.  
  810.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  811.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  812.  
  813. #ifdef YYLSP_NEEDED
  814.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  815.   YYLTYPE *yyls = yylsa;
  816.   YYLTYPE *yylsp;
  817.  
  818. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  819. #else
  820. #define YYPOPSTACK   (yyvsp--, yyssp--)
  821. #endif
  822.  
  823.   int yystacksize = YYINITDEPTH;
  824.  
  825. #ifdef YYPURE
  826.   int yychar;
  827.   YYSTYPE yylval;
  828.   int yynerrs;
  829. #ifdef YYLSP_NEEDED
  830.   YYLTYPE yylloc;
  831. #endif
  832. #endif
  833.  
  834.   YYSTYPE yyval;        /*  the variable used to return        */
  835.                 /*  semantic values from the action    */
  836.                 /*  routines                */
  837.  
  838.   int yylen;
  839.  
  840. #if YYDEBUG != 0
  841.   if (yydebug)
  842.     fprintf(stderr, "Starting parse\n");
  843. #endif
  844.  
  845.   yystate = 0;
  846.   yyerrstatus = 0;
  847.   yynerrs = 0;
  848.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  849.  
  850.   /* Initialize stack pointers.
  851.      Waste one element of value and location stack
  852.      so that they stay on the same level as the state stack.
  853.      The wasted elements are never initialized.  */
  854.  
  855.   yyssp = yyss - 1;
  856.   yyvsp = yyvs;
  857. #ifdef YYLSP_NEEDED
  858.   yylsp = yyls;
  859. #endif
  860.  
  861. /* Push a new state, which is found in  yystate  .  */
  862. /* In all cases, when you get here, the value and location stacks
  863.    have just been pushed. so pushing a state here evens the stacks.  */
  864. yynewstate:
  865.  
  866.   *++yyssp = yystate;
  867.  
  868.   if (yyssp >= yyss + yystacksize - 1)
  869.     {
  870.       /* Give user a chance to reallocate the stack */
  871.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  872.       YYSTYPE *yyvs1 = yyvs;
  873.       short *yyss1 = yyss;
  874. #ifdef YYLSP_NEEDED
  875.       YYLTYPE *yyls1 = yyls;
  876. #endif
  877.  
  878.       /* Get the current used size of the three stacks, in elements.  */
  879.       int size = yyssp - yyss + 1;
  880.  
  881. #ifdef yyoverflow
  882.       /* Each stack pointer address is followed by the size of
  883.      the data in use in that stack, in bytes.  */
  884. #ifdef YYLSP_NEEDED
  885.       /* This used to be a conditional around just the two extra args,
  886.      but that might be undefined if yyoverflow is a macro.  */
  887.       yyoverflow("parser stack overflow",
  888.          &yyss1, size * sizeof (*yyssp),
  889.          &yyvs1, size * sizeof (*yyvsp),
  890.          &yyls1, size * sizeof (*yylsp),
  891.          &yystacksize);
  892. #else
  893.       yyoverflow("parser stack overflow",
  894.          &yyss1, size * sizeof (*yyssp),
  895.          &yyvs1, size * sizeof (*yyvsp),
  896.          &yystacksize);
  897. #endif
  898.  
  899.       yyss = yyss1; yyvs = yyvs1;
  900. #ifdef YYLSP_NEEDED
  901.       yyls = yyls1;
  902. #endif
  903. #else /* no yyoverflow */
  904.       /* Extend the stack our own way.  */
  905.       if (yystacksize >= YYMAXDEPTH)
  906.     {
  907.       yyerror("parser stack overflow");
  908.       return 2;
  909.     }
  910.       yystacksize *= 2;
  911.       if (yystacksize > YYMAXDEPTH)
  912.     yystacksize = YYMAXDEPTH;
  913.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  914.       __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
  915.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  916.       __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
  917. #ifdef YYLSP_NEEDED
  918.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  919.       __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
  920. #endif
  921. #endif /* no yyoverflow */
  922.  
  923.       yyssp = yyss + size - 1;
  924.       yyvsp = yyvs + size - 1;
  925. #ifdef YYLSP_NEEDED
  926.       yylsp = yyls + size - 1;
  927. #endif
  928.  
  929. #if YYDEBUG != 0
  930.       if (yydebug)
  931.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  932. #endif
  933.  
  934.       if (yyssp >= yyss + yystacksize - 1)
  935.     YYABORT;
  936.     }
  937.  
  938. #if YYDEBUG != 0
  939.   if (yydebug)
  940.     fprintf(stderr, "Entering state %d\n", yystate);
  941. #endif
  942.  
  943.   goto yybackup;
  944.  yybackup:
  945.  
  946. /* Do appropriate processing given the current state.  */
  947. /* Read a lookahead token if we need one and don't already have one.  */
  948. /* yyresume: */
  949.  
  950.   /* First try to decide what to do without reference to lookahead token.  */
  951.  
  952.   yyn = yypact[yystate];
  953.   if (yyn == YYFLAG)
  954.     goto yydefault;
  955.  
  956.   /* Not known => get a lookahead token if don't already have one.  */
  957.  
  958.   /* yychar is either YYEMPTY or YYEOF
  959.      or a valid token in external form.  */
  960.  
  961.   if (yychar == YYEMPTY)
  962.     {
  963. #if YYDEBUG != 0
  964.       if (yydebug)
  965.     fprintf(stderr, "Reading a token: ");
  966. #endif
  967.       yychar = YYLEX;
  968.     }
  969.  
  970.   /* Convert token to internal form (in yychar1) for indexing tables with */
  971.  
  972.   if (yychar <= 0)        /* This means end of input. */
  973.     {
  974.       yychar1 = 0;
  975.       yychar = YYEOF;        /* Don't call YYLEX any more */
  976.  
  977. #if YYDEBUG != 0
  978.       if (yydebug)
  979.     fprintf(stderr, "Now at end of input.\n");
  980. #endif
  981.     }
  982.   else
  983.     {
  984.       yychar1 = YYTRANSLATE(yychar);
  985.  
  986. #if YYDEBUG != 0
  987.       if (yydebug)
  988.     {
  989.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  990.       /* Give the individual parser a way to print the precise meaning
  991.          of a token, for further debugging info.  */
  992. #ifdef YYPRINT
  993.       YYPRINT (stderr, yychar, yylval);
  994. #endif
  995.       fprintf (stderr, ")\n");
  996.     }
  997. #endif
  998.     }
  999.  
  1000.   yyn += yychar1;
  1001.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  1002.     goto yydefault;
  1003.  
  1004.   yyn = yytable[yyn];
  1005.  
  1006.   /* yyn is what to do for this token type in this state.
  1007.      Negative => reduce, -yyn is rule number.
  1008.      Positive => shift, yyn is new state.
  1009.        New state is final state => don't bother to shift,
  1010.        just return success.
  1011.      0, or most negative number => error.  */
  1012.  
  1013.   if (yyn < 0)
  1014.     {
  1015.       if (yyn == YYFLAG)
  1016.     goto yyerrlab;
  1017.       yyn = -yyn;
  1018.       goto yyreduce;
  1019.     }
  1020.   else if (yyn == 0)
  1021.     goto yyerrlab;
  1022.  
  1023.   if (yyn == YYFINAL)
  1024.     YYACCEPT;
  1025.  
  1026.   /* Shift the lookahead token.  */
  1027.  
  1028. #if YYDEBUG != 0
  1029.   if (yydebug)
  1030.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  1031. #endif
  1032.  
  1033.   /* Discard the token being shifted unless it is eof.  */
  1034.   if (yychar != YYEOF)
  1035.     yychar = YYEMPTY;
  1036.  
  1037.   *++yyvsp = yylval;
  1038. #ifdef YYLSP_NEEDED
  1039.   *++yylsp = yylloc;
  1040. #endif
  1041.  
  1042.   /* count tokens shifted since error; after three, turn off error status.  */
  1043.   if (yyerrstatus) yyerrstatus--;
  1044.  
  1045.   yystate = yyn;
  1046.   goto yynewstate;
  1047.  
  1048. /* Do the default action for the current state.  */
  1049. yydefault:
  1050.  
  1051.   yyn = yydefact[yystate];
  1052.   if (yyn == 0)
  1053.     goto yyerrlab;
  1054.  
  1055. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  1056. yyreduce:
  1057.   yylen = yyr2[yyn];
  1058.   if (yylen > 0)
  1059.     yyval = yyvsp[1-yylen]; /* implement default value of the action */
  1060.  
  1061. #if YYDEBUG != 0
  1062.   if (yydebug)
  1063.     {
  1064.       int i;
  1065.  
  1066.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  1067.            yyn, yyrline[yyn]);
  1068.  
  1069.       /* Print the symbols being reduced, and their result.  */
  1070.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  1071.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  1072.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  1073.     }
  1074. #endif
  1075.  
  1076.  
  1077.   switch (yyn) {
  1078.  
  1079. case 1:
  1080. {
  1081.         yyval.binary_node = NULL;
  1082.         ;
  1083.     break;}
  1084. case 2:
  1085. {
  1086.         TRACE1("-cdo\n");
  1087.         yyval.binary_node = yyvsp[-1].binary_node;
  1088.         ;
  1089.     break;}
  1090. case 3:
  1091. {
  1092.         yyval.binary_node = yyvsp[-1].binary_node;
  1093.         if (yyval.binary_node == NULL) {
  1094.             css_tree_root = yyvsp[0].binary_node;
  1095.             yyval.binary_node = css_tree_root;
  1096.         }
  1097.         else
  1098.             LeftAppendNode(yyval.binary_node, yyvsp[0].binary_node);
  1099.         ;
  1100.     break;}
  1101. case 4:
  1102. {
  1103.         css_node tmp;
  1104.         tmp = NewNode(NODE_RULESET_LIST, NULL, NULL, yyvsp[0].binary_node);
  1105.         
  1106.         yyval.binary_node = yyvsp[-1].binary_node;
  1107.         if (yyval.binary_node == NULL) {
  1108.             css_tree_root = tmp;
  1109.             yyval.binary_node = css_tree_root;
  1110.         }
  1111.         else
  1112.             LeftAppendNode(yyval.binary_node, tmp);
  1113.         ;
  1114.     break;}
  1115. case 5:
  1116. {
  1117.         TRACE1("-cdc\n");
  1118.         yyval.binary_node = yyvsp[-1].binary_node;
  1119.         ;
  1120.     break;}
  1121. case 6:
  1122. {
  1123.         yyerrok;
  1124.         yyclearin;
  1125.         ;
  1126.     break;}
  1127. case 7:
  1128. {
  1129.         yyval.binary_node = NewNode(NODE_IMPORT_LIST, NULL, NULL, yyvsp[0].binary_node);
  1130.         ;
  1131.     break;}
  1132. case 8:
  1133. {
  1134.         yyval.binary_node = NewNode(NODE_FONTDEF_LIST, NULL, NULL, yyvsp[0].binary_node);
  1135.         ;
  1136.     break;}
  1137. case 9:
  1138.      yyval.binary_node = yyvsp[-1].binary_node;
  1139.    ;
  1140.     break;}
  1141. case 10:
  1142.         yyval.binary_node = yyvsp[-1].binary_node;
  1143.         ;
  1144.     break;}
  1145. case 11:
  1146. {
  1147.     yyval.binary_node = NewNode(NODE_IMPORT_STRING, css_text, NULL, NULL);
  1148.    ;
  1149.     break;}
  1150. case 12:
  1151. {
  1152.      TRACE1("-import url\n");
  1153.      yyvsp[0].binary_node->node_id = NODE_IMPORT_URL;
  1154.      yyval.binary_node = yyvsp[0].binary_node;
  1155.    ;
  1156.     break;}
  1157. case 13:
  1158.      TRACE1("-unary_op '-'\n");
  1159.      yyval.binary_node = NewNode(NODE_UNARY_OP, css_text, NULL, NULL);
  1160.    ;
  1161.     break;}
  1162. case 14:
  1163. {
  1164.      TRACE1("-unary_op '+'\n");
  1165.      yyval.binary_node = NewNode(NODE_UNARY_OP, css_text, NULL, NULL);
  1166.    ;
  1167.     break;}
  1168. case 15:
  1169.      TRACE1("-empty operator\n");
  1170.      yyval.binary_node = NewNode(NODE_EMPTY_OP, NULL, NULL, NULL);
  1171.    ;
  1172.     break;}
  1173. case 16:
  1174.      TRACE1("-operator : '/'\n"); 
  1175.      yyval.binary_node = NewNode(NODE_EXPR_OP, css_text, NULL, NULL);
  1176.    ;
  1177.     break;}
  1178. case 17:
  1179.      TRACE1("-operator : ','\n"); 
  1180.      yyval.binary_node = NewNode(NODE_EXPR_OP, css_text, NULL, NULL);
  1181.    ;
  1182.     break;}
  1183. case 18:
  1184. {
  1185.      TRACE2("-property : IDENT '%s'\n", css_text); 
  1186.      yyval.binary_node = NewNode(NODE_PROPERTY, css_text, NULL, NULL);
  1187.    ;
  1188.     break;}
  1189. case 19:
  1190. {
  1191.      yyval.binary_node = NewNode(NODE_PROPERTY, css_text, NULL, NULL);
  1192.    ;
  1193.     break;}
  1194. case 20:
  1195. {
  1196.      TRACE2("-property : BACKGROUND '%s'\n", css_text);
  1197.      ClearBackground();
  1198.      yyval.binary_node = NULL;
  1199.      /* This shorthand property will generate five component properties. */
  1200.    ;
  1201.     break;}
  1202. case 21:
  1203. {
  1204.      TRACE2("-property : FONT '%s'\n", css_text);
  1205.      ClearFont();
  1206.      yyval.binary_node = NULL;
  1207.      /* This shorthand property will generate six component properties. */
  1208.    ;
  1209.     break;}
  1210. case 22:
  1211. {
  1212.      ClearListStyle();
  1213.      yyval.binary_node = NULL;
  1214.      /* This shorthand property will generate three component properties. */
  1215.    ;
  1216.     break;}
  1217. case 23:
  1218. {
  1219.      ClearBorder();
  1220.      yyval.binary_node = NULL;
  1221.      /* This shorthand property will generate 2 or 3 component properties. */
  1222.    ;
  1223.     break;}
  1224. case 24:
  1225.      TRACE1("-selector_list { declaration_list }\n"); 
  1226.      yyval.binary_node = NewNode(NODE_RULESET, NULL, yyvsp[-3].binary_node, yyvsp[-1].binary_node);
  1227.    ;
  1228.     break;}
  1229. case 25:
  1230.      TRACE1("-selector\n"); 
  1231.      yyval.binary_node = NewNode(NODE_SELECTOR_LIST, NULL, NULL, yyvsp[0].binary_node);
  1232.    ;
  1233.     break;}
  1234. case 26:
  1235.      css_node tmp;
  1236.      TRACE1("-selector_list , selector\n"); 
  1237.      tmp = NewNode(NODE_SELECTOR_LIST, NULL, NULL, yyvsp[0].binary_node);
  1238.      
  1239.      yyval.binary_node = yyvsp[-2].binary_node;
  1240.      if( yyval.binary_node == NULL )
  1241.        yyval.binary_node = tmp;
  1242.      else
  1243.        LeftAppendNode( yyval.binary_node, tmp );
  1244.    ;
  1245.     break;}
  1246. case 27:
  1247. {
  1248.     TRACE1("-simple_selector\n");
  1249.     yyval.binary_node = NewNode(NODE_SELECTOR, NULL, yyvsp[0].binary_node, NULL);
  1250. ;
  1251.     break;}
  1252. case 28:
  1253. {
  1254.     TRACE1("-simple_selector : pseudo_element\n");
  1255.     yyval.binary_node = NewNode(NODE_SELECTOR, NULL, yyvsp[-1].binary_node, yyvsp[0].binary_node);
  1256. ;
  1257.     break;}
  1258. case 29:
  1259. {
  1260.     TRACE1("-contextual_selector\n");
  1261.     yyval.binary_node = NewNode(NODE_SELECTOR, NULL, yyvsp[0].binary_node, NULL);
  1262. ;
  1263.     break;}
  1264. case 30:
  1265. {
  1266.     TRACE1("-contextual_selector : pseudo_element\n");
  1267.      yyval.binary_node = NewNode(NODE_SELECTOR, NULL, yyvsp[-1].binary_node, yyvsp[0].binary_node);
  1268. ;
  1269.     break;}
  1270. case 31:
  1271. {
  1272.     TRACE1("-contextual_selector_list simple_selector\n");
  1273.     yyval.binary_node = NewNode(NODE_SELECTOR_CONTEXTUAL, NULL, yyvsp[-1].binary_node, yyvsp[0].binary_node);
  1274. ;
  1275.     break;}
  1276. case 32:
  1277. {
  1278.      TRACE1("-simple_selector\n");
  1279.      yyval.binary_node = NewNode(NODE_SELECTOR_CONTEXTUAL, NULL, NULL, yyvsp[0].binary_node);
  1280.    ;
  1281.     break;}
  1282. case 33:
  1283. {
  1284.      TRACE1("-contextual_selector_list simple_selector\n");
  1285.      yyval.binary_node = NewNode(NODE_SELECTOR_CONTEXTUAL, NULL, yyvsp[-1].binary_node, yyvsp[0].binary_node);
  1286.    ;
  1287.     break;}
  1288. case 34:
  1289.      TRACE1("-element_name\n");
  1290.      yyval.binary_node = NewNode(NODE_SIMPLE_SELECTOR_NAME_ONLY, NULL, yyvsp[0].binary_node, NULL);
  1291.    ;
  1292.     break;}
  1293. case 35:
  1294. {
  1295.      TRACE1("-dot class\n");
  1296.      yyval.binary_node = NewNode(NODE_SIMPLE_SELECTOR_DOT_AND_CLASS, NULL, yyvsp[0].binary_node, NULL);
  1297.    ;
  1298.     break;}
  1299. case 36:
  1300. {
  1301.      TRACE1("-id\n");
  1302.      yyval.binary_node = NewNode(NODE_SIMPLE_SELECTOR_ID_SELECTOR, NULL, yyvsp[0].binary_node, NULL);
  1303.    ;
  1304.     break;}
  1305. case 37:
  1306. {
  1307.      TRACE1("-element dot class\n");
  1308.      yyval.binary_node = NewNode(NODE_SIMPLE_SELECTOR_NAME_AND_CLASS, NULL, yyvsp[-2].binary_node, yyvsp[0].binary_node);
  1309.    ;
  1310.     break;}
  1311. case 38:
  1312. {
  1313.      TRACE1("-element pseudo_class\n");
  1314.      yyval.binary_node = NewNode(NODE_SIMPLE_SELECTOR_NAME_PSEUDO_CLASS, NULL, yyvsp[-1].binary_node, yyvsp[0].binary_node);
  1315.    ;
  1316.     break;}
  1317. case 39:
  1318. {
  1319.      TRACE2("-element_name '%s' dot class pseudo_class\n", yyvsp[-3].binary_node->string);
  1320.      yyvsp[-3].binary_node->node_id = NODE_SIMPLE_SELECTOR_NAME_CLASS_PSEUDO_CLASS;
  1321.      yyvsp[-3].binary_node->left = yyvsp[-1].binary_node;
  1322.      yyvsp[-3].binary_node->right = yyvsp[0].binary_node;
  1323.      yyval.binary_node = yyvsp[-3].binary_node;
  1324.    ;
  1325.     break;}
  1326. case 40:
  1327. {
  1328.      TRACE1("-dot class pseudo_class\n");
  1329.      yyval.binary_node = NewNode(NODE_SIMPLE_SELECTOR_NAME_CLASS_PSEUDO_CLASS, "A", yyvsp[-1].binary_node, yyvsp[0].binary_node);
  1330.    ;
  1331.     break;}
  1332. case 41:
  1333. {
  1334.      css_node tmp;
  1335.      TRACE1("solitary pseudo_class\n");
  1336.      /* See CSS1 spec of 17 December 1996 section 2.1 Anchor pseudo-classes */
  1337.      tmp = NewNode(NODE_ELEMENT_NAME, "A", NULL, NULL);
  1338.      yyval.binary_node = NewNode(NODE_SIMPLE_SELECTOR_NAME_PSEUDO_CLASS, NULL, tmp, yyvsp[0].binary_node);
  1339.    ;
  1340.     break;}
  1341. case 42:
  1342. {
  1343.      yyval.binary_node = NewNode(NODE_WILD, NULL, NULL, NULL);
  1344.    ;
  1345.     break;}
  1346. case 43:
  1347.      TRACE2("-IDENT '%s' to element_name\n", css_text); 
  1348.      yyval.binary_node = NewNode(NODE_ELEMENT_NAME, css_text, NULL, NULL);
  1349.    ;
  1350.     break;}
  1351. case 44:
  1352. {
  1353.         TRACE2("-IDENT '%s' to class\n", css_text);
  1354.         yyval.binary_node = NewNode(NODE_CLASS, css_text, NULL, NULL);
  1355.       ;
  1356.     break;}
  1357. case 45:
  1358. {
  1359.         TRACE2("-IDENT '%s' to id\n", css_text);
  1360.         yyval.binary_node = NewNode(NODE_ID_SELECTOR, css_text, NULL, NULL);
  1361.       ;
  1362.     break;}
  1363. case 46:
  1364. {
  1365.      yyval.binary_node = NewNode(NODE_LINK_PSCLASS, css_link, NULL, NULL);
  1366.    ;
  1367.     break;}
  1368. case 47:
  1369. {
  1370.      yyval.binary_node = NewNode(NODE_VISITED_PSCLASS, css_visited, NULL, NULL);
  1371.    ;
  1372.     break;}
  1373. case 48:
  1374. {
  1375.      yyval.binary_node = NewNode(NODE_ACTIVE_PSCLASS, css_active, NULL, NULL);
  1376.    ;
  1377.     break;}
  1378. case 49:
  1379. {
  1380.      yyval.binary_node = NewNode(NODE_LINK_PSCLASS, css_link, NULL, NULL);
  1381.    ;
  1382.     break;}
  1383. case 50:
  1384. {
  1385.      yyval.binary_node = NewNode(NODE_VISITED_PSCLASS, css_visited, NULL, NULL);
  1386.    ;
  1387.     break;}
  1388. case 51:
  1389. {
  1390.      yyval.binary_node = NewNode(NODE_ACTIVE_PSCLASS, css_active, NULL, NULL);
  1391.    ;
  1392.     break;}
  1393. case 52:
  1394.      TRACE2("-IDENT '%s' to pseudo_element\n", css_text);
  1395.      yyval.binary_node = NewNode(NODE_PSEUDO_ELEMENT, "first-Line", NULL, NULL);
  1396.    ;
  1397.     break;}
  1398. case 53:
  1399.      TRACE2("-IDENT '%s' to pseudo_element\n", css_text);
  1400.      yyval.binary_node = NewNode(NODE_PSEUDO_ELEMENT, "first-Letter", NULL, NULL);
  1401.    ;
  1402.     break;}
  1403. case 54:
  1404. {
  1405.      TRACE1("-declaration\n");
  1406.      yyval.binary_node = yyvsp[0].binary_node;
  1407.    ;
  1408.     break;}
  1409. case 55:
  1410. {
  1411.      /* to keep the order, append the new node to the end. */
  1412.      TRACE1("-declaration_list ';' declaration\n");
  1413.      yyval.binary_node = yyvsp[-2].binary_node;
  1414.      if (NULL == yyval.binary_node)
  1415.        yyval.binary_node = yyvsp[0].binary_node;
  1416.      else
  1417.        LeftAppendNode(yyval.binary_node, yyvsp[0].binary_node);
  1418.    ;
  1419.     break;}
  1420. case 56:
  1421.      TRACE1("-empty declaration\n");
  1422.      yyval.binary_node = NewNode(NODE_DECLARATION_LIST, NULL, NULL, NULL);
  1423.    ;
  1424.     break;}
  1425. case 57:
  1426. {
  1427.      css_node dcl;
  1428.      TRACE1("-property : expr\n");
  1429.      dcl = NewNode(NODE_DECLARATION_PROPERTY_EXPR, NULL, yyvsp[-3].binary_node, yyvsp[-1].binary_node);
  1430.      yyval.binary_node = NewNode(NODE_DECLARATION_LIST, NULL, NULL, dcl);
  1431.    ;
  1432.     break;}
  1433. case 58:
  1434. {
  1435.      css_node expr, dcl;
  1436.      expr = NewNode(NODE_EXPR, NULL, NULL, yyvsp[-1].binary_node);
  1437.      dcl = NewNode(NODE_DECLARATION_PROPERTY_EXPR, NULL, yyvsp[-3].binary_node, expr);
  1438.      yyval.binary_node = NewNode(NODE_DECLARATION_LIST, NULL, NULL, dcl);
  1439.     ;
  1440.     break;}
  1441. case 59:
  1442. {
  1443.      /* The priority notation is ignored by the translator
  1444.       * so we conveniently ignore it here, too.
  1445.       */
  1446.      TRACE1("-background property : background_values_list\n");
  1447.      yyval.binary_node = AssembleBackground();
  1448.    ;
  1449.     break;}
  1450. case 60:
  1451. {
  1452.      TRACE1("-font property : font_values_list prio\n");
  1453.      /* The priority notation is ignored by the translator
  1454.       * so we conveniently ignore it here, too.
  1455.       */
  1456.      yyval.binary_node = AssembleFont();
  1457.    ;
  1458.     break;}
  1459. case 61:
  1460. {
  1461.      yyval.binary_node = AssembleListStyle();
  1462.    ;
  1463.     break;}
  1464. case 62:
  1465. {
  1466.      yyval.binary_node = AssembleBorder();
  1467.     ;
  1468.     break;}
  1469. case 63:
  1470. { /* nothing */ ;
  1471.     break;}
  1472. case 65:
  1473. {                       /* !important */
  1474.      TRACE1("-IMPORTANT_SYM\n");
  1475.      yyval.binary_node = NULL;
  1476.    ;
  1477.     break;}
  1478. case 66:
  1479. {
  1480.      TRACE1("-term\n");
  1481.      yyval.binary_node = NewNode(NODE_EXPR, NULL, NULL, yyvsp[0].binary_node);
  1482.    ;
  1483.     break;}
  1484. case 67:
  1485. {
  1486.      TRACE1("-expr op term\n");
  1487.  
  1488.      yyval.binary_node = yyvsp[-2].binary_node;
  1489.      /* put the new term at the end */
  1490.      yyvsp[-1].binary_node->right = yyvsp[0].binary_node;
  1491.  
  1492.      if (yyval.binary_node == NULL)
  1493.        yyval.binary_node = yyvsp[-1].binary_node;
  1494.      else
  1495.        LeftAppendNode( yyval.binary_node, yyvsp[-1].binary_node ); 
  1496.    ;
  1497.     break;}
  1498. case 74:
  1499. {
  1500.      TRACE1("-unary_operator signed_const to term\n"); 
  1501.      yyval.binary_node = yyvsp[-1].binary_node;
  1502.      yyval.binary_node->left = yyvsp[0].binary_node;
  1503.    ;
  1504.     break;}
  1505. case 75:
  1506. {
  1507.      yyval.binary_node = NewNode(NODE_NUMBER, css_text, NULL, NULL);
  1508.    ;
  1509.     break;}
  1510. case 77:
  1511. {
  1512.      yyval.binary_node = yyvsp[-1].binary_node;
  1513.      yyval.binary_node->left = yyvsp[0].binary_node;
  1514.    ;
  1515.     break;}
  1516. case 78:
  1517. {
  1518.      yyval.binary_node = NewNode(NODE_PERCENTAGE, css_text, NULL, NULL);
  1519.    ;
  1520.     break;}
  1521. case 79:
  1522. {
  1523.      yyval.binary_node = NewNode(NODE_LENGTH, css_text, NULL, NULL);
  1524.    ;
  1525.     break;}
  1526. case 80:
  1527. {
  1528.      yyval.binary_node = NewNode(NODE_EMS, css_text, NULL, NULL);
  1529.    ;
  1530.     break;}
  1531. case 81:
  1532. {
  1533.      yyval.binary_node = NewNode(NODE_EMS, css_text, NULL, NULL);
  1534.    ;
  1535.     break;}
  1536. case 82:
  1537. {
  1538.      yyval.binary_node = NewNode(NODE_STRING, css_text, NULL, NULL);
  1539.    ;
  1540.     break;}
  1541. case 83:
  1542.      TRACE2("-IDENT '%s' to unsigned_symbol\n", css_text);
  1543.      yyval.binary_node = NewNode(NODE_IDENT, css_text, NULL, NULL);
  1544.    ;
  1545.     break;}
  1546. case 84:
  1547. {
  1548.      yyval.binary_node = NewNode(NODE_URL, css_text, NULL, NULL);
  1549.    ;
  1550.     break;}
  1551. case 85:
  1552. {
  1553.      yyval.binary_node = NewNode(NODE_HEXCOLOR, css_text, NULL, NULL);
  1554.    ;
  1555.     break;}
  1556. case 86:
  1557. {
  1558.      yyval.binary_node = NewNode(NODE_RGB, css_text, NULL, NULL);
  1559.    ;
  1560.     break;}
  1561. case 94:
  1562. {
  1563.         yyval.binary_node = NewDeclarationNode(NODE_URL, css_text, bg_image);
  1564.         AddBackground(BackgroundImage, yyval.binary_node);
  1565.       ;
  1566.     break;}
  1567. case 95:
  1568. {
  1569.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, bg_image);
  1570.         AddBackground(BackgroundImage, yyval.binary_node);
  1571.       ;
  1572.     break;}
  1573. case 96:
  1574. {
  1575.         yyval.binary_node = NewComponentNode(yyvsp[0].binary_node, bg_color);
  1576.         AddBackground(BackgroundColor, yyval.binary_node);
  1577.       ;
  1578.     break;}
  1579. case 97:
  1580. {
  1581.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, bg_color);
  1582.         AddBackground(BackgroundColor, yyval.binary_node);
  1583.       ;
  1584.     break;}
  1585. case 98:
  1586. {
  1587.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, bg_color);
  1588.         AddBackground(BackgroundColor, yyval.binary_node);
  1589.       ;
  1590.     break;}
  1591. case 99:
  1592. {
  1593.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, "background-repeat");
  1594.         AddBackground(BackgroundRepeat, yyval.binary_node);
  1595.       ;
  1596.     break;}
  1597. case 100:
  1598. {
  1599.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, "background-attachment");
  1600.         AddBackground(BackgroundAttachment, yyval.binary_node);
  1601.       ;
  1602.     break;}
  1603. case 101:
  1604. {
  1605.         css_node property, declaration;
  1606.         property = NewNode(NODE_PROPERTY, bg_position, NULL, NULL);
  1607.         declaration = NewNode(NODE_DECLARATION_PROPERTY_EXPR, NULL,
  1608.                               property, yyvsp[0].binary_node);
  1609.         AddBackground(BackgroundPosition, declaration);
  1610.       ;
  1611.     break;}
  1612. case 102:
  1613. {
  1614.         yyval.binary_node = NewNode(NODE_EXPR, NULL, NULL, yyvsp[0].binary_node);
  1615.       ;
  1616.     break;}
  1617. case 103:
  1618. {
  1619.         css_node operator;
  1620.         yyval.binary_node = NewNode(NODE_EXPR, NULL, NULL, yyvsp[-1].binary_node);
  1621.         operator = NewNode(NODE_EMPTY_OP, NULL, NULL, yyvsp[0].binary_node);
  1622.         if (yyval.binary_node == NULL)
  1623.             yyval.binary_node = operator;
  1624.         else
  1625.             LeftAppendNode(yyval.binary_node, operator);
  1626.       ;
  1627.     break;}
  1628. case 104:
  1629. {
  1630.         yyval.binary_node = NewNode(NODE_EXPR, NULL, NULL, yyvsp[0].binary_node);
  1631.       ;
  1632.     break;}
  1633. case 105:
  1634. {
  1635.         css_node operator;
  1636.         yyval.binary_node = yyvsp[-1].binary_node;
  1637.         operator = NewNode(NODE_EMPTY_OP, NULL, NULL, yyvsp[0].binary_node);
  1638.         if (yyval.binary_node == NULL)
  1639.             yyval.binary_node = operator;
  1640.         else
  1641.             LeftAppendNode(yyval.binary_node, operator);
  1642.       ;
  1643.     break;}
  1644. case 106:
  1645. {
  1646.         yyval.binary_node = NewNode(NODE_IDENT, css_text, NULL, NULL);
  1647.       ;
  1648.     break;}
  1649. case 107:
  1650. {
  1651.         css_node tmp;
  1652.         tmp = NewComponentNode(yyvsp[-1].binary_node, font_size);
  1653.         AddFont(FontSize, tmp);
  1654.         AddFont(FontFamily, yyvsp[0].binary_node);
  1655.         yyval.binary_node = NULL;
  1656.       ;
  1657.     break;}
  1658. case 108:
  1659. {
  1660.         css_node tmp;
  1661.         tmp = NewComponentNode(yyvsp[-3].binary_node, font_size);
  1662.         AddFont(FontSize, tmp);
  1663.         tmp = NewComponentNode(yyvsp[-1].binary_node, line_height);
  1664.         AddFont(FontLeading, tmp);
  1665.         AddFont(FontFamily, yyvsp[0].binary_node);
  1666.         yyval.binary_node = NULL;
  1667.       ;
  1668.     break;}
  1669. case 109:
  1670.      TRACE1("-empty operator\n");
  1671.      yyval.binary_node = NewNode(NODE_EMPTY_OP, NULL, NULL, NULL);
  1672.    ;
  1673.     break;}
  1674. case 110:
  1675.      TRACE1("-operator : ','\n"); 
  1676.      yyval.binary_node = NewNode(NODE_EXPR_OP, css_text, NULL, NULL);
  1677.    ;
  1678.     break;}
  1679. case 111:
  1680. {
  1681.      css_node property;
  1682.      TRACE1("-font_family_expr to font_family_value\n");
  1683.      property = NewNode(NODE_PROPERTY, font_family, NULL, NULL);
  1684.      yyval.binary_node = NewNode(NODE_DECLARATION_PROPERTY_EXPR, NULL, property, yyvsp[0].binary_node);
  1685.     ;
  1686.     break;}
  1687. case 112:
  1688. {
  1689.      TRACE1("-unsigned_symbol\n");
  1690.      yyval.binary_node = NewNode(NODE_EXPR, NULL, NULL, yyvsp[0].binary_node);
  1691.    ;
  1692.     break;}
  1693. case 113:
  1694. {
  1695.      TRACE1("-font_family_value font_family_op unsigned_symbol\n");
  1696.  
  1697.      yyval.binary_node = yyvsp[-2].binary_node;
  1698.      /* put the new term at the end */
  1699.      yyvsp[-1].binary_node->right = yyvsp[0].binary_node;
  1700.  
  1701.      if (yyval.binary_node == NULL)
  1702.        yyval.binary_node = yyvsp[-1].binary_node;
  1703.      else
  1704.        LeftAppendNode( yyval.binary_node, yyvsp[-1].binary_node ); 
  1705.    ;
  1706.     break;}
  1707. case 114:
  1708. { /* empty */
  1709.         yyval.binary_node = NULL;
  1710.       ;
  1711.     break;}
  1712. case 115:
  1713. {
  1714.         yyval.binary_node = NULL;
  1715.       ;
  1716.     break;}
  1717. case 116:
  1718. {
  1719.     TRACE2("-FONT_STYLE '%s' to font_optional_value\n", css_text);
  1720.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, font_style);
  1721.         AddFont(FontStyle, yyval.binary_node);
  1722.       ;
  1723.     break;}
  1724. case 117:
  1725. {
  1726.     TRACE2("-FONT_VARIANT '%s' to font_optional_value\n", css_text);
  1727.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, font_variant);
  1728.         AddFont(FontVariant, yyval.binary_node);
  1729.       ;
  1730.     break;}
  1731. case 118:
  1732. {
  1733.     TRACE2("-FONT_WEIGHT '%s' to font_optional_value\n", css_text);
  1734.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, font_weight);
  1735.         AddFont(FontWeight, yyval.binary_node);
  1736.       ;
  1737.     break;}
  1738. case 119:
  1739. {
  1740.         AddFont(FontNormal, NULL);
  1741.       ;
  1742.     break;}
  1743. case 121:
  1744. {
  1745.         yyval.binary_node = NewNode(NODE_IDENT, css_text, NULL, NULL);
  1746.       ;
  1747.     break;}
  1748. case 122:
  1749. {
  1750.         /* just drop the '+' on the floor */
  1751.         yyval.binary_node = yyvsp[0].binary_node;
  1752.       ;
  1753.     break;}
  1754. case 125:
  1755. {
  1756.         /* The only valid identifier is the word "normal".
  1757.          * There's an idea that a normal leading value is font-specific,
  1758.          * so the identifier is passed upwards.
  1759.          */
  1760.     yyval.binary_node = NewNode(NODE_IDENT, css_text, NULL, NULL);
  1761.       ;
  1762.     break;}
  1763. case 128:
  1764. {
  1765.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, list_style_type);
  1766.         AddListStyle(ListStyleMarker, yyval.binary_node);
  1767.         yyval.binary_node = NULL;
  1768.       ;
  1769.     break;}
  1770. case 129:
  1771. {
  1772.         AddListStyle(ListStyleNone, NULL);
  1773.         yyval.binary_node = NULL;
  1774.       ;
  1775.     break;}
  1776. case 130:
  1777. {
  1778.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, list_style_position);
  1779.         AddListStyle(ListStylePosition, yyval.binary_node);
  1780.         yyval.binary_node = NULL;
  1781.       ;
  1782.     break;}
  1783. case 131:
  1784. {
  1785.         yyval.binary_node = NewComponentNode(yyvsp[0].binary_node, list_style_image);
  1786.         AddListStyle(ListStyleImage, yyval.binary_node);
  1787.         yyval.binary_node = NULL;
  1788.       ;
  1789.     break;}
  1790. case 134:
  1791. {
  1792.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, border_style);
  1793.         AddBorder(BorderStyle, yyval.binary_node);
  1794.         yyval.binary_node = NULL;
  1795.       ;
  1796.     break;}
  1797. case 135:
  1798. {
  1799.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, border_width);
  1800.         AddBorder(BorderWidth, yyval.binary_node);
  1801.         yyval.binary_node = NULL;
  1802.       ;
  1803.     break;}
  1804. case 136:
  1805. {
  1806.         yyval.binary_node = NewComponentNode(yyvsp[0].binary_node, border_width);
  1807.         AddBorder(BorderWidth, yyval.binary_node);
  1808.         yyval.binary_node = NULL;
  1809.       ;
  1810.     break;}
  1811. case 137:
  1812. {
  1813.         yyval.binary_node = NewComponentNode(yyvsp[0].binary_node, border_color);
  1814.         AddBorder(BorderColor, yyval.binary_node);
  1815.         yyval.binary_node = NULL;
  1816.       ;
  1817.     break;}
  1818. case 138:
  1819. {
  1820.         yyval.binary_node = NewDeclarationNode(NODE_IDENT, css_text, border_color);
  1821.         AddBorder(BorderColor, yyval.binary_node);
  1822.         yyval.binary_node = NULL;
  1823.       ;
  1824.     break;}
  1825. }
  1826.    /* the action file gets copied in in place of this dollarsign */
  1827.  
  1828.  
  1829.   yyvsp -= yylen;
  1830.   yyssp -= yylen;
  1831. #ifdef YYLSP_NEEDED
  1832.   yylsp -= yylen;
  1833. #endif
  1834.  
  1835. #if YYDEBUG != 0
  1836.   if (yydebug)
  1837.     {
  1838.       short *ssp1 = yyss - 1;
  1839.       fprintf (stderr, "state stack now");
  1840.       while (ssp1 != yyssp)
  1841.     fprintf (stderr, " %d", *++ssp1);
  1842.       fprintf (stderr, "\n");
  1843.     }
  1844. #endif
  1845.  
  1846.   *++yyvsp = yyval;
  1847.  
  1848. #ifdef YYLSP_NEEDED
  1849.   yylsp++;
  1850.   if (yylen == 0)
  1851.     {
  1852.       yylsp->first_line = yylloc.first_line;
  1853.       yylsp->first_column = yylloc.first_column;
  1854.       yylsp->last_line = (yylsp-1)->last_line;
  1855.       yylsp->last_column = (yylsp-1)->last_column;
  1856.       yylsp->text = 0;
  1857.     }
  1858.   else
  1859.     {
  1860.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1861.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1862.     }
  1863. #endif
  1864.  
  1865.   /* Now "shift" the result of the reduction.
  1866.      Determine what state that goes to,
  1867.      based on the state we popped back to
  1868.      and the rule number reduced by.  */
  1869.  
  1870.   yyn = yyr1[yyn];
  1871.  
  1872.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1873.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1874.     yystate = yytable[yystate];
  1875.   else
  1876.     yystate = yydefgoto[yyn - YYNTBASE];
  1877.  
  1878.   goto yynewstate;
  1879.  
  1880. yyerrlab:   /* here on detecting error */
  1881.  
  1882.   if (! yyerrstatus)
  1883.     /* If not already recovering from an error, report this error.  */
  1884.     {
  1885.       ++yynerrs;
  1886.  
  1887. #ifdef YYERROR_VERBOSE
  1888.       yyn = yypact[yystate];
  1889.  
  1890.       if (yyn > YYFLAG && yyn < YYLAST)
  1891.     {
  1892.       int size = 0;
  1893.       char *msg;
  1894.       int x, count;
  1895.  
  1896.       count = 0;
  1897.       /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
  1898.       for (x = (yyn < 0 ? -yyn : 0);
  1899.            x < (sizeof(yytname) / sizeof(char *)); x++)
  1900.         if (yycheck[x + yyn] == x)
  1901.           size += strlen(yytname[x]) + 15, count++;
  1902.       msg = (char *) malloc(size + 15);
  1903.       if (msg != 0)
  1904.         {
  1905.           strcpy(msg, "parse error");
  1906.  
  1907.           if (count < 5)
  1908.         {
  1909.           count = 0;
  1910.           for (x = (yyn < 0 ? -yyn : 0);
  1911.                x < (sizeof(yytname) / sizeof(char *)); x++)
  1912.             if (yycheck[x + yyn] == x)
  1913.               {
  1914.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1915.             strcat(msg, yytname[x]);
  1916.             strcat(msg, "'");
  1917.             count++;
  1918.               }
  1919.         }
  1920.           yyerror(msg);
  1921.           free(msg);
  1922.         }
  1923.       else
  1924.         yyerror ("parse error; also virtual memory exceeded");
  1925.     }
  1926.       else
  1927. #endif /* YYERROR_VERBOSE */
  1928.     yyerror("parse error");
  1929.     }
  1930.  
  1931.   goto yyerrlab1;
  1932. yyerrlab1:   /* here on error raised explicitly by an action */
  1933.  
  1934.   if (yyerrstatus == 3)
  1935.     {
  1936.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1937.  
  1938.       /* return failure if at end of input */
  1939.       if (yychar == YYEOF)
  1940.     YYABORT;
  1941.  
  1942. #if YYDEBUG != 0
  1943.       if (yydebug)
  1944.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1945. #endif
  1946.  
  1947.       yychar = YYEMPTY;
  1948.     }
  1949.  
  1950.   /* Else will try to reuse lookahead token
  1951.      after shifting the error token.  */
  1952.  
  1953.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1954.  
  1955.   goto yyerrhandle;
  1956.  
  1957. yyerrdefault:  /* current state does not do anything special for the error token. */
  1958.  
  1959. #if 0
  1960.   /* This is wrong; only states that explicitly want error tokens
  1961.      should shift them.  */
  1962.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1963.   if (yyn) goto yydefault;
  1964. #endif
  1965.  
  1966. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1967.  
  1968.   if (yyssp == yyss) YYABORT;
  1969.   yyvsp--;
  1970.   yystate = *--yyssp;
  1971. #ifdef YYLSP_NEEDED
  1972.   yylsp--;
  1973. #endif
  1974.  
  1975. #if YYDEBUG != 0
  1976.   if (yydebug)
  1977.     {
  1978.       short *ssp1 = yyss - 1;
  1979.       fprintf (stderr, "Error: state stack now");
  1980.       while (ssp1 != yyssp)
  1981.     fprintf (stderr, " %d", *++ssp1);
  1982.       fprintf (stderr, "\n");
  1983.     }
  1984. #endif
  1985.  
  1986. yyerrhandle:
  1987.  
  1988.   yyn = yypact[yystate];
  1989.   if (yyn == YYFLAG)
  1990.     goto yyerrdefault;
  1991.  
  1992.   yyn += YYTERROR;
  1993.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1994.     goto yyerrdefault;
  1995.  
  1996.   yyn = yytable[yyn];
  1997.   if (yyn < 0)
  1998.     {
  1999.       if (yyn == YYFLAG)
  2000.     goto yyerrpop;
  2001.       yyn = -yyn;
  2002.       goto yyreduce;
  2003.     }
  2004.   else if (yyn == 0)
  2005.     goto yyerrpop;
  2006.  
  2007.   if (yyn == YYFINAL)
  2008.     YYACCEPT;
  2009.  
  2010. #if YYDEBUG != 0
  2011.   if (yydebug)
  2012.     fprintf(stderr, "Shifting error token, ");
  2013. #endif
  2014.  
  2015.   *++yyvsp = yylval;
  2016. #ifdef YYLSP_NEEDED
  2017.   *++yylsp = yylloc;
  2018. #endif
  2019.  
  2020.   yystate = yyn;
  2021.   goto yynewstate;
  2022. }
  2023.  
  2024.  
  2025. #include "xp_mem.h"
  2026. #include "xpassert.h"
  2027.  
  2028. /* Memory allocated here will be freed by css_FreeNode in csstojs.c */
  2029. static css_node NewNode(int node_id, char *ss, css_node left, css_node right)
  2030. {
  2031.     register css_node pp;
  2032.  
  2033.     if ((pp = XP_NEW(css_nodeRecord)) == NULL)
  2034.         return NULL;
  2035.  
  2036.     pp->node_id = node_id;
  2037.     pp->string = NULL;
  2038.     if (ss) {
  2039.         if ((pp->string = (char *) XP_ALLOC(strlen(ss) + 1)) != NULL)
  2040.             (void) strcpy(pp->string, ss);
  2041.     }
  2042.     pp->left   = left;
  2043.     pp->right  = right;
  2044.     return pp;
  2045. }
  2046.  
  2047.  
  2048. /* Append new_node to the leftmost leaf of head */
  2049. static void LeftAppendNode(css_node head, css_node new_node)
  2050. {
  2051.     if (head == NULL)
  2052.         return;
  2053.     
  2054.     while (head->left != NULL)
  2055.         head = head->left;
  2056.     head->left = new_node;         
  2057. }
  2058.  
  2059.  
  2060. static css_node NewDeclarationNode(int node_id, char *ss, char *prop)
  2061. {
  2062.     css_node value, expression, property;
  2063.     value = NewNode(node_id, ss, NULL, NULL);
  2064.     expression = NewNode(NODE_EXPR, NULL, NULL, value);
  2065.     property = NewNode(NODE_PROPERTY, prop, NULL, NULL);
  2066.     return NewNode(NODE_DECLARATION_PROPERTY_EXPR, NULL, property, expression);
  2067. }
  2068.  
  2069.  
  2070. static css_node NewComponentNode(css_node value, char *prop)
  2071. {
  2072.     css_node expression, property;
  2073.     expression = NewNode(NODE_EXPR, NULL, NULL, value);
  2074.     property = NewNode(NODE_PROPERTY, prop, NULL, NULL);
  2075.     return NewNode(NODE_DECLARATION_PROPERTY_EXPR, NULL, property, expression);
  2076. }
  2077.  
  2078.  
  2079. static void ClearFont(void)
  2080. {
  2081.     font.style = font.variant = font.weight = NULL;
  2082.     font.size = font.leading = font.family = NULL;
  2083.     font.normal_count = font.parse_error = 0;
  2084. }
  2085.  
  2086.  
  2087. static void AddFont(int node_type, css_node node)
  2088. {
  2089.     if (FontStyle == node_type && (! font.style))
  2090.         font.style = node;
  2091.     else if (FontVariant == node_type && (! font.variant))
  2092.         font.variant = node;
  2093.     else if (FontWeight == node_type && (!  font.weight))
  2094.         font.weight = node;
  2095.     else if (FontNormal == node_type)
  2096.         font.normal_count++;
  2097.     else if (FontSize == node_type && (! font.size))
  2098.         font.size = node;
  2099.     else if (FontLeading == node_type && (! font.leading))
  2100.         font.leading = node;
  2101.     else if (FontFamily == node_type && (! font.family))
  2102.         font.family = node;
  2103.     else {
  2104.         font.parse_error++;
  2105.         if (node) css_FreeNode(node);
  2106.     }
  2107. }
  2108.  
  2109.  
  2110. static css_node AssembleFont(void)
  2111. {
  2112.     css_node head, element;
  2113.     int count;
  2114.  
  2115.     count = 0;
  2116.     if (font.style)       count++;
  2117.     if (font.variant)     count++;
  2118.     if (font.weight)      count++;
  2119.     if (font.normal_count > (3 - count))
  2120.         font.parse_error++;
  2121.  
  2122.     if (font.parse_error) {
  2123.         if (font.style)    css_FreeNode(font.style);
  2124.         if (font.variant)  css_FreeNode(font.variant);
  2125.         if (font.weight)   css_FreeNode(font.weight);
  2126.         if (font.size)     css_FreeNode(font.size);
  2127.         if (font.leading)  css_FreeNode(font.leading);
  2128.         if (font.family)   css_FreeNode(font.family);
  2129.         ClearFont();
  2130.         return NULL;
  2131.     }
  2132.  
  2133.     if (! font.style)
  2134.         font.style = NewDeclarationNode(NODE_IDENT, css_normal, font_style);
  2135.     if (! font.variant)
  2136.         font.variant = NewDeclarationNode(NODE_IDENT, css_normal, font_variant);
  2137.     if (! font.weight)
  2138.         font.weight = NewDeclarationNode(NODE_IDENT, css_normal, font_weight);
  2139.     if (! font.leading)
  2140.         font.leading = NewDeclarationNode(NODE_IDENT, css_normal, line_height);
  2141.  
  2142.     head = NewNode(NODE_DECLARATION_LIST, NULL, NULL, font.style);
  2143.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, font.variant);
  2144.     LeftAppendNode(head, element);
  2145.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, font.weight);
  2146.     LeftAppendNode(head, element);
  2147.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, font.size);
  2148.     LeftAppendNode(head, element);
  2149.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, font.leading);
  2150.     LeftAppendNode(head, element);
  2151.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, font.family);
  2152.     LeftAppendNode(head, element);
  2153.  
  2154.     ClearFont();
  2155.     return head;
  2156. }
  2157.  
  2158.  
  2159. static void ClearBackground(void)
  2160. {
  2161.     bg.color = bg.image = bg.repeat = NULL;
  2162.     bg.attachment = bg.position = NULL;
  2163.     bg.parse_error = 0;
  2164. }
  2165.  
  2166.  
  2167. static void AddBackground(int node_type, css_node node)
  2168. {
  2169.     if (BackgroundColor == node_type && (! bg.color))
  2170.         bg.color = node;
  2171.     else if (BackgroundImage == node_type && (! bg.image))
  2172.         bg.image = node;
  2173.     else if (BackgroundRepeat == node_type && (!  bg.repeat))
  2174.         bg.repeat = node;
  2175.     else if (BackgroundAttachment == node_type && (! bg.attachment))
  2176.         bg.attachment = node;
  2177.     else if (BackgroundPosition == node_type && (! bg.position))
  2178.         bg.position = node;
  2179.     else {
  2180.         bg.parse_error++;
  2181.         css_FreeNode(node);
  2182.     }
  2183. }
  2184.  
  2185.  
  2186. static css_node AssembleBackground(void)
  2187. {
  2188.     css_node head, element;
  2189.  
  2190.     if (bg.parse_error) {
  2191.         if (bg.color)
  2192.             css_FreeNode(bg.color);
  2193.         if (bg.image)
  2194.             css_FreeNode(bg.image);
  2195.         if (bg.repeat)
  2196.             css_FreeNode(bg.repeat);
  2197.         if (bg.attachment)
  2198.             css_FreeNode(bg.attachment);
  2199.         if (bg.position)
  2200.             css_FreeNode(bg.position);
  2201.         ClearBackground();
  2202.         return NULL;
  2203.     }
  2204.  
  2205.     if (! bg.color)
  2206.         bg.color = NewDeclarationNode(NODE_IDENT, css_transparent, bg_color);
  2207.     if (! bg.image)
  2208.         bg.image = NewDeclarationNode(NODE_IDENT, css_none, bg_image);
  2209.     if (! bg.repeat)
  2210.         bg.repeat = NewDeclarationNode(NODE_IDENT, css_repeat, bg_repeat);
  2211.     if (! bg.attachment)
  2212.         bg.attachment = NewDeclarationNode(NODE_IDENT, css_scroll, bg_attachment);
  2213.     if (! bg.position)
  2214.         bg.position = NewDeclarationNode(NODE_PERCENTAGE, css_origin,
  2215.                                          bg_position);
  2216.  
  2217.     head = NewNode(NODE_DECLARATION_LIST, NULL, NULL, bg.color);
  2218.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, bg.image);
  2219.     LeftAppendNode(head, element);
  2220.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, bg.repeat);
  2221.     LeftAppendNode(head, element);
  2222.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, bg.attachment);
  2223.     LeftAppendNode(head, element);
  2224.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, bg.position);
  2225.     LeftAppendNode(head, element);
  2226.  
  2227.     ClearBackground();
  2228.     return head;
  2229. }                                      
  2230.         
  2231.  
  2232. static void ClearListStyle(void)
  2233. {
  2234.     ls.marker = ls.image = ls.position = NULL;
  2235.     ls.none_count = ls.parse_error = 0;
  2236. }
  2237.  
  2238. static void AddListStyle(int node_type, css_node node)
  2239. {
  2240.     if (ListStyleMarker == node_type && (! ls.marker))
  2241.         ls.marker = node;
  2242.     else if (ListStyleImage == node_type && (! ls.image))
  2243.         ls.image = node;
  2244.     else if (ListStylePosition == node_type && (! ls.position))
  2245.         ls.position = node;
  2246.     else if (ListStyleNone == node_type)
  2247.         ls.none_count++;
  2248.     else {
  2249.         ls.parse_error++;
  2250.         if (node) css_FreeNode(node);
  2251.     }
  2252. }
  2253.  
  2254. static css_node AssembleListStyle(void)
  2255. {
  2256.     css_node head, element;
  2257.     int count;
  2258.     char * marker_value;
  2259.  
  2260.     count = 0;
  2261.     if (ls.marker)    count++;
  2262.     if (ls.image)    count++;
  2263.     if (ls.none_count > (2 - count))
  2264.         ls.parse_error++;
  2265.  
  2266.     if (ls.parse_error) {
  2267.         if (ls.marker)    css_FreeNode(ls.marker);
  2268.         if (ls.image)    css_FreeNode(ls.image);
  2269.         if (ls.position)    css_FreeNode(ls.position);
  2270.         ClearListStyle();
  2271.         return NULL;
  2272.     }
  2273.  
  2274.     if (! ls.marker) {
  2275.         /* list-style: none
  2276.          * could mean marker or image.  It should set the marker;
  2277.          * the image will default to none.
  2278.          */
  2279.         marker_value = ls.none_count ? css_none : css_disc;
  2280.         ls.marker = NewDeclarationNode(NODE_IDENT, marker_value,
  2281.                                        list_style_type);
  2282.     }
  2283.     if (! ls.image)
  2284.         ls.image = NewDeclarationNode(NODE_IDENT, css_none, list_style_image);
  2285.     if (! ls.position)
  2286.         ls.position = NewDeclarationNode(NODE_IDENT, css_outside,
  2287.                                          list_style_position);
  2288.  
  2289.     head = NewNode(NODE_DECLARATION_LIST, NULL, NULL, ls.marker);
  2290.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, ls.image);
  2291.     LeftAppendNode(head, element);
  2292.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, ls.position);
  2293.     LeftAppendNode(head, element);
  2294.  
  2295.     ClearListStyle();
  2296.     return head;
  2297. }
  2298.  
  2299.  
  2300. static void ClearBorder(void)
  2301. {
  2302.     border.width = border.style = border.color = (css_node) NULL;
  2303.     border.parse_error = 0;
  2304. }
  2305.  
  2306. static void AddBorder(int node_type, css_node node)
  2307. {
  2308.     if (BorderWidth == node_type && (! border.width))
  2309.         border.width = node;
  2310.     else if (BorderStyle == node_type && (! border.style))
  2311.         border.style = node;
  2312.     else if (BorderColor == node_type && (! border.color))
  2313.         border.color = node;
  2314.     else {
  2315.         border.parse_error++;
  2316.         if (node) css_FreeNode(node);
  2317.     }
  2318. }
  2319.  
  2320. static css_node AssembleBorder(void)
  2321. {
  2322.     css_node head, element;
  2323.  
  2324.     if (border.parse_error) {
  2325.         if (border.width) css_FreeNode(border.width);
  2326.         if (border.style) css_FreeNode(border.style);
  2327.         if (border.color) css_FreeNode(border.color);
  2328.         ClearBorder();
  2329.         return (css_node) NULL;
  2330.     }
  2331.  
  2332.     if (! border.width)
  2333.         border.width = NewDeclarationNode(NODE_IDENT, css_medium, border_width);
  2334.     if (! border.style)
  2335.         border.style = NewDeclarationNode(NODE_IDENT, css_none, border_style);
  2336.  
  2337.     head = NewNode(NODE_DECLARATION_LIST, NULL, NULL, border.width);
  2338.     element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, border.style);
  2339.     LeftAppendNode(head, element);
  2340.     if (border.color) {
  2341.         element = NewNode(NODE_DECLARATION_LIST, NULL, NULL, border.color);
  2342.         LeftAppendNode(head, element);
  2343.     }
  2344.  
  2345.     ClearBorder();
  2346.     return head;
  2347. }
  2348.  
  2349. /* css_overflow is only for parsers generated by bison. */
  2350. static void css_overflow(const char *message, short **yyss1, int yyss1_size, 
  2351.                          YYSTYPE **yyvs1, int yyvs1_size, int *yystacksize)
  2352. {
  2353.     short * yyss2;
  2354.     YYSTYPE * yyvs2;
  2355.     int new_size;
  2356.  
  2357.  
  2358.     if (*yystacksize >= YYMAXDEPTH)
  2359.         return;
  2360.  
  2361.     new_size = *yystacksize * 2;
  2362.     if (new_size > YYMAXDEPTH)
  2363.         new_size = YYMAXDEPTH;
  2364.  
  2365.     if (*yystacksize == YYINITDEPTH) {
  2366.         /* First time allocating from the heap. */
  2367.         yyss2 = (short *) XP_ALLOC(new_size * sizeof(short));
  2368.         if (yyss2)
  2369.             (void) memcpy((void *)yyss2, (void *) *yyss1, yyss1_size);
  2370.         yyvs2 = XP_ALLOC(new_size * sizeof(YYSTYPE));
  2371.         if (yyvs2)
  2372.             (void) memcpy((void *)yyvs2, (void *) *yyvs1, yyvs1_size);
  2373.     } else {
  2374.         yyss2 = (short *) XP_REALLOC(*yyss1, new_size * sizeof(short));
  2375.         yyvs2 = XP_REALLOC(*yyvs1, new_size * sizeof(YYSTYPE));
  2376.     }
  2377.  
  2378.     if (yyss2 && yyvs2) {
  2379.         *yyss1 = yyss2;
  2380.         *yyvs1 = yyvs2;
  2381.         *yystacksize = new_size;
  2382.     }
  2383.  
  2384.     /* Any failure to allocate will be noticed by the caller. */
  2385. }
  2386.  
  2387.