/* A Bison parser, made from rcparser_y.y
   by GNU bison 1.30.  */

#define YYBISON 1  /* Identify Bison output.  */

# define	BOOL	257
# define	NUM	258
# define	UNIT	259
# define	KEYNAME	260
# define	KEY	261
# define	KEY_MOD	262
# define	STRING	263
# define	STYLE	264
# define	SPECTRAL_CLASS_LIST	265
# define	KEY_MODIFIER	266
# define	USER_COORDS	267
# define	CENTER	268
# define	VIEW_RADIUS	269
# define	MAX_LINK	270
# define	SHOW_LINKS	271
# define	SHOW_LINK_LABELS	272
# define	SHOW_STAR_LABELS	273
# define	LABELS_COLOR	274
# define	LABELS_FONT	275
# define	DISTANCE_UNIT	276
# define	NORTH	277
# define	STAR_SELECTION	278
# define	STAR_RULES	279
# define	LINK_RULES	280
# define	CATALOG	281

#line 20 "rcparser_y.y"

#include "../include/starmap.h"
#include "../include/settings.h"
#include "../include/rcparser.h"

extern int yylineno;
char *current_file;

#define YYPARSE_PARAM parser

struct link_rule
{
        double color[3];
        GdkLineStyle style;
        int width;
        double max_length;
        struct link_rule *next;
};

struct st_rcparser
{
        key_press_t *keybindings;
        double lon, lat, north, view_radius, max_link;
        coords_3d_t center;
        int show_links, show_link_labels, show_star_labels;
        double labels_color[3];
        char labels_font[256];
        distance_unit_t unit;
        star_selection_t *selection;
        double default_color[3];
        GdkLineStyle default_style;
        int default_width;
        struct link_rule *link_rules;
        star_drawing_rules_t *star_rules;
        char *filename;
};

/* Declaration of internal interface functions */

static void add_keybinding( rcparser_t *parser, keybinding_t binding,
                            key_press_t key_press );
static void set_user_coords( rcparser_t *parser, double lon, double lat );
static void set_north( rcparser_t *parser, double north );
static void set_center( rcparser_t *parser, coords_3d_t coords );
static void set_view_radius( rcparser_t *parser, double radius );
static void set_max_link( rcparser_t *parser, double max_link );
static void set_show_links( rcparser_t *parser, int show );
static void set_show_link_labels( rcparser_t *parser, int show );
static void set_show_star_labels( rcparser_t *parser, int show );
static void set_labels_color( rcparser_t *parser, double rgb[] );
static void set_labels_font( rcparser_t *parser, const char *string );
static void set_distance_unit( rcparser_t *parser, distance_unit_t unit );
static void set_star_selection( rcparser_t *parser, star_selection_t *sel );
static struct link_rule *new_link_rule( rcparser_t *parser, double distance,
                                        double rgb[], GdkLineStyle style,
                                        int width );
static void set_link_rules( rcparser_t *parser, struct link_rule *rules );
static void clear_link_rules( rcparser_t *parser );
static void set_link_defaults( rcparser_t *parser, double rgb[],
                               GdkLineStyle style, int width );
static void set_star_rules( rcparser_t *parser, star_drawing_rules_t *rules );
static void set_filename( rcparser_t *parser, char *filename );


#line 85 "rcparser_y.y"
typedef union {
        int bool;
        double number;
        coords_3d_t coords;
        double rgb[3];
        distance_unit_t unit;
        key_press_t key_press;
        keybinding_t key_name;
        char *string;
        GdkLineStyle style;
        struct { int O, B, A, F, G, K, M, W; } spectral_class_list;
        struct { double O[3], B[3], A[3], F[3], 
                         G[3], K[3], M[3], W[3]; } star_colors;
        double star_sizes[4];
        star_selection_t *star_sel;
        struct link_rule *link_rule;
} YYSTYPE;
#include <stdio.h>



#define	YYFINAL		195
#define	YYFLAG		-32768
#define	YYNTBASE	45

/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
#define YYTRANSLATE(x) ((unsigned)(x) <= 281 ? yytranslate[x] : 73)

/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
static const char yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      28,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      31,    33,     2,    30,    32,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,    35,    36,
       2,    29,     2,     2,     2,    38,    37,     2,     2,     2,
      39,    40,     2,     2,     2,    41,     2,    42,     2,    34,
       2,     2,    44,     2,     2,     2,     2,    43,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     3,     4,     5,
       6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
      26,    27
};

#if YYDEBUG != 0
static const short yyprhs[] =
{
       0,     0,     1,     4,     6,     9,    11,    13,    15,    17,
      19,    21,    23,    25,    27,    29,    31,    33,    35,    37,
      39,    41,    45,    49,    51,    55,    63,    67,    71,    75,
      79,    83,    87,    91,    95,    99,   103,   107,   117,   151,
     161,   167,   171,   173,   174,   184,   192,   195,   209,   217,
     227,   236,   245
};
static const short yyrhs[] =
{
      -1,    45,    46,     0,    28,     0,    47,    28,     0,    48,
       0,    49,     0,    51,     0,    52,     0,    53,     0,    54,
       0,    55,     0,    56,     0,    57,     0,    58,     0,    59,
       0,    60,     0,    61,     0,    62,     0,    63,     0,    66,
       0,     6,    29,    50,     0,    27,    29,     9,     0,     7,
       0,     8,    30,     7,     0,    13,    29,    31,     4,    32,
       4,    33,     0,    23,    29,     4,     0,    14,    29,    71,
       0,    15,    29,    69,     0,    16,    29,    69,     0,    17,
      29,     3,     0,    18,    29,     3,     0,    19,    29,     3,
       0,    20,    29,    70,     0,    21,    29,     9,     0,    22,
      29,     5,     0,    24,    29,    72,     0,    25,    29,    31,
      64,    32,    65,    32,    72,    33,     0,    31,    34,    35,
      70,    36,    37,    35,    70,    36,    38,    35,    70,    36,
      39,    35,    70,    36,    40,    35,    70,    36,    41,    35,
      70,    36,    42,    35,    70,    36,    43,    35,    70,    33,
       0,    31,     4,    36,     4,    36,     4,    36,     4,    33,
       0,    26,    29,    31,    67,    33,     0,    68,    32,    67,
       0,    68,     0,     0,    31,    69,    36,    70,    36,    10,
      36,     4,    33,     0,    31,    70,    36,    10,    36,     4,
      33,     0,     4,     5,     0,    31,    44,    35,     4,    36,
      40,    35,     4,    36,    37,    35,     4,    33,     0,    31,
       4,    32,     4,    32,     4,    33,     0,    31,     4,    36,
       4,    36,    11,    36,     3,    33,     0,    31,     4,    36,
      36,    11,    36,     3,    33,     0,    31,    36,     4,    36,
      11,    36,     3,    33,     0,    31,    36,    36,    11,    36,
       3,    33,     0
};

#endif

#if YYDEBUG != 0
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const short yyrline[] =
{
       0,   128,   128,   132,   132,   135,   136,   137,   138,   139,
     140,   141,   142,   143,   144,   145,   146,   147,   148,   149,
     150,   153,   158,   163,   166,   173,   178,   183,   188,   194,
     199,   204,   209,   214,   219,   233,   238,   243,   333,   370,
     378,   383,   387,   391,   396,   399,   405,   410,   417,   424,
     446,   468,   490
};
#endif


#if YYDEBUG != 0 || defined YYERROR_VERBOSE

/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
static const char *const yytname[] =
{
  "$", "error", "$undefined.", "BOOL", "NUM", "UNIT", "KEYNAME", "KEY", 
  "KEY_MOD", "STRING", "STYLE", "SPECTRAL_CLASS_LIST", "KEY_MODIFIER", 
  "USER_COORDS", "CENTER", "VIEW_RADIUS", "MAX_LINK", "SHOW_LINKS", 
  "SHOW_LINK_LABELS", "SHOW_STAR_LABELS", "LABELS_COLOR", "LABELS_FONT", 
  "DISTANCE_UNIT", "NORTH", "STAR_SELECTION", "STAR_RULES", "LINK_RULES", 
  "CATALOG", "'\\n'", "'='", "'+'", "'('", "','", "')'", "'O'", "':'", 
  "';'", "'B'", "'A'", "'F'", "'G'", "'K'", "'M'", "'W'", "'R'", "input", 
  "line", "command", "keybinding", "catalog", "key", "user_coords", 
  "north", "center", "view_radius", "max_link", "show_links", 
  "show_link_labels", "show_star_labels", "labels_color", "labels_font", 
  "distance_unit", "star_selection", "star_rules", "star_rules_colors", 
  "star_rules_sizes", "link_rules", "list_link_rules", "link_rule", 
  "distance", "rgb", "coords", "starselection", NULL
};
#endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const short yyr1[] =
{
       0,    45,    45,    46,    46,    47,    47,    47,    47,    47,
      47,    47,    47,    47,    47,    47,    47,    47,    47,    47,
      47,    48,    49,    50,    50,    51,    52,    53,    54,    55,
      56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
      66,    67,    67,    67,    68,    68,    69,    70,    71,    72,
      72,    72,    72
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
static const short yyr2[] =
{
       0,     0,     2,     1,     2,     1,     1,     1,     1,     1,
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
       1,     3,     3,     1,     3,     7,     3,     3,     3,     3,
       3,     3,     3,     3,     3,     3,     3,     9,    33,     9,
       5,     3,     1,     0,     9,     7,     2,    13,     7,     9,
       8,     8,     7
};

/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
   doesn't specify something else to do.  Zero means the default is an
   error. */
static const short yydefact[] =
{
       1,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     3,     2,
       0,     5,     6,     7,     8,     9,    10,    11,    12,    13,
      14,    15,    16,    17,    18,    19,    20,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     4,    23,     0,    21,     0,     0,    27,
       0,    28,    29,    30,    31,    32,     0,    33,    34,    35,
      26,     0,    36,     0,    43,    22,     0,     0,     0,    46,
       0,     0,     0,     0,     0,     0,     0,    42,    24,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,    40,
      43,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,    41,    25,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,    48,     0,     0,
       0,     0,    52,     0,     0,    37,     0,     0,     0,     0,
      50,    51,     0,     0,     0,    45,     0,    49,     0,     0,
       0,     0,     0,     0,    44,     0,     0,     0,     0,     0,
      39,    47,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,    38,     0,     0
};

static const short yydefgoto[] =
{
       1,    19,    20,    21,    22,    56,    23,    24,    25,    26,
      27,    28,    29,    30,    31,    32,    33,    34,    35,    84,
     110,    36,    86,    87,    61,    67,    59,    72
};

static const short yypact[] =
{
  -32768,    33,   -23,   -22,   -21,   -18,   -17,   -16,   -15,   -14,
     -13,   -12,   -11,   -10,    -9,    -8,    -7,    -5,-32768,-32768,
      -3,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,     2,    -4,     6,
      24,    24,    26,    27,    28,     7,    31,    36,    38,    12,
      13,    32,    53,-32768,-32768,    34,-32768,    61,    62,-32768,
      63,-32768,-32768,-32768,-32768,-32768,    25,-32768,-32768,-32768,
  -32768,    -2,-32768,    39,    40,-32768,    65,    41,    42,-32768,
      43,    44,    -1,    45,    49,     1,    50,    54,-32768,    71,
      72,    73,     0,    46,    74,    52,    57,    55,    56,-32768,
      40,    60,    64,    59,    67,    78,    86,    68,     7,    95,
      69,     7,    90,-32768,-32768,   101,    70,    96,    75,    76,
     105,    77,    79,    12,    80,    81,    85,    84,    87,   106,
     111,    88,    83,   118,    91,   115,   122,-32768,   123,   125,
      97,    98,-32768,    94,    99,-32768,   100,   104,   102,   107,
  -32768,-32768,     7,   128,   129,-32768,   108,-32768,   103,   110,
     109,   112,   113,   130,-32768,   137,   114,   117,   119,     7,
  -32768,-32768,   120,   116,   124,     7,   121,   126,   127,     7,
     131,   132,   133,     7,   134,   135,   136,     7,   138,   139,
     140,     7,   143,-32768,   144,-32768
};

static const short yypgoto[] =
{
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
  -32768,-32768,    48,-32768,   -40,   -85,-32768,    20
};


#define	YYLAST		182


static const short yytable[] =
{
      98,    62,    81,    93,   104,    60,    37,    38,    39,    54,
      55,    40,    41,    42,    43,    44,    45,    46,    47,    48,
      49,    50,    51,   121,    52,    53,   124,    57,    60,    63,
      64,    65,    66,   194,    82,    94,   105,    58,    66,     2,
      68,    69,    70,    71,    73,    97,     3,     4,     5,     6,
       7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
      17,    18,    75,    74,    76,    77,    78,   158,    79,    80,
      83,    85,    88,    89,    90,   101,   102,   103,    91,    95,
      92,    96,   106,    99,   172,   107,   100,   108,   109,   118,
     176,   111,   112,   114,   180,   116,   115,   119,   184,   122,
     125,   123,   188,   117,   120,   126,   192,   128,   131,   140,
     127,   129,   130,   132,   141,   133,   135,   136,   137,   138,
     143,   142,   144,   139,   145,   146,   147,   148,   149,   152,
     150,   151,   159,   160,   167,   153,   154,   155,   156,   162,
     157,   168,   164,   134,   195,   161,   163,   165,   113,   169,
     170,   166,   171,     0,     0,   174,   173,   177,     0,   175,
       0,     0,   179,     0,     0,     0,   178,   181,   183,     0,
     185,   187,     0,   182,   189,   191,   193,   186,     0,     0,
       0,     0,   190
};

static const short yycheck[] =
{
      85,    41,     4,     4,     4,     4,    29,    29,    29,     7,
       8,    29,    29,    29,    29,    29,    29,    29,    29,    29,
      29,    29,    29,   108,    29,    28,   111,    31,     4,     3,
       3,     3,    31,     0,    36,    36,    36,    31,    31,     6,
       9,     5,     4,    31,    31,    85,    13,    14,    15,    16,
      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
      27,    28,     9,    31,    30,     4,     4,   152,     5,    44,
      31,    31,     7,    32,    32,     4,     4,     4,    35,    34,
      36,    32,    36,    33,   169,    11,    32,    35,    31,    11,
     175,    36,    36,    33,   179,    36,    32,    11,   183,     4,
      10,    32,   187,    36,    36,     4,   191,    11,     3,     3,
      40,    36,    36,    36,     3,    36,    36,    36,    33,    35,
      37,    33,     4,    36,    33,    10,     4,     4,     3,    35,
      33,    33,     4,     4,     4,    36,    36,    33,    36,    36,
      33,     4,    33,   123,     0,    37,    36,    35,   100,    35,
      33,    38,    33,    -1,    -1,    39,    36,    36,    -1,    35,
      -1,    -1,    35,    -1,    -1,    -1,    40,    36,    35,    -1,
      36,    35,    -1,    41,    36,    35,    33,    42,    -1,    -1,
      -1,    -1,    43
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/share/bison/bison.simple"

/* Skeleton output parser for bison,
   Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

/* This is the parser code that is written into each bison parser when
   the %semantic_parser declaration is not specified in the grammar.
   It was written by Richard Stallman by simplifying the hairy parser
   used when %semantic_parser is specified.  */

#ifndef YYSTACK_USE_ALLOCA
# ifdef alloca
#  define YYSTACK_USE_ALLOCA 1
# else /* alloca not defined */
#  ifdef __GNUC__
#   define YYSTACK_USE_ALLOCA 1
#   define alloca __builtin_alloca
#  else /* not GNU C.  */
#   if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
#    define YYSTACK_USE_ALLOCA 1
#    include <alloca.h>
#   else /* not sparc */
     /* We think this test detects Watcom and Microsoft C.  */
     /* This used to test MSDOS, but that is a bad idea since that
	symbol is in the user namespace.  */
#    if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
#     if 0
       /* No need for malloc.h, which pollutes the namespace; instead,
	  just don't use alloca.  */
#      include <malloc.h>
#     endif
#    else /* not MSDOS, or __TURBOC__ */
#     if defined(_AIX)
       /* I don't know what this was needed for, but it pollutes the
	  namespace.  So I turned it off.  rms, 2 May 1997.  */
       /* #include <malloc.h>  */
 #pragma alloca
#      define YYSTACK_USE_ALLOCA 1
#     else /* not MSDOS, or __TURBOC__, or _AIX */
#      if 0
	/* haible@ilog.fr says this works for HPUX 9.05 and up, and on
	   HPUX 10.  Eventually we can turn this on.  */
#       ifdef __hpux
#        define YYSTACK_USE_ALLOCA 1
#        define alloca __builtin_alloca
#  	endif /* __hpux */
#      endif
#     endif /* not _AIX */
#    endif /* not MSDOS, or __TURBOC__ */
#   endif /* not sparc */
#  endif /* not GNU C */
# endif /* alloca not defined */
#endif /* YYSTACK_USE_ALLOCA not defined */

#ifndef YYSTACK_USE_ALLOCA
# define YYSTACK_USE_ALLOCA 0
#endif

#if YYSTACK_USE_ALLOCA
# define YYSTACK_ALLOC alloca
#else
# define YYSTACK_ALLOC malloc
#endif

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	goto yyacceptlab
#define YYABORT 	goto yyabortlab
#define YYERROR		goto yyerrlab1
/* Like YYERROR except do call yyerror.  This remains here temporarily
   to ease the transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL		goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(Token, Value)					\
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    {								\
      yychar = (Token);						\
      yylval = (Value);						\
      yychar1 = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { 								\
      yyerror ("syntax error: cannot back up");			\
      YYERROR;							\
    }								\
while (0)

#define YYTERROR	1
#define YYERRCODE	256


/* YYLLOC_DEFAULT -- Compute the default location (before the actions
   are run).

   When YYLLOC_DEFAULT is run, CURRENT is set the location of the
   first token.  By default, to implement support for ranges, extend
   its range to the last symbol.  */

#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)       	\
   Current.last_line   = Rhs[N].last_line;	\
   Current.last_column = Rhs[N].last_column;
#endif


/* YYLEX -- calling `yylex' with the right arguments.  */

#if YYPURE
# if YYLSP_NEEDED
#  ifdef YYLEX_PARAM
#   define YYLEX		yylex (&yylval, &yylloc, YYLEX_PARAM)
#  else
#   define YYLEX		yylex (&yylval, &yylloc)
#  endif
# else /* !YYLSP_NEEDED */
#  ifdef YYLEX_PARAM
#   define YYLEX		yylex (&yylval, YYLEX_PARAM)
#  else
#   define YYLEX		yylex (&yylval)
#  endif
# endif /* !YYLSP_NEEDED */
#else /* !YYPURE */
# define YYLEX			yylex ()
#endif /* !YYPURE */


/* Enable debugging if requested.  */
#if YYDEBUG
# define YYDPRINTF(Args)			\
do {						\
  if (yydebug)					\
    fprintf Args;				\
} while (0)
/* Nonzero means print parse trace. [The following comment makes no
   sense to me.  Could someone clarify it?  --akim] Since this is
   uninitialized, it does not stop multiple parsers from coexisting.
   */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
#endif /* !YYDEBUG */

/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef	YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).  */
#if YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif

/* Define __yy_memcpy.  Note that the size argument
   should be passed with type unsigned int, because that is what the non-GCC
   definitions require.  With GCC, __builtin_memcpy takes an arg
   of type size_t, but it can handle unsigned int.  */

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
# define __yy_memcpy(To, From, Count)	__builtin_memcpy (To, From, Count)
#else				/* not GNU C or C++ */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
# ifndef __cplusplus
__yy_memcpy (to, from, count)
     char *to;
     const char *from;
     unsigned int count;
# else /* __cplusplus */
__yy_memcpy (char *to, const char *from, unsigned int count)
# endif
{
  register const char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif

#line 216 "/usr/share/bison/bison.simple"


/* The user can define YYPARSE_PARAM as the name of an argument to be passed
   into yyparse.  The argument should have type void *.
   It should actually point to an object.
   Grammar actions can access the variable by casting it
   to the proper pointer type.  */

#ifdef YYPARSE_PARAM
# ifdef __cplusplus
#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL
# else /* !__cplusplus */
#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
# endif /* !__cplusplus */
#else /* !YYPARSE_PARAM */
# define YYPARSE_PARAM_ARG
# define YYPARSE_PARAM_DECL
#endif /* !YYPARSE_PARAM */

/* Prevent warning if -Wstrict-prototypes.  */
#ifdef __GNUC__
# ifdef YYPARSE_PARAM
int yyparse (void *);
# else
int yyparse (void);
# endif
#endif

/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
   variables are global, or local to YYPARSE.  */

#define _YY_DECL_VARIABLES				\
/* The lookahead symbol.  */				\
int yychar;						\
							\
/* The semantic value of the lookahead symbol. */	\
YYSTYPE yylval;						\
							\
/* Number of parse errors so far.  */			\
int yynerrs;

#if YYLSP_NEEDED
# define YY_DECL_VARIABLES			\
_YY_DECL_VARIABLES				\
						\
/* Location data for the lookahead symbol.  */	\
YYLTYPE yylloc;
#else
# define YY_DECL_VARIABLES			\
_YY_DECL_VARIABLES
#endif


/* If nonreentrant, generate the variables here. */

#if !YYPURE
YY_DECL_VARIABLES
#endif  /* !YYPURE */

int
yyparse (YYPARSE_PARAM_ARG)
     YYPARSE_PARAM_DECL
{
  /* If reentrant, generate the variables here. */
#if YYPURE
  YY_DECL_VARIABLES
#endif  /* !YYPURE */

  register int yystate;
  register int yyn;
  /* Number of tokens to shift before error messages enabled.  */
  int yyerrstatus;
  /* Lookahead token as an internal (translated) token number.  */
  int yychar1 = 0;

  /* Three stacks and their tools:
     `yyss': related to states,
     `yysv': related to semantic values,
     `yyls': related to locations.

     Refer to the stacks thru separate pointers, to allow yyoverflow
     to reallocate them elsewhere.  */

  /* The state stack. */
  short	yyssa[YYINITDEPTH];
  short *yyss = yyssa;
  register short *yyssp;

  /* The semantic value stack.  */
  YYSTYPE yyvsa[YYINITDEPTH];
  YYSTYPE *yyvs = yyvsa;
  register YYSTYPE *yyvsp;

#if YYLSP_NEEDED
  /* The location stack.  */
  YYLTYPE yylsa[YYINITDEPTH];
  YYLTYPE *yyls = yylsa;
  YYLTYPE *yylsp;
#endif

#if YYLSP_NEEDED
# define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
#else
# define YYPOPSTACK   (yyvsp--, yyssp--)
#endif

  int yystacksize = YYINITDEPTH;
  int yyfree_stacks = 0;


  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;
# if YYLSP_NEEDED
  YYLTYPE yyloc;
# endif

  /* When reducing, the number of symbols on the RHS of the reduced
     rule. */
  int yylen;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss;
  yyvsp = yyvs;
#if YYLSP_NEEDED
  yylsp = yyls;
#endif
  goto yysetstate;

/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
 yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed. so pushing a state here evens the stacks.
     */
  yyssp++;

 yysetstate:
  *yyssp = yystate;

  if (yyssp >= yyss + yystacksize - 1)
    {
      /* Give user a chance to reallocate the stack. Use copies of
	 these so that the &'s don't force the real ones into memory.
	 */
      YYSTYPE *yyvs1 = yyvs;
      short *yyss1 = yyss;
#if YYLSP_NEEDED
      YYLTYPE *yyls1 = yyls;
#endif

      /* Get the current used size of the three stacks, in elements.  */
      int size = yyssp - yyss + 1;

#ifdef yyoverflow
      /* Each stack pointer address is followed by the size of the
	 data in use in that stack, in bytes.  */
# if YYLSP_NEEDED
      /* This used to be a conditional around just the two extra args,
	 but that might be undefined if yyoverflow is a macro.  */
      yyoverflow ("parser stack overflow",
		  &yyss1, size * sizeof (*yyssp),
		  &yyvs1, size * sizeof (*yyvsp),
		  &yyls1, size * sizeof (*yylsp),
		  &yystacksize);
# else
      yyoverflow ("parser stack overflow",
		  &yyss1, size * sizeof (*yyssp),
		  &yyvs1, size * sizeof (*yyvsp),
		  &yystacksize);
# endif

      yyss = yyss1; yyvs = yyvs1;
# if YYLSP_NEEDED
      yyls = yyls1;
# endif
#else /* no yyoverflow */
      /* Extend the stack our own way.  */
      if (yystacksize >= YYMAXDEPTH)
	{
	  yyerror ("parser stack overflow");
	  if (yyfree_stacks)
	    {
	      free (yyss);
	      free (yyvs);
# if YYLSP_NEEDED
	      free (yyls);
# endif
	    }
	  return 2;
	}
      yystacksize *= 2;
      if (yystacksize > YYMAXDEPTH)
	yystacksize = YYMAXDEPTH;
# if !YYSTACK_USE_ALLOCA
      yyfree_stacks = 1;
# endif
      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
      __yy_memcpy ((char *)yyss, (char *)yyss1,
		   size * (unsigned int) sizeof (*yyssp));
      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
		   size * (unsigned int) sizeof (*yyvsp));
# if YYLSP_NEEDED
      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
      __yy_memcpy ((char *)yyls, (char *)yyls1,
		   size * (unsigned int) sizeof (*yylsp));
# endif
#endif /* no yyoverflow */

      yyssp = yyss + size - 1;
      yyvsp = yyvs + size - 1;
#if YYLSP_NEEDED
      yylsp = yyls + size - 1;
#endif

      YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));

      if (yyssp >= yyss + yystacksize - 1)
	YYABORT;
    }

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  goto yybackup;


/*-----------.
| yybackup.  |
`-----------*/
yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* yychar is either YYEMPTY or YYEOF
     or a valid token in external form.  */

  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

  /* Convert token to internal form (in yychar1) for indexing tables with */

  if (yychar <= 0)		/* This means end of input. */
    {
      yychar1 = 0;
      yychar = YYEOF;		/* Don't call YYLEX any more */

      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yychar1 = YYTRANSLATE (yychar);

#if YYDEBUG
     /* We have to keep this `#if YYDEBUG', since we use variables
	which are defined only if `YYDEBUG' is set.  */
      if (yydebug)
	{
	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
	  /* Give the individual parser a way to print the precise
	     meaning of a token, for further debugging info.  */
# ifdef YYPRINT
	  YYPRINT (stderr, yychar, yylval);
# endif
	  fprintf (stderr, ")\n");
	}
#endif
    }

  yyn += yychar1;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
    goto yydefault;

  yyn = yytable[yyn];

  /* yyn is what to do for this token type in this state.
     Negative => reduce, -yyn is rule number.
     Positive => shift, yyn is new state.
       New state is final state => don't bother to shift,
       just return success.
     0, or most negative number => error.  */

  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrlab;

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */
  YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;
#if YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  yystate = yyn;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.

     Otherwise, the following line sets YYVAL to the semantic value of
     the lookahead token.  This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];

#if YYLSP_NEEDED
  /* Similarly for the default location.  Let the user run additional
     commands if for instance locations are ranges.  */
  yyloc = yylsp[1-yylen];
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
#endif

#if YYDEBUG
  /* We have to keep this `#if YYDEBUG', since we use variables which
     are defined only if `YYDEBUG' is set.  */
  if (yydebug)
    {
      int i;

      fprintf (stderr, "Reducing via rule %d (line %d), ",
	       yyn, yyrline[yyn]);

      /* Print the symbols being reduced, and their result.  */
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
    }
#endif

  switch (yyn) {

case 21:
#line 154 "rcparser_y.y"
{ 
        add_keybinding((rcparser_t*)parser, yyvsp[-2].key_name, yyvsp[0].key_press); 
;
    break;}
case 22:
#line 159 "rcparser_y.y"
{
        set_filename((rcparser_t*)parser, yyvsp[0].string );
;
    break;}
case 23:
#line 164 "rcparser_y.y"
{
			yyval.key_press = yyvsp[0].key_press;
		;
    break;}
case 24:
#line 168 "rcparser_y.y"
{
			yyval.key_press.mods = yyvsp[-2].key_press.mods;
			yyval.key_press.key = yyvsp[0].key_press.key;
		;
    break;}
case 25:
#line 174 "rcparser_y.y"
{
        set_user_coords((rcparser_t*)parser, yyvsp[-1].number, yyvsp[-3].number); 
;
    break;}
case 26:
#line 179 "rcparser_y.y"
{
        set_north((rcparser_t*)parser, yyvsp[0].number);
;
    break;}
case 27:
#line 184 "rcparser_y.y"
{
        set_center((rcparser_t*)parser, yyvsp[0].coords);
;
    break;}
case 28:
#line 189 "rcparser_y.y"
{
        set_view_radius((rcparser_t*)parser, yyvsp[0].number);
;
    break;}
case 29:
#line 195 "rcparser_y.y"
{
        set_max_link((rcparser_t*)parser, yyvsp[0].number);
;
    break;}
case 30:
#line 200 "rcparser_y.y"
{
        set_show_links((rcparser_t*)parser, yyvsp[0].bool);
;
    break;}
case 31:
#line 205 "rcparser_y.y"
{
        set_show_link_labels((rcparser_t*)parser, yyvsp[0].bool);
;
    break;}
case 32:
#line 210 "rcparser_y.y"
{
        set_show_star_labels((rcparser_t*)parser, yyvsp[0].bool);
;
    break;}
case 33:
#line 215 "rcparser_y.y"
{
        set_labels_color((rcparser_t*)parser, yyvsp[0].rgb);
;
    break;}
case 34:
#line 220 "rcparser_y.y"
{
        char msg[512];
        
        if( !gdk_font_load(yyvsp[0].string) )
        {       
                sprintf( msg, _("Font \"%s\" not found"), yyvsp[0].string);
                yyerror(msg);
                YYERROR;
        }
        else
                set_labels_font((rcparser_t*)parser, yyvsp[0].string);
;
    break;}
case 35:
#line 234 "rcparser_y.y"
{
        set_distance_unit((rcparser_t*)parser, yyvsp[0].unit);
;
    break;}
case 36:
#line 239 "rcparser_y.y"
{
        set_star_selection((rcparser_t*)parser, yyvsp[0].star_sel);
;
    break;}
case 37:
#line 245 "rcparser_y.y"
{
        star_drawing_rules_t *rules;
        star_selection_t *selection;

        rules = star_drawing_rules_new(DEFAULT_SIZE, default_color);

        /* Colors */

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_O );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_O, 0, 
                                yyvsp[-5].star_colors.O, FALSE );

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_B );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_B, 0, 
                                yyvsp[-5].star_colors.B, FALSE );

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_A );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_A, 0, 
                                yyvsp[-5].star_colors.A, FALSE );

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_F );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_F, 0, 
                                yyvsp[-5].star_colors.F, FALSE );

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_G );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_G, 0, 
                                yyvsp[-5].star_colors.G, FALSE );

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_K );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_K, 0, 
                                yyvsp[-5].star_colors.K, FALSE );

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_M );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_M, 0, 
                                yyvsp[-5].star_colors.M, FALSE );

        selection = star_selection_new();
        star_selection_act_spectrum( selection, SPECTRUM_WHITE_DWARF );
        star_drawing_rules_add( rules, selection, PRIORITY_SPECTRUM_WD, 0, 
                                yyvsp[-5].star_colors.W, FALSE );

        /* The size settings. */
        /* NOTE: The rules must be inserted in this order, so that in the case
           of multiple stars, if different components match different rules,
           the largest one will have preference. */

        selection = star_selection_new();
        star_selection_act_min_lum( selection, yyvsp[-3].star_sizes[3]);
        star_drawing_rules_add( rules, selection, PRIORITY_LUMINOSITY, 
                                SIZE_4, NULL, FALSE );

        selection = star_selection_new();
        star_selection_act_min_lum( selection, yyvsp[-3].star_sizes[2]);
        star_selection_act_max_lum( selection, yyvsp[-3].star_sizes[3]);
        star_drawing_rules_add( rules, selection, PRIORITY_LUMINOSITY, 
                                SIZE_3, NULL, FALSE );

        selection = star_selection_new();
        star_selection_act_min_lum( selection, yyvsp[-3].star_sizes[1]);
        star_selection_act_max_lum( selection, yyvsp[-3].star_sizes[2]);
        star_drawing_rules_add( rules, selection, PRIORITY_LUMINOSITY, 
                                SIZE_2, NULL, FALSE );

        selection = star_selection_new();
        star_selection_act_min_lum( selection, yyvsp[-3].star_sizes[0]);
        star_selection_act_max_lum( selection, yyvsp[-3].star_sizes[1]);
        star_drawing_rules_add( rules, selection, PRIORITY_LUMINOSITY, 
                                SIZE_1, NULL, FALSE );

        selection = star_selection_new();
        star_selection_act_max_lum( selection, yyvsp[-3].star_sizes[0] );
        star_drawing_rules_add( rules, selection, PRIORITY_LUMINOSITY, 
                                SIZE_0, NULL, FALSE );

        /* The name settings. */
        star_drawing_rules_add( rules, yyvsp[-1].star_sel, PRIORITY_SHOW_NAME, 
                                0, NULL, TRUE );

        set_star_rules( (rcparser_t*)parser, rules );
;
    break;}
case 38:
#line 336 "rcparser_y.y"
{
        yyval.star_colors.O[0] = yyvsp[-29].rgb[0];
        yyval.star_colors.O[1] = yyvsp[-29].rgb[1];
        yyval.star_colors.O[2] = yyvsp[-29].rgb[2];

        yyval.star_colors.B[0] = yyvsp[-25].rgb[0];
        yyval.star_colors.B[1] = yyvsp[-25].rgb[1];
        yyval.star_colors.B[2] = yyvsp[-25].rgb[2];

        yyval.star_colors.A[0] = yyvsp[-21].rgb[0];
        yyval.star_colors.A[1] = yyvsp[-21].rgb[1];
        yyval.star_colors.A[2] = yyvsp[-21].rgb[2];

        yyval.star_colors.F[0] = yyvsp[-17].rgb[0];
        yyval.star_colors.F[1] = yyvsp[-17].rgb[1];
        yyval.star_colors.F[2] = yyvsp[-17].rgb[2];

        yyval.star_colors.G[0] = yyvsp[-13].rgb[0];
        yyval.star_colors.G[1] = yyvsp[-13].rgb[1];
        yyval.star_colors.G[2] = yyvsp[-13].rgb[2];

        yyval.star_colors.K[0] = yyvsp[-9].rgb[0];
        yyval.star_colors.K[1] = yyvsp[-9].rgb[1];
        yyval.star_colors.K[2] = yyvsp[-9].rgb[2];

        yyval.star_colors.M[0] = yyvsp[-5].rgb[0];
        yyval.star_colors.M[1] = yyvsp[-5].rgb[1];
        yyval.star_colors.M[2] = yyvsp[-5].rgb[2];

        yyval.star_colors.W[0] = yyvsp[-1].rgb[0];
        yyval.star_colors.W[1] = yyvsp[-1].rgb[1];
        yyval.star_colors.W[2] = yyvsp[-1].rgb[2];
;
    break;}
case 39:
#line 371 "rcparser_y.y"
{
        yyval.star_sizes[0] = yyvsp[-7].number;
        yyval.star_sizes[1] = yyvsp[-5].number;
        yyval.star_sizes[2] = yyvsp[-3].number;
        yyval.star_sizes[3] = yyvsp[-1].number;
;
    break;}
case 40:
#line 379 "rcparser_y.y"
{
        set_link_rules( (rcparser_t*)parser, yyvsp[-1].link_rule );
;
    break;}
case 41:
#line 384 "rcparser_y.y"
{
        yyvsp[-2].link_rule->next = yyvsp[0].link_rule;
        yyval.link_rule = yyvsp[-2].link_rule;
;
    break;}
case 42:
#line 389 "rcparser_y.y"
{
        yyval.link_rule = yyvsp[0].link_rule;
;
    break;}
case 43:
#line 392 "rcparser_y.y"
{
        yyval.link_rule = NULL;
;
    break;}
case 44:
#line 397 "rcparser_y.y"
{
        yyval.link_rule = new_link_rule( (rcparser_t*)parser, yyvsp[-7].number, yyvsp[-5].rgb, yyvsp[-3].style, yyvsp[-1].number );
;
    break;}
case 45:
#line 401 "rcparser_y.y"
{
        set_link_defaults( (rcparser_t*)parser, yyvsp[-5].rgb, yyvsp[-3].style, yyvsp[-1].number );
;
    break;}
case 46:
#line 406 "rcparser_y.y"
{ 
        yyval.number = yyvsp[-1].number / (yyvsp[0].unit == DISTANCE_PARSECS ? 1 : PARSEC_TO_LY);
;
    break;}
case 47:
#line 411 "rcparser_y.y"
{
        yyval.rgb[0] = yyvsp[-9].number;
        yyval.rgb[1] = yyvsp[-5].number;
        yyval.rgb[2] = yyvsp[-1].number;
;
    break;}
case 48:
#line 418 "rcparser_y.y"
{
        yyval.coords.x = yyvsp[-5].number;
        yyval.coords.y = yyvsp[-3].number;
        yyval.coords.z = yyvsp[-1].number;
;
    break;}
case 49:
#line 425 "rcparser_y.y"
{
        yyval.star_sel = star_selection_new();
        star_selection_set_allow_multiples( yyval.star_sel, yyvsp[-1].bool );
        star_selection_act_min_lum( yyval.star_sel, yyvsp[-7].number );
        star_selection_act_max_lum( yyval.star_sel, yyvsp[-5].number );
        if( yyvsp[-3].spectral_class_list.O )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_O );
        if( yyvsp[-3].spectral_class_list.B )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_B );
        if( yyvsp[-3].spectral_class_list.A )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_A );
        if( yyvsp[-3].spectral_class_list.F )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_F );
        if( yyvsp[-3].spectral_class_list.G )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_G );
        if( yyvsp[-3].spectral_class_list.K )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_K );
        if( yyvsp[-3].spectral_class_list.M )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_M );
        if( yyvsp[-3].spectral_class_list.W )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_WHITE_DWARF );
;
    break;}
case 50:
#line 448 "rcparser_y.y"
{
        yyval.star_sel = star_selection_new();
        star_selection_set_allow_multiples( yyval.star_sel, yyvsp[-1].bool );
        star_selection_act_min_lum( yyval.star_sel, yyvsp[-6].number );
        if( yyvsp[-3].spectral_class_list.O )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_O );
        if( yyvsp[-3].spectral_class_list.B )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_B );
        if( yyvsp[-3].spectral_class_list.A )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_A );
        if( yyvsp[-3].spectral_class_list.F )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_F );
        if( yyvsp[-3].spectral_class_list.G )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_G );
        if( yyvsp[-3].spectral_class_list.K )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_K );
        if( yyvsp[-3].spectral_class_list.M )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_M );
        if( yyvsp[-3].spectral_class_list.W )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_WHITE_DWARF );
;
    break;}
case 51:
#line 470 "rcparser_y.y"
{
        yyval.star_sel = star_selection_new();
        star_selection_set_allow_multiples( yyval.star_sel, yyvsp[-1].bool );
        star_selection_act_max_lum( yyval.star_sel, yyvsp[-5].number );
        if( yyvsp[-3].spectral_class_list.O )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_O );
        if( yyvsp[-3].spectral_class_list.B )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_B );
        if( yyvsp[-3].spectral_class_list.A )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_A );
        if( yyvsp[-3].spectral_class_list.F )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_F );
        if( yyvsp[-3].spectral_class_list.G )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_G );
        if( yyvsp[-3].spectral_class_list.K )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_K );
        if( yyvsp[-3].spectral_class_list.M )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_M );
        if( yyvsp[-3].spectral_class_list.W )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_WHITE_DWARF );
;
    break;}
case 52:
#line 492 "rcparser_y.y"
{
        yyval.star_sel = star_selection_new();
        star_selection_set_allow_multiples( yyval.star_sel, yyvsp[-1].bool );
        if( yyvsp[-3].spectral_class_list.O )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_O );
        if( yyvsp[-3].spectral_class_list.B )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_B );
        if( yyvsp[-3].spectral_class_list.A )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_A );
        if( yyvsp[-3].spectral_class_list.F )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_F );
        if( yyvsp[-3].spectral_class_list.G )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_G );
        if( yyvsp[-3].spectral_class_list.K )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_K );
        if( yyvsp[-3].spectral_class_list.M )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_M );
        if( yyvsp[-3].spectral_class_list.W )
                star_selection_act_spectrum( yyval.star_sel, SPECTRUM_WHITE_DWARF );
;
    break;}
}

#line 610 "/usr/share/bison/bison.simple"


  yyvsp -= yylen;
  yyssp -= yylen;
#if YYLSP_NEEDED
  yylsp -= yylen;
#endif

#if YYDEBUG
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

  *++yyvsp = yyval;
#if YYLSP_NEEDED
  *++yylsp = yyloc;
#endif

  /* Now `shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTBASE];

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;

#ifdef YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (yyn > YYFLAG && yyn < YYLAST)
	{
	  int size = 0;
	  char *msg;
	  int x, count;

	  count = 0;
	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
	  for (x = (yyn < 0 ? -yyn : 0);
	       x < (int) (sizeof (yytname) / sizeof (char *)); x++)
	    if (yycheck[x + yyn] == x)
	      size += strlen (yytname[x]) + 15, count++;
	  size += strlen ("parse error, unexpected `") + 1;
	  size += strlen (yytname[YYTRANSLATE (yychar)]);
	  msg = (char *) malloc (size);
	  if (msg != 0)
	    {
	      strcpy (msg, "parse error, unexpected `");
	      strcat (msg, yytname[YYTRANSLATE (yychar)]);
	      strcat (msg, "'");

	      if (count < 5)
		{
		  count = 0;
		  for (x = (yyn < 0 ? -yyn : 0);
		       x < (int) (sizeof (yytname) / sizeof (char *)); x++)
		    if (yycheck[x + yyn] == x)
		      {
			strcat (msg, count == 0 ? ", expecting `" : " or `");
			strcat (msg, yytname[x]);
			strcat (msg, "'");
			count++;
		      }
		}
	      yyerror (msg);
	      free (msg);
	    }
	  else
	    yyerror ("parse error; also virtual memory exceeded");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror ("parse error");
    }
  goto yyerrlab1;


/*--------------------------------------------------.
| yyerrlab1 -- error raised explicitly by an action |
`--------------------------------------------------*/
yyerrlab1:
  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */

      /* return failure if at end of input */
      if (yychar == YYEOF)
	YYABORT;
      YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
		  yychar, yytname[yychar1]));
      yychar = YYEMPTY;
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */

  yyerrstatus = 3;		/* Each real token shifted decrements this */

  goto yyerrhandle;


/*-------------------------------------------------------------------.
| yyerrdefault -- current state does not do anything special for the |
| error token.                                                       |
`-------------------------------------------------------------------*/
yyerrdefault:
#if 0
  /* This is wrong; only states that explicitly want error tokens
     should shift them.  */

  /* If its default is to accept any token, ok.  Otherwise pop it.  */
  yyn = yydefact[yystate];
  if (yyn)
    goto yydefault;
#endif


/*---------------------------------------------------------------.
| yyerrpop -- pop the current state because it cannot handle the |
| error token                                                    |
`---------------------------------------------------------------*/
yyerrpop:
  if (yyssp == yyss)
    YYABORT;
  yyvsp--;
  yystate = *--yyssp;
#if YYLSP_NEEDED
  yylsp--;
#endif

#if YYDEBUG
  if (yydebug)
    {
      short *ssp1 = yyss - 1;
      fprintf (stderr, "Error: state stack now");
      while (ssp1 != yyssp)
	fprintf (stderr, " %d", *++ssp1);
      fprintf (stderr, "\n");
    }
#endif

/*--------------.
| yyerrhandle.  |
`--------------*/
yyerrhandle:
  yyn = yypact[yystate];
  if (yyn == YYFLAG)
    goto yyerrdefault;

  yyn += YYTERROR;
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
    goto yyerrdefault;

  yyn = yytable[yyn];
  if (yyn < 0)
    {
      if (yyn == YYFLAG)
	goto yyerrpop;
      yyn = -yyn;
      goto yyreduce;
    }
  else if (yyn == 0)
    goto yyerrpop;

  if (yyn == YYFINAL)
    YYACCEPT;

  YYDPRINTF ((stderr, "Shifting error token, "));

  *++yyvsp = yylval;
#if YYLSP_NEEDED
  *++yylsp = yylloc;
#endif

  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#if YYLSP_NEEDED
      free (yyls);
#endif
    }
  return 0;


/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  if (yyfree_stacks)
    {
      free (yyss);
      free (yyvs);
#if YYLSP_NEEDED
      free (yyls);
#endif
    }
  return 1;
}
#line 513 "rcparser_y.y"


int yyerror ( char *s )
{
        char msg[256];
        sprintf( msg, _("File %s, Line %i: %s"), current_file, yylineno, s );
        emit_error_message(msg);
}

/* External Interface Functions */
        
rcparser_t *rcparser_new( void )
{
        rcparser_t *parser;
        int i;

        if( (parser = (rcparser_t*)malloc(sizeof(rcparser_t))) &&
            (parser->keybindings = (key_press_t*) 
             malloc(sizeof(key_press_t)*KEY_END_OF_LIST) ) )
        {
                parser->link_rules = NULL;
        }

        for( i = 0; i < KEY_END_OF_LIST; i++ )
        {
                parser->keybindings[i].key = 0;
                parser->keybindings[i].mods = 0;
        }

        parser->filename = NULL;

        return parser;
}

int rcparser_parse_file( rcparser_t *parser, const char *filename )
{
        yylineno = 1;
        current_file = filename;
        rcparser_init_lex(filename);
        return yyparse( parser );
}

void rcparser_apply_to_settings( rcparser_t *parser, settings_t *settings )
{
        link_selection_t *selection;
        link_drawing_rules_t *rules;
        double prev = 0;
        struct link_rule *r;

        /* Lots of changes here, save the callbacks for later. */
        settings_disable_callbacks( settings );

        settings_set_sight_params_polar( settings, 
                                         parser->lon * M_PI/180, 
                                         parser->lat * M_PI/180,
                                         parser->north * M_PI/180 );
        settings_set_center( settings, &parser->center );
        settings_set_view_radius( settings, parser->view_radius );
        selection = link_selection_new();
        link_selection_act_max_length( selection, parser->max_link );
        settings_set_link_filter( settings, selection );
        settings_set_show_links( settings, parser->show_links );
        settings_set_show_link_labels( settings, parser->show_link_labels );
        settings_set_show_star_labels( settings, parser->show_star_labels );
        settings_set_labels_color( settings, parser->labels_color );
        settings_set_labels_font( settings, parser->labels_font );
        settings_set_distance_unit( settings, parser->unit );
        settings_set_star_filter( settings, parser->selection );
        rules = link_drawing_rules_new( parser->default_width,
                                        parser->default_style,
                                        parser->default_color );
        for( r = parser->link_rules; r; r = r->next )
        {
                selection = link_selection_new();
                link_selection_act_min_length( selection, prev );
                link_selection_act_max_length( selection, r->max_length );
                link_drawing_rules_add( rules, selection, r->width, 
                                        r->style, r->color );
                prev = r->max_length;
        }
        settings_set_link_draw_rules( settings, rules );
        settings_set_star_draw_rules( settings, parser->star_rules );
        if( parser->filename )
                settings_set_catalog_filename( settings, parser->filename );
        settings_set_keybindings( settings, parser->keybindings );

        settings_enable_callbacks( settings );
}

void rcparser_destroy( rcparser_t *parser )
{
        struct link_rule *rule;

        for( rule = parser->link_rules; rule; rule = rule->next )
                free(rule);

        free(parser);
}

/* Internal interface */

void add_keybinding( rcparser_t *parser, keybinding_t binding,
                     key_press_t key_press )
{
        parser->keybindings[binding] = key_press;
}

void set_user_coords( rcparser_t *parser, double lon, double lat )
{
        parser->lon = lon;
        parser->lat = lat;
}

void set_north( rcparser_t *parser, double north )
{
        parser->north = north;
}

void set_center( rcparser_t *parser, coords_3d_t coords )
{
        parser->center = coords;
}

void set_view_radius( rcparser_t *parser, double radius )
{
        parser->view_radius = radius;
}

void set_max_link( rcparser_t *parser, double max_link )
{
        parser->max_link = max_link;
}

void set_show_links( rcparser_t *parser, int show )
{
        parser->show_links = show;
}

void set_show_link_labels( rcparser_t *parser, int show )
{
        parser->show_link_labels = show;
}

void set_show_star_labels( rcparser_t *parser, int show )
{
        parser->show_star_labels = show;
}

void set_labels_color( rcparser_t *parser, double rgb[] )
{
        parser->labels_color[0] = rgb[0];
        parser->labels_color[1] = rgb[1];
        parser->labels_color[2] = rgb[2];
}

void set_labels_font( rcparser_t *parser, const char *string )
{
        strncpy( parser->labels_font, string, 256 );
}

void set_distance_unit( rcparser_t *parser, distance_unit_t unit )
{
        parser->unit = unit;
}

void set_star_selection( rcparser_t *parser, star_selection_t *sel )
{
        parser->selection = sel;
}
                         
struct link_rule *new_link_rule( rcparser_t *parser, double distance,
                                 double rgb[], GdkLineStyle style, int width )
{
        struct link_rule *rule;
        
        rule = (struct link_rule*) malloc( sizeof(struct link_rule) );
        
        rule->next = NULL;
        rule->color[0] = rgb[0];
        rule->color[1] = rgb[1];
        rule->color[2] = rgb[2];
        rule->width = width;
        rule->style = style;
        rule->max_length = distance;

        return rule;
}

void clear_link_rules( rcparser_t *parser )
{
        struct link_rule *rule, *rule_tmp;

        for( rule = parser->link_rules; rule; rule = rule_tmp )
        {
                rule_tmp = rule->next;
                free( rule );
        }
        parser->link_rules = NULL;
}

void set_link_rules( rcparser_t *parser, struct link_rule *rules )
{
        if( parser->link_rules )
                clear_link_rules( parser );
        parser->link_rules = rules;
}

void set_link_defaults( rcparser_t *parser, double rgb[], GdkLineStyle style, 
                        int width )
{
        parser->default_color[0] = rgb[0];
        parser->default_color[1] = rgb[1];
        parser->default_color[2] = rgb[2];
        parser->default_style = style;
        parser->default_width = width;
}

void set_star_rules( rcparser_t *parser, star_drawing_rules_t *rules )
{
        parser->star_rules = rules;
}
                     
void set_filename( rcparser_t *parser, char *filename )
{
        parser->filename = filename;
}


syntax highlighted by Code2HTML, v. 0.9.1