Main Page | Data Structures | Directories | File List | Data Fields | Globals

cframe_parser.c

Go to the documentation of this file.
00001 /* A Bison parser, made by GNU Bison 2.2.  */
00002 
00003 /* Skeleton implementation for Bison's Yacc-like parsers in C
00004 
00005    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
00006    Free Software Foundation, Inc.
00007 
00008    This program is free software; you can redistribute it and/or modify
00009    it under the terms of the GNU General Public License as published by
00010    the Free Software Foundation; either version 2, or (at your option)
00011    any later version.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021    Boston, MA 02110-1301, USA.  */
00022 
00023 /* As a special exception, you may create a larger work that contains
00024    part or all of the Bison parser skeleton and distribute that work
00025    under terms of your choice, so long as that work isn't itself a
00026    parser generator using the skeleton or a modified version thereof
00027    as a parser skeleton.  Alternatively, if you modify or redistribute
00028    the parser skeleton itself, you may (at your option) remove this
00029    special exception, which will cause the skeleton and the resulting
00030    Bison output files to be licensed under the GNU General Public
00031    License without this special exception.
00032 
00033    This special exception was added by the Free Software Foundation in
00034    version 2.2 of Bison.  */
00035 
00036 /* C LALR(1) parser skeleton written by Richard Stallman, by
00037    simplifying the original so-called "semantic" parser.  */
00038 
00039 /* All symbols defined below should begin with yy or YY, to avoid
00040    infringing on user name space.  This should be done even for local
00041    variables, as they might otherwise be expanded by user macros.
00042    There are some unavoidable exceptions within include files to
00043    define necessary library symbols; they are noted "INFRINGES ON
00044    USER NAME SPACE" below.  */
00045 
00046 /* Identify Bison output.  */
00047 #define YYBISON 1
00048 
00049 /* Bison version.  */
00050 #define YYBISON_VERSION "2.2"
00051 
00052 /* Skeleton name.  */
00053 #define YYSKELETON_NAME "yacc.c"
00054 
00055 /* Pure parsers.  */
00056 #define YYPURE 0
00057 
00058 /* Using locations.  */
00059 #define YYLSP_NEEDED 0
00060 
00061 /* Substitute the variable and function names.  */
00062 #define yyparse cframeparse
00063 #define yylex   cframelex
00064 #define yyerror cframeerror
00065 #define yylval  cframelval
00066 #define yychar  cframechar
00067 #define yydebug cframedebug
00068 #define yynerrs cframenerrs
00069 
00070 
00071 /* Tokens.  */
00072 #ifndef YYTOKENTYPE
00073 # define YYTOKENTYPE
00074    /* Put the tokens into the symbol table, so that GDB and other debuggers
00075       know about them.  */
00076    enum yytokentype {
00077      STRING = 258,
00078      LBRACE = 259,
00079      RBRACE = 260,
00080      EQ = 261,
00081      COMMA = 262
00082    };
00083 #endif
00084 /* Tokens.  */
00085 #define STRING 258
00086 #define LBRACE 259
00087 #define RBRACE 260
00088 #define EQ 261
00089 #define COMMA 262
00090 
00091 
00092 
00093 
00094 /* Copy the first part of user declarations.  */
00095 #line 1 "src/cframe_parser.y"
00096 
00097 #include <config.h>
00098 
00099 #include <stdio.h>
00100 #include <stdlib.h>
00101 #include <string.h>
00102 #include <errno.h>
00103 
00104 #include <cartcomm/nmea.h>
00105 #include <cartcomm/cframe.h>
00106 #include "nan.h"
00107 
00108 #define DEBUG_LEVEL 1
00109 #include "debug.h"
00110 
00111 #include "cframe_lexer.h"
00112 #include "cframe_parser.h"
00113 
00114 #define YYPARSE_PARAM data
00115 #define cdata ((cframe_t *) data)
00116 
00117 int cframedebug = 1;
00118 #define YYERROR_VERBOSE
00119 
00120 int cframewrap(void) { return 1; }
00121 void cframeerror(char *str) {
00122     DEBUG1("error decoding: %s", str);
00123 }
00124 
00125 void parse_avpair(cframe_t *cf, char *fieldName, char *fieldVal);
00126 
00127 
00128 /* Enabling traces.  */
00129 #ifndef YYDEBUG
00130 # define YYDEBUG 0
00131 #endif
00132 
00133 /* Enabling verbose error messages.  */
00134 #ifdef YYERROR_VERBOSE
00135 # undef YYERROR_VERBOSE
00136 # define YYERROR_VERBOSE 1
00137 #else
00138 # define YYERROR_VERBOSE 0
00139 #endif
00140 
00141 /* Enabling the token table.  */
00142 #ifndef YYTOKEN_TABLE
00143 # define YYTOKEN_TABLE 0
00144 #endif
00145 
00146 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
00147 typedef union YYSTYPE
00148 #line 33 "src/cframe_parser.y"
00149 {
00150     char *string;
00151 }
00152 /* Line 187 of yacc.c.  */
00153 #line 154 "src/cframe_parser.tab.c"
00154     YYSTYPE;
00155 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
00156 # define YYSTYPE_IS_DECLARED 1
00157 # define YYSTYPE_IS_TRIVIAL 1
00158 #endif
00159 
00160 
00161 
00162 /* Copy the second part of user declarations.  */
00163 
00164 
00165 /* Line 216 of yacc.c.  */
00166 #line 167 "src/cframe_parser.tab.c"
00167 
00168 #ifdef short
00169 # undef short
00170 #endif
00171 
00172 #ifdef YYTYPE_UINT8
00173 typedef YYTYPE_UINT8 yytype_uint8;
00174 #else
00175 typedef unsigned char yytype_uint8;
00176 #endif
00177 
00178 #ifdef YYTYPE_INT8
00179 typedef YYTYPE_INT8 yytype_int8;
00180 #elif (defined __STDC__ || defined __C99__FUNC__ \
00181      || defined __cplusplus || defined _MSC_VER)
00182 typedef signed char yytype_int8;
00183 #else
00184 typedef short int yytype_int8;
00185 #endif
00186 
00187 #ifdef YYTYPE_UINT16
00188 typedef YYTYPE_UINT16 yytype_uint16;
00189 #else
00190 typedef unsigned short int yytype_uint16;
00191 #endif
00192 
00193 #ifdef YYTYPE_INT16
00194 typedef YYTYPE_INT16 yytype_int16;
00195 #else
00196 typedef short int yytype_int16;
00197 #endif
00198 
00199 #ifndef YYSIZE_T
00200 # ifdef __SIZE_TYPE__
00201 #  define YYSIZE_T __SIZE_TYPE__
00202 # elif defined size_t
00203 #  define YYSIZE_T size_t
00204 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
00205      || defined __cplusplus || defined _MSC_VER)
00206 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
00207 #  define YYSIZE_T size_t
00208 # else
00209 #  define YYSIZE_T unsigned int
00210 # endif
00211 #endif
00212 
00213 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
00214 
00215 #ifndef YY_
00216 # if YYENABLE_NLS
00217 #  if ENABLE_NLS
00218 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
00219 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
00220 #  endif
00221 # endif
00222 # ifndef YY_
00223 #  define YY_(msgid) msgid
00224 # endif
00225 #endif
00226 
00227 /* Suppress unused-variable warnings by "using" E.  */
00228 #if ! defined lint || defined __GNUC__
00229 # define YYUSE(e) ((void) (e))
00230 #else
00231 # define YYUSE(e) /* empty */
00232 #endif
00233 
00234 /* Identity function, used to suppress warnings about constant conditions.  */
00235 #ifndef lint
00236 # define YYID(n) (n)
00237 #else
00238 #if (defined __STDC__ || defined __C99__FUNC__ \
00239      || defined __cplusplus || defined _MSC_VER)
00240 static int
00241 YYID (int i)
00242 #else
00243 static int
00244 YYID (i)
00245     int i;
00246 #endif
00247 {
00248   return i;
00249 }
00250 #endif
00251 
00252 #if ! defined yyoverflow || YYERROR_VERBOSE
00253 
00254 /* The parser invokes alloca or malloc; define the necessary symbols.  */
00255 
00256 # ifdef YYSTACK_USE_ALLOCA
00257 #  if YYSTACK_USE_ALLOCA
00258 #   ifdef __GNUC__
00259 #    define YYSTACK_ALLOC __builtin_alloca
00260 #   elif defined __BUILTIN_VA_ARG_INCR
00261 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
00262 #   elif defined _AIX
00263 #    define YYSTACK_ALLOC __alloca
00264 #   elif defined _MSC_VER
00265 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
00266 #    define alloca _alloca
00267 #   else
00268 #    define YYSTACK_ALLOC alloca
00269 #    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00270      || defined __cplusplus || defined _MSC_VER)
00271 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00272 #     ifndef _STDLIB_H
00273 #      define _STDLIB_H 1
00274 #     endif
00275 #    endif
00276 #   endif
00277 #  endif
00278 # endif
00279 
00280 # ifdef YYSTACK_ALLOC
00281    /* Pacify GCC's `empty if-body' warning.  */
00282 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
00283 #  ifndef YYSTACK_ALLOC_MAXIMUM
00284     /* The OS might guarantee only one guard page at the bottom of the stack,
00285        and a page size can be as small as 4096 bytes.  So we cannot safely
00286        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
00287        to allow for a few compiler-allocated temporary stack slots.  */
00288 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
00289 #  endif
00290 # else
00291 #  define YYSTACK_ALLOC YYMALLOC
00292 #  define YYSTACK_FREE YYFREE
00293 #  ifndef YYSTACK_ALLOC_MAXIMUM
00294 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
00295 #  endif
00296 #  if (defined __cplusplus && ! defined _STDLIB_H \
00297        && ! ((defined YYMALLOC || defined malloc) \
00298          && (defined YYFREE || defined free)))
00299 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
00300 #   ifndef _STDLIB_H
00301 #    define _STDLIB_H 1
00302 #   endif
00303 #  endif
00304 #  ifndef YYMALLOC
00305 #   define YYMALLOC malloc
00306 #   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00307      || defined __cplusplus || defined _MSC_VER)
00308 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
00309 #   endif
00310 #  endif
00311 #  ifndef YYFREE
00312 #   define YYFREE free
00313 #   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
00314      || defined __cplusplus || defined _MSC_VER)
00315 void free (void *); /* INFRINGES ON USER NAME SPACE */
00316 #   endif
00317 #  endif
00318 # endif
00319 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
00320 
00321 
00322 #if (! defined yyoverflow \
00323      && (! defined __cplusplus \
00324      || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
00325 
00326 /* A type that is properly aligned for any stack member.  */
00327 union yyalloc
00328 {
00329   yytype_int16 yyss;
00330   YYSTYPE yyvs;
00331   };
00332 
00333 /* The size of the maximum gap between one aligned stack and the next.  */
00334 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
00335 
00336 /* The size of an array large to enough to hold all stacks, each with
00337    N elements.  */
00338 # define YYSTACK_BYTES(N) \
00339      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
00340       + YYSTACK_GAP_MAXIMUM)
00341 
00342 /* Copy COUNT objects from FROM to TO.  The source and destination do
00343    not overlap.  */
00344 # ifndef YYCOPY
00345 #  if defined __GNUC__ && 1 < __GNUC__
00346 #   define YYCOPY(To, From, Count) \
00347       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
00348 #  else
00349 #   define YYCOPY(To, From, Count)      \
00350       do                    \
00351     {                   \
00352       YYSIZE_T yyi;             \
00353       for (yyi = 0; yyi < (Count); yyi++)   \
00354         (To)[yyi] = (From)[yyi];        \
00355     }                   \
00356       while (YYID (0))
00357 #  endif
00358 # endif
00359 
00360 /* Relocate STACK from its old location to the new one.  The
00361    local variables YYSIZE and YYSTACKSIZE give the old and new number of
00362    elements in the stack, and YYPTR gives the new location of the
00363    stack.  Advance YYPTR to a properly aligned location for the next
00364    stack.  */
00365 # define YYSTACK_RELOCATE(Stack)                    \
00366     do                                  \
00367       {                                 \
00368     YYSIZE_T yynewbytes;                        \
00369     YYCOPY (&yyptr->Stack, Stack, yysize);              \
00370     Stack = &yyptr->Stack;                      \
00371     yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
00372     yyptr += yynewbytes / sizeof (*yyptr);              \
00373       }                                 \
00374     while (YYID (0))
00375 
00376 #endif
00377 
00378 /* YYFINAL -- State number of the termination state.  */
00379 #define YYFINAL  4
00380 /* YYLAST -- Last index in YYTABLE.  */
00381 #define YYLAST   6
00382 
00383 /* YYNTOKENS -- Number of terminals.  */
00384 #define YYNTOKENS  8
00385 /* YYNNTS -- Number of nonterminals.  */
00386 #define YYNNTS  4
00387 /* YYNRULES -- Number of rules.  */
00388 #define YYNRULES  6
00389 /* YYNRULES -- Number of states.  */
00390 #define YYNSTATES  11
00391 
00392 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
00393 #define YYUNDEFTOK  2
00394 #define YYMAXUTOK   262
00395 
00396 #define YYTRANSLATE(YYX)                        \
00397   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
00398 
00399 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
00400 static const yytype_uint8 yytranslate[] =
00401 {
00402        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00403        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00404        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00405        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00406        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00407        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00408        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00409        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00410        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00411        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00412        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00413        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00414        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00415        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00416        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00417        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00418        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00419        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00420        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00421        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00422        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00423        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00424        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00425        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00426        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00427        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
00428        5,     6,     7
00429 };
00430 
00431 #if YYDEBUG
00432 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
00433    YYRHS.  */
00434 static const yytype_uint8 yyprhs[] =
00435 {
00436        0,     0,     3,     8,     9,    13,    17
00437 };
00438 
00439 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
00440 static const yytype_int8 yyrhs[] =
00441 {
00442        9,     0,    -1,     4,    10,     3,     5,    -1,    -1,    10,
00443       11,     7,    -1,     3,     6,     3,    -1,     3,     6,    -1
00444 };
00445 
00446 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
00447 static const yytype_uint8 yyrline[] =
00448 {
00449        0,    45,    45,    53,    55,    58,    63
00450 };
00451 #endif
00452 
00453 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
00454 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
00455    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
00456 static const char *const yytname[] =
00457 {
00458   "$end", "error", "$undefined", "STRING", "LBRACE", "RBRACE", "EQ",
00459   "COMMA", "$accept", "msg", "avpairlist", "avpair", 0
00460 };
00461 #endif
00462 
00463 # ifdef YYPRINT
00464 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
00465    token YYLEX-NUM.  */
00466 static const yytype_uint16 yytoknum[] =
00467 {
00468        0,   256,   257,   258,   259,   260,   261,   262
00469 };
00470 # endif
00471 
00472 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
00473 static const yytype_uint8 yyr1[] =
00474 {
00475        0,     8,     9,    10,    10,    11,    11
00476 };
00477 
00478 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
00479 static const yytype_uint8 yyr2[] =
00480 {
00481        0,     2,     4,     0,     3,     3,     2
00482 };
00483 
00484 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
00485    STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
00486    means the default is an error.  */
00487 static const yytype_uint8 yydefact[] =
00488 {
00489        0,     3,     0,     0,     1,     0,     0,     2,     6,     4,
00490        5
00491 };
00492 
00493 /* YYDEFGOTO[NTERM-NUM].  */
00494 static const yytype_int8 yydefgoto[] =
00495 {
00496       -1,     2,     3,     6
00497 };
00498 
00499 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
00500    STATE-NUM.  */
00501 #define YYPACT_NINF -6
00502 static const yytype_int8 yypact[] =
00503 {
00504       -2,    -6,     3,     1,    -6,    -5,    -1,    -6,     2,    -6,
00505       -6
00506 };
00507 
00508 /* YYPGOTO[NTERM-NUM].  */
00509 static const yytype_int8 yypgoto[] =
00510 {
00511       -6,    -6,    -6,    -6
00512 };
00513 
00514 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
00515    positive, shift that token.  If negative, reduce the rule which
00516    number is the opposite.  If zero, do what YYDEFACT says.
00517    If YYTABLE_NINF, syntax error.  */
00518 #define YYTABLE_NINF -1
00519 static const yytype_uint8 yytable[] =
00520 {
00521        7,     8,     1,     4,     5,    10,     9
00522 };
00523 
00524 static const yytype_uint8 yycheck[] =
00525 {
00526        5,     6,     4,     0,     3,     3,     7
00527 };
00528 
00529 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
00530    symbol of state STATE-NUM.  */
00531 static const yytype_uint8 yystos[] =
00532 {
00533        0,     4,     9,    10,     0,     3,    11,     5,     6,     7,
00534        3
00535 };
00536 
00537 #define yyerrok     (yyerrstatus = 0)
00538 #define yyclearin   (yychar = YYEMPTY)
00539 #define YYEMPTY     (-2)
00540 #define YYEOF       0
00541 
00542 #define YYACCEPT    goto yyacceptlab
00543 #define YYABORT     goto yyabortlab
00544 #define YYERROR     goto yyerrorlab
00545 
00546 
00547 /* Like YYERROR except do call yyerror.  This remains here temporarily
00548    to ease the transition to the new meaning of YYERROR, for GCC.
00549    Once GCC version 2 has supplanted version 1, this can go.  */
00550 
00551 #define YYFAIL      goto yyerrlab
00552 
00553 #define YYRECOVERING()  (!!yyerrstatus)
00554 
00555 #define YYBACKUP(Token, Value)                  \
00556 do                              \
00557   if (yychar == YYEMPTY && yylen == 1)              \
00558     {                               \
00559       yychar = (Token);                     \
00560       yylval = (Value);                     \
00561       yytoken = YYTRANSLATE (yychar);               \
00562       YYPOPSTACK (1);                       \
00563       goto yybackup;                        \
00564     }                               \
00565   else                              \
00566     {                               \
00567       yyerror (YY_("syntax error: cannot back up")); \
00568       YYERROR;                          \
00569     }                               \
00570 while (YYID (0))
00571 
00572 
00573 #define YYTERROR    1
00574 #define YYERRCODE   256
00575 
00576 
00577 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
00578    If N is 0, then set CURRENT to the empty location which ends
00579    the previous symbol: RHS[0] (always defined).  */
00580 
00581 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
00582 #ifndef YYLLOC_DEFAULT
00583 # define YYLLOC_DEFAULT(Current, Rhs, N)                \
00584     do                                  \
00585       if (YYID (N))                                                    \
00586     {                               \
00587       (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;    \
00588       (Current).first_column = YYRHSLOC (Rhs, 1).first_column;  \
00589       (Current).last_line    = YYRHSLOC (Rhs, N).last_line;     \
00590       (Current).last_column  = YYRHSLOC (Rhs, N).last_column;   \
00591     }                               \
00592       else                              \
00593     {                               \
00594       (Current).first_line   = (Current).last_line   =      \
00595         YYRHSLOC (Rhs, 0).last_line;                \
00596       (Current).first_column = (Current).last_column =      \
00597         YYRHSLOC (Rhs, 0).last_column;              \
00598     }                               \
00599     while (YYID (0))
00600 #endif
00601 
00602 
00603 /* YY_LOCATION_PRINT -- Print the location on the stream.
00604    This macro was not mandated originally: define only if we know
00605    we won't break user code: when these are the locations we know.  */
00606 
00607 #ifndef YY_LOCATION_PRINT
00608 # if YYLTYPE_IS_TRIVIAL
00609 #  define YY_LOCATION_PRINT(File, Loc)          \
00610      fprintf (File, "%d.%d-%d.%d",          \
00611           (Loc).first_line, (Loc).first_column, \
00612           (Loc).last_line,  (Loc).last_column)
00613 # else
00614 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
00615 # endif
00616 #endif
00617 
00618 
00619 /* YYLEX -- calling `yylex' with the right arguments.  */
00620 
00621 #ifdef YYLEX_PARAM
00622 # define YYLEX yylex (YYLEX_PARAM)
00623 #else
00624 # define YYLEX yylex ()
00625 #endif
00626 
00627 /* Enable debugging if requested.  */
00628 #if YYDEBUG
00629 
00630 # ifndef YYFPRINTF
00631 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
00632 #  define YYFPRINTF fprintf
00633 # endif
00634 
00635 # define YYDPRINTF(Args)            \
00636 do {                        \
00637   if (yydebug)                  \
00638     YYFPRINTF Args;             \
00639 } while (YYID (0))
00640 
00641 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)            \
00642 do {                                      \
00643   if (yydebug)                                \
00644     {                                     \
00645       YYFPRINTF (stderr, "%s ", Title);                   \
00646       yy_symbol_print (stderr,                        \
00647           Type, Value); \
00648       YYFPRINTF (stderr, "\n");                       \
00649     }                                     \
00650 } while (YYID (0))
00651 
00652 
00653 /*--------------------------------.
00654 | Print this symbol on YYOUTPUT.  |
00655 `--------------------------------*/
00656 
00657 /*ARGSUSED*/
00658 #if (defined __STDC__ || defined __C99__FUNC__ \
00659      || defined __cplusplus || defined _MSC_VER)
00660 static void
00661 yy_symbol_value_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep)
00662 #else
00663 static void
00664 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
00665     FILE *yyoutput;
00666     int yytype;
00667     const YYSTYPE * const yyvaluep;
00668 #endif
00669 {
00670   if (!yyvaluep)
00671     return;
00672 # ifdef YYPRINT
00673   if (yytype < YYNTOKENS)
00674     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
00675 # else
00676   YYUSE (yyoutput);
00677 # endif
00678   switch (yytype)
00679     {
00680       default:
00681     break;
00682     }
00683 }
00684 
00685 
00686 /*--------------------------------.
00687 | Print this symbol on YYOUTPUT.  |
00688 `--------------------------------*/
00689 
00690 #if (defined __STDC__ || defined __C99__FUNC__ \
00691      || defined __cplusplus || defined _MSC_VER)
00692 static void
00693 yy_symbol_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep)
00694 #else
00695 static void
00696 yy_symbol_print (yyoutput, yytype, yyvaluep)
00697     FILE *yyoutput;
00698     int yytype;
00699     const YYSTYPE * const yyvaluep;
00700 #endif
00701 {
00702   if (yytype < YYNTOKENS)
00703     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
00704   else
00705     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
00706 
00707   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
00708   YYFPRINTF (yyoutput, ")");
00709 }
00710 
00711 /*------------------------------------------------------------------.
00712 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
00713 | TOP (included).                                                   |
00714 `------------------------------------------------------------------*/
00715 
00716 #if (defined __STDC__ || defined __C99__FUNC__ \
00717      || defined __cplusplus || defined _MSC_VER)
00718 static void
00719 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
00720 #else
00721 static void
00722 yy_stack_print (bottom, top)
00723     yytype_int16 *bottom;
00724     yytype_int16 *top;
00725 #endif
00726 {
00727   YYFPRINTF (stderr, "Stack now");
00728   for (; bottom <= top; ++bottom)
00729     YYFPRINTF (stderr, " %d", *bottom);
00730   YYFPRINTF (stderr, "\n");
00731 }
00732 
00733 # define YY_STACK_PRINT(Bottom, Top)                \
00734 do {                                \
00735   if (yydebug)                          \
00736     yy_stack_print ((Bottom), (Top));               \
00737 } while (YYID (0))
00738 
00739 
00740 /*------------------------------------------------.
00741 | Report that the YYRULE is going to be reduced.  |
00742 `------------------------------------------------*/
00743 
00744 #if (defined __STDC__ || defined __C99__FUNC__ \
00745      || defined __cplusplus || defined _MSC_VER)
00746 static void
00747 yy_reduce_print (YYSTYPE *yyvsp, 
00748            int yyrule)
00749 #else
00750 static void
00751 yy_reduce_print (yyvsp, yyrule
00752            )
00753     YYSTYPE *yyvsp;
00754     
00755            int yyrule;
00756 #endif
00757 {
00758   int yynrhs = yyr2[yyrule];
00759   int yyi;
00760   unsigned long int yylno = yyrline[yyrule];
00761   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
00762          yyrule - 1, yylno);
00763   /* The symbols being reduced.  */
00764   for (yyi = 0; yyi < yynrhs; yyi++)
00765     {
00766       fprintf (stderr, "   $%d = ", yyi + 1);
00767       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
00768                &(yyvsp[(yyi + 1) - (yynrhs)])
00769                            );
00770       fprintf (stderr, "\n");
00771     }
00772 }
00773 
00774 # define YY_REDUCE_PRINT(Rule)      \
00775 do {                    \
00776   if (yydebug)              \
00777     yy_reduce_print (yyvsp, Rule); \
00778 } while (YYID (0))
00779 
00780 /* Nonzero means print parse trace.  It is left uninitialized so that
00781    multiple parsers can coexist.  */
00782 int yydebug;
00783 #else /* !YYDEBUG */
00784 # define YYDPRINTF(Args)
00785 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
00786 # define YY_STACK_PRINT(Bottom, Top)
00787 # define YY_REDUCE_PRINT(Rule)
00788 #endif /* !YYDEBUG */
00789 
00790 
00791 /* YYINITDEPTH -- initial size of the parser's stacks.  */
00792 #ifndef YYINITDEPTH
00793 # define YYINITDEPTH 200
00794 #endif
00795 
00796 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
00797    if the built-in stack extension method is used).
00798 
00799    Do not make this value too large; the results are undefined if
00800    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
00801    evaluated with infinite-precision integer arithmetic.  */
00802 
00803 #ifndef YYMAXDEPTH
00804 # define YYMAXDEPTH 10000
00805 #endif
00806 
00807 
00808 
00809 #if YYERROR_VERBOSE
00810 
00811 # ifndef yystrlen
00812 #  if defined __GLIBC__ && defined _STRING_H
00813 #   define yystrlen strlen
00814 #  else
00815 /* Return the length of YYSTR.  */
00816 #if (defined __STDC__ || defined __C99__FUNC__ \
00817      || defined __cplusplus || defined _MSC_VER)
00818 static YYSIZE_T
00819 yystrlen (const char *yystr)
00820 #else
00821 static YYSIZE_T
00822 yystrlen (yystr)
00823     const char *yystr;
00824 #endif
00825 {
00826   YYSIZE_T yylen;
00827   for (yylen = 0; yystr[yylen]; yylen++)
00828     continue;
00829   return yylen;
00830 }
00831 #  endif
00832 # endif
00833 
00834 # ifndef yystpcpy
00835 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
00836 #   define yystpcpy stpcpy
00837 #  else
00838 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
00839    YYDEST.  */
00840 #if (defined __STDC__ || defined __C99__FUNC__ \
00841      || defined __cplusplus || defined _MSC_VER)
00842 static char *
00843 yystpcpy (char *yydest, const char *yysrc)
00844 #else
00845 static char *
00846 yystpcpy (yydest, yysrc)
00847     char *yydest;
00848     const char *yysrc;
00849 #endif
00850 {
00851   char *yyd = yydest;
00852   const char *yys = yysrc;
00853 
00854   while ((*yyd++ = *yys++) != '\0')
00855     continue;
00856 
00857   return yyd - 1;
00858 }
00859 #  endif
00860 # endif
00861 
00862 # ifndef yytnamerr
00863 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
00864    quotes and backslashes, so that it's suitable for yyerror.  The
00865    heuristic is that double-quoting is unnecessary unless the string
00866    contains an apostrophe, a comma, or backslash (other than
00867    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
00868    null, do not copy; instead, return the length of what the result
00869    would have been.  */
00870 static YYSIZE_T
00871 yytnamerr (char *yyres, const char *yystr)
00872 {
00873   if (*yystr == '"')
00874     {
00875       YYSIZE_T yyn = 0;
00876       char const *yyp = yystr;
00877 
00878       for (;;)
00879     switch (*++yyp)
00880       {
00881       case '\'':
00882       case ',':
00883         goto do_not_strip_quotes;
00884 
00885       case '\\':
00886         if (*++yyp != '\\')
00887           goto do_not_strip_quotes;
00888         /* Fall through.  */
00889       default:
00890         if (yyres)
00891           yyres[yyn] = *yyp;
00892         yyn++;
00893         break;
00894 
00895       case '"':
00896         if (yyres)
00897           yyres[yyn] = '\0';
00898         return yyn;
00899       }
00900     do_not_strip_quotes: ;
00901     }
00902 
00903   if (! yyres)
00904     return yystrlen (yystr);
00905 
00906   return yystpcpy (yyres, yystr) - yyres;
00907 }
00908 # endif
00909 
00910 /* Copy into YYRESULT an error message about the unexpected token
00911    YYCHAR while in state YYSTATE.  Return the number of bytes copied,
00912    including the terminating null byte.  If YYRESULT is null, do not
00913    copy anything; just return the number of bytes that would be
00914    copied.  As a special case, return 0 if an ordinary "syntax error"
00915    message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
00916    size calculation.  */
00917 static YYSIZE_T
00918 yysyntax_error (char *yyresult, int yystate, int yychar)
00919 {
00920   int yyn = yypact[yystate];
00921 
00922   if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
00923     return 0;
00924   else
00925     {
00926       int yytype = YYTRANSLATE (yychar);
00927       YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
00928       YYSIZE_T yysize = yysize0;
00929       YYSIZE_T yysize1;
00930       int yysize_overflow = 0;
00931       enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
00932       char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
00933       int yyx;
00934 
00935 # if 0
00936       /* This is so xgettext sees the translatable formats that are
00937      constructed on the fly.  */
00938       YY_("syntax error, unexpected %s");
00939       YY_("syntax error, unexpected %s, expecting %s");
00940       YY_("syntax error, unexpected %s, expecting %s or %s");
00941       YY_("syntax error, unexpected %s, expecting %s or %s or %s");
00942       YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
00943 # endif
00944       char *yyfmt;
00945       char const *yyf;
00946       static char const yyunexpected[] = "syntax error, unexpected %s";
00947       static char const yyexpecting[] = ", expecting %s";
00948       static char const yyor[] = " or %s";
00949       char yyformat[sizeof yyunexpected
00950             + sizeof yyexpecting - 1
00951             + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
00952                * (sizeof yyor - 1))];
00953       char const *yyprefix = yyexpecting;
00954 
00955       /* Start YYX at -YYN if negative to avoid negative indexes in
00956      YYCHECK.  */
00957       int yyxbegin = yyn < 0 ? -yyn : 0;
00958 
00959       /* Stay within bounds of both yycheck and yytname.  */
00960       int yychecklim = YYLAST - yyn + 1;
00961       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
00962       int yycount = 1;
00963 
00964       yyarg[0] = yytname[yytype];
00965       yyfmt = yystpcpy (yyformat, yyunexpected);
00966 
00967       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
00968     if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
00969       {
00970         if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
00971           {
00972         yycount = 1;
00973         yysize = yysize0;
00974         yyformat[sizeof yyunexpected - 1] = '\0';
00975         break;
00976           }
00977         yyarg[yycount++] = yytname[yyx];
00978         yysize1 = yysize + yytnamerr (0, yytname[yyx]);
00979         yysize_overflow |= (yysize1 < yysize);
00980         yysize = yysize1;
00981         yyfmt = yystpcpy (yyfmt, yyprefix);
00982         yyprefix = yyor;
00983       }
00984 
00985       yyf = YY_(yyformat);
00986       yysize1 = yysize + yystrlen (yyf);
00987       yysize_overflow |= (yysize1 < yysize);
00988       yysize = yysize1;
00989 
00990       if (yysize_overflow)
00991     return YYSIZE_MAXIMUM;
00992 
00993       if (yyresult)
00994     {
00995       /* Avoid sprintf, as that infringes on the user's name space.
00996          Don't have undefined behavior even if the translation
00997          produced a string with the wrong number of "%s"s.  */
00998       char *yyp = yyresult;
00999       int yyi = 0;
01000       while ((*yyp = *yyf) != '\0')
01001         {
01002           if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
01003         {
01004           yyp += yytnamerr (yyp, yyarg[yyi++]);
01005           yyf += 2;
01006         }
01007           else
01008         {
01009           yyp++;
01010           yyf++;
01011         }
01012         }
01013     }
01014       return yysize;
01015     }
01016 }
01017 #endif /* YYERROR_VERBOSE */
01018 
01019 
01020 /*-----------------------------------------------.
01021 | Release the memory associated to this symbol.  |
01022 `-----------------------------------------------*/
01023 
01024 /*ARGSUSED*/
01025 #if (defined __STDC__ || defined __C99__FUNC__ \
01026      || defined __cplusplus || defined _MSC_VER)
01027 static void
01028 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
01029 #else
01030 static void
01031 yydestruct (yymsg, yytype, yyvaluep)
01032     const char *yymsg;
01033     int yytype;
01034     YYSTYPE *yyvaluep;
01035 #endif
01036 {
01037   YYUSE (yyvaluep);
01038 
01039   if (!yymsg)
01040     yymsg = "Deleting";
01041   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
01042 
01043   switch (yytype)
01044     {
01045 
01046       default:
01047     break;
01048     }
01049 }
01050 
01051 
01052 /* Prevent warnings from -Wmissing-prototypes.  */
01053 
01054 #ifdef YYPARSE_PARAM
01055 #if defined __STDC__ || defined __cplusplus
01056 int yyparse (void *YYPARSE_PARAM);
01057 #else
01058 int yyparse ();
01059 #endif
01060 #else /* ! YYPARSE_PARAM */
01061 #if defined __STDC__ || defined __cplusplus
01062 int yyparse (void);
01063 #else
01064 int yyparse ();
01065 #endif
01066 #endif /* ! YYPARSE_PARAM */
01067 
01068 
01069 
01070 /* The look-ahead symbol.  */
01071 int yychar;
01072 
01073 /* The semantic value of the look-ahead symbol.  */
01074 YYSTYPE yylval;
01075 
01076 /* Number of syntax errors so far.  */
01077 int yynerrs;
01078 
01079 
01080 
01081 /*----------.
01082 | yyparse.  |
01083 `----------*/
01084 
01085 #ifdef YYPARSE_PARAM
01086 #if (defined __STDC__ || defined __C99__FUNC__ \
01087      || defined __cplusplus || defined _MSC_VER)
01088 int
01089 yyparse (void *YYPARSE_PARAM)
01090 #else
01091 int
01092 yyparse (YYPARSE_PARAM)
01093     void *YYPARSE_PARAM;
01094 #endif
01095 #else /* ! YYPARSE_PARAM */
01096 #if (defined __STDC__ || defined __C99__FUNC__ \
01097      || defined __cplusplus || defined _MSC_VER)
01098 int
01099 yyparse (void)
01100 #else
01101 int
01102 yyparse ()
01103 
01104 #endif
01105 #endif
01106 {
01107   
01108   int yystate;
01109   int yyn;
01110   int yyresult;
01111   /* Number of tokens to shift before error messages enabled.  */
01112   int yyerrstatus;
01113   /* Look-ahead token as an internal (translated) token number.  */
01114   int yytoken = 0;
01115 #if YYERROR_VERBOSE
01116   /* Buffer for error messages, and its allocated size.  */
01117   char yymsgbuf[128];
01118   char *yymsg = yymsgbuf;
01119   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
01120 #endif
01121 
01122   /* Three stacks and their tools:
01123      `yyss': related to states,
01124      `yyvs': related to semantic values,
01125      `yyls': related to locations.
01126 
01127      Refer to the stacks thru separate pointers, to allow yyoverflow
01128      to reallocate them elsewhere.  */
01129 
01130   /* The state stack.  */
01131   yytype_int16 yyssa[YYINITDEPTH];
01132   yytype_int16 *yyss = yyssa;
01133   yytype_int16 *yyssp;
01134 
01135   /* The semantic value stack.  */
01136   YYSTYPE yyvsa[YYINITDEPTH];
01137   YYSTYPE *yyvs = yyvsa;
01138   YYSTYPE *yyvsp;
01139 
01140 
01141 
01142 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
01143 
01144   YYSIZE_T yystacksize = YYINITDEPTH;
01145 
01146   /* The variables used to return semantic value and location from the
01147      action routines.  */
01148   YYSTYPE yyval;
01149 
01150 
01151   /* The number of symbols on the RHS of the reduced rule.
01152      Keep to zero when no symbol should be popped.  */
01153   int yylen = 0;
01154 
01155   YYDPRINTF ((stderr, "Starting parse\n"));
01156 
01157   yystate = 0;
01158   yyerrstatus = 0;
01159   yynerrs = 0;
01160   yychar = YYEMPTY;     /* Cause a token to be read.  */
01161 
01162   /* Initialize stack pointers.
01163      Waste one element of value and location stack
01164      so that they stay on the same level as the state stack.
01165      The wasted elements are never initialized.  */
01166 
01167   yyssp = yyss;
01168   yyvsp = yyvs;
01169 
01170   goto yysetstate;
01171 
01172 /*------------------------------------------------------------.
01173 | yynewstate -- Push a new state, which is found in yystate.  |
01174 `------------------------------------------------------------*/
01175  yynewstate:
01176   /* In all cases, when you get here, the value and location stacks
01177      have just been pushed.  So pushing a state here evens the stacks.  */
01178   yyssp++;
01179 
01180  yysetstate:
01181   *yyssp = yystate;
01182 
01183   if (yyss + yystacksize - 1 <= yyssp)
01184     {
01185       /* Get the current used size of the three stacks, in elements.  */
01186       YYSIZE_T yysize = yyssp - yyss + 1;
01187 
01188 #ifdef yyoverflow
01189       {
01190     /* Give user a chance to reallocate the stack.  Use copies of
01191        these so that the &'s don't force the real ones into
01192        memory.  */
01193     YYSTYPE *yyvs1 = yyvs;
01194     yytype_int16 *yyss1 = yyss;
01195 
01196 
01197     /* Each stack pointer address is followed by the size of the
01198        data in use in that stack, in bytes.  This used to be a
01199        conditional around just the two extra args, but that might
01200        be undefined if yyoverflow is a macro.  */
01201     yyoverflow (YY_("memory exhausted"),
01202             &yyss1, yysize * sizeof (*yyssp),
01203             &yyvs1, yysize * sizeof (*yyvsp),
01204 
01205             &yystacksize);
01206 
01207     yyss = yyss1;
01208     yyvs = yyvs1;
01209       }
01210 #else /* no yyoverflow */
01211 # ifndef YYSTACK_RELOCATE
01212       goto yyexhaustedlab;
01213 # else
01214       /* Extend the stack our own way.  */
01215       if (YYMAXDEPTH <= yystacksize)
01216     goto yyexhaustedlab;
01217       yystacksize *= 2;
01218       if (YYMAXDEPTH < yystacksize)
01219     yystacksize = YYMAXDEPTH;
01220 
01221       {
01222     yytype_int16 *yyss1 = yyss;
01223     union yyalloc *yyptr =
01224       (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01225     if (! yyptr)
01226       goto yyexhaustedlab;
01227     YYSTACK_RELOCATE (yyss);
01228     YYSTACK_RELOCATE (yyvs);
01229 
01230 #  undef YYSTACK_RELOCATE
01231     if (yyss1 != yyssa)
01232       YYSTACK_FREE (yyss1);
01233       }
01234 # endif
01235 #endif /* no yyoverflow */
01236 
01237       yyssp = yyss + yysize - 1;
01238       yyvsp = yyvs + yysize - 1;
01239 
01240 
01241       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01242           (unsigned long int) yystacksize));
01243 
01244       if (yyss + yystacksize - 1 <= yyssp)
01245     YYABORT;
01246     }
01247 
01248   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01249 
01250   goto yybackup;
01251 
01252 /*-----------.
01253 | yybackup.  |
01254 `-----------*/
01255 yybackup:
01256 
01257   /* Do appropriate processing given the current state.  Read a
01258      look-ahead token if we need one and don't already have one.  */
01259 
01260   /* First try to decide what to do without reference to look-ahead token.  */
01261   yyn = yypact[yystate];
01262   if (yyn == YYPACT_NINF)
01263     goto yydefault;
01264 
01265   /* Not known => get a look-ahead token if don't already have one.  */
01266 
01267   /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol.  */
01268   if (yychar == YYEMPTY)
01269     {
01270       YYDPRINTF ((stderr, "Reading a token: "));
01271       yychar = YYLEX;
01272     }
01273 
01274   if (yychar <= YYEOF)
01275     {
01276       yychar = yytoken = YYEOF;
01277       YYDPRINTF ((stderr, "Now at end of input.\n"));
01278     }
01279   else
01280     {
01281       yytoken = YYTRANSLATE (yychar);
01282       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
01283     }
01284 
01285   /* If the proper action on seeing token YYTOKEN is to reduce or to
01286      detect an error, take that action.  */
01287   yyn += yytoken;
01288   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01289     goto yydefault;
01290   yyn = yytable[yyn];
01291   if (yyn <= 0)
01292     {
01293       if (yyn == 0 || yyn == YYTABLE_NINF)
01294     goto yyerrlab;
01295       yyn = -yyn;
01296       goto yyreduce;
01297     }
01298 
01299   if (yyn == YYFINAL)
01300     YYACCEPT;
01301 
01302   /* Count tokens shifted since error; after three, turn off error
01303      status.  */
01304   if (yyerrstatus)
01305     yyerrstatus--;
01306 
01307   /* Shift the look-ahead token.  */
01308   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
01309 
01310   /* Discard the shifted token unless it is eof.  */
01311   if (yychar != YYEOF)
01312     yychar = YYEMPTY;
01313 
01314   yystate = yyn;
01315   *++yyvsp = yylval;
01316 
01317   goto yynewstate;
01318 
01319 
01320 /*-----------------------------------------------------------.
01321 | yydefault -- do the default action for the current state.  |
01322 `-----------------------------------------------------------*/
01323 yydefault:
01324   yyn = yydefact[yystate];
01325   if (yyn == 0)
01326     goto yyerrlab;
01327   goto yyreduce;
01328 
01329 
01330 /*-----------------------------.
01331 | yyreduce -- Do a reduction.  |
01332 `-----------------------------*/
01333 yyreduce:
01334   /* yyn is the number of a rule to reduce with.  */
01335   yylen = yyr2[yyn];
01336 
01337   /* If YYLEN is nonzero, implement the default value of the action:
01338      `$$ = $1'.
01339 
01340      Otherwise, the following line sets YYVAL to garbage.
01341      This behavior is undocumented and Bison
01342      users should not rely upon it.  Assigning to YYVAL
01343      unconditionally makes the parser a bit smaller, and it avoids a
01344      GCC warning that YYVAL may be used uninitialized.  */
01345   yyval = yyvsp[1-yylen];
01346 
01347 
01348   YY_REDUCE_PRINT (yyn);
01349   switch (yyn)
01350     {
01351         case 2:
01352 #line 46 "src/cframe_parser.y"
01353     {
01354             errno = 0;
01355             cdata->checksum = strtol((yyvsp[(3) - (4)].string), NULL, 16);
01356             ASSERT_EQUAL(errno, 0);
01357             free((yyvsp[(3) - (4)].string));
01358         }
01359     break;
01360 
01361   case 5:
01362 #line 59 "src/cframe_parser.y"
01363     {
01364             parse_avpair(cdata, (yyvsp[(1) - (3)].string), (yyvsp[(3) - (3)].string));
01365             free((yyvsp[(1) - (3)].string)); free((yyvsp[(3) - (3)].string));
01366         }
01367     break;
01368 
01369   case 6:
01370 #line 64 "src/cframe_parser.y"
01371     {
01372             parse_avpair(cdata, (yyvsp[(1) - (2)].string), "");
01373             free((yyvsp[(1) - (2)].string));
01374         }
01375     break;
01376 
01377 
01378 /* Line 1267 of yacc.c.  */
01379 #line 1380 "src/cframe_parser.tab.c"
01380       default: break;
01381     }
01382   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
01383 
01384   YYPOPSTACK (yylen);
01385   yylen = 0;
01386   YY_STACK_PRINT (yyss, yyssp);
01387 
01388   *++yyvsp = yyval;
01389 
01390 
01391   /* Now `shift' the result of the reduction.  Determine what state
01392      that goes to, based on the state we popped back to and the rule
01393      number reduced by.  */
01394 
01395   yyn = yyr1[yyn];
01396 
01397   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
01398   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
01399     yystate = yytable[yystate];
01400   else
01401     yystate = yydefgoto[yyn - YYNTOKENS];
01402 
01403   goto yynewstate;
01404 
01405 
01406 /*------------------------------------.
01407 | yyerrlab -- here on detecting error |
01408 `------------------------------------*/
01409 yyerrlab:
01410   /* If not already recovering from an error, report this error.  */
01411   if (!yyerrstatus)
01412     {
01413       ++yynerrs;
01414 #if ! YYERROR_VERBOSE
01415       yyerror (YY_("syntax error"));
01416 #else
01417       {
01418     YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
01419     if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
01420       {
01421         YYSIZE_T yyalloc = 2 * yysize;
01422         if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
01423           yyalloc = YYSTACK_ALLOC_MAXIMUM;
01424         if (yymsg != yymsgbuf)
01425           YYSTACK_FREE (yymsg);
01426         yymsg = (char *) YYSTACK_ALLOC (yyalloc);
01427         if (yymsg)
01428           yymsg_alloc = yyalloc;
01429         else
01430           {
01431         yymsg = yymsgbuf;
01432         yymsg_alloc = sizeof yymsgbuf;
01433           }
01434       }
01435 
01436     if (0 < yysize && yysize <= yymsg_alloc)
01437       {
01438         (void) yysyntax_error (yymsg, yystate, yychar);
01439         yyerror (yymsg);
01440       }
01441     else
01442       {
01443         yyerror (YY_("syntax error"));
01444         if (yysize != 0)
01445           goto yyexhaustedlab;
01446       }
01447       }
01448 #endif
01449     }
01450 
01451 
01452 
01453   if (yyerrstatus == 3)
01454     {
01455       /* If just tried and failed to reuse look-ahead token after an
01456      error, discard it.  */
01457 
01458       if (yychar <= YYEOF)
01459     {
01460       /* Return failure if at end of input.  */
01461       if (yychar == YYEOF)
01462         YYABORT;
01463     }
01464       else
01465     {
01466       yydestruct ("Error: discarding",
01467               yytoken, &yylval);
01468       yychar = YYEMPTY;
01469     }
01470     }
01471 
01472   /* Else will try to reuse look-ahead token after shifting the error
01473      token.  */
01474   goto yyerrlab1;
01475 
01476 
01477 /*---------------------------------------------------.
01478 | yyerrorlab -- error raised explicitly by YYERROR.  |
01479 `---------------------------------------------------*/
01480 yyerrorlab:
01481 
01482   /* Pacify compilers like GCC when the user code never invokes
01483      YYERROR and the label yyerrorlab therefore never appears in user
01484      code.  */
01485   if (/*CONSTCOND*/ 0)
01486      goto yyerrorlab;
01487 
01488   /* Do not reclaim the symbols of the rule which action triggered
01489      this YYERROR.  */
01490   YYPOPSTACK (yylen);
01491   yylen = 0;
01492   YY_STACK_PRINT (yyss, yyssp);
01493   yystate = *yyssp;
01494   goto yyerrlab1;
01495 
01496 
01497 /*-------------------------------------------------------------.
01498 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
01499 `-------------------------------------------------------------*/
01500 yyerrlab1:
01501   yyerrstatus = 3;  /* Each real token shifted decrements this.  */
01502 
01503   for (;;)
01504     {
01505       yyn = yypact[yystate];
01506       if (yyn != YYPACT_NINF)
01507     {
01508       yyn += YYTERROR;
01509       if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
01510         {
01511           yyn = yytable[yyn];
01512           if (0 < yyn)
01513         break;
01514         }
01515     }
01516 
01517       /* Pop the current state because it cannot handle the error token.  */
01518       if (yyssp == yyss)
01519     YYABORT;
01520 
01521 
01522       yydestruct ("Error: popping",
01523           yystos[yystate], yyvsp);
01524       YYPOPSTACK (1);
01525       yystate = *yyssp;
01526       YY_STACK_PRINT (yyss, yyssp);
01527     }
01528 
01529   if (yyn == YYFINAL)
01530     YYACCEPT;
01531 
01532   *++yyvsp = yylval;
01533 
01534 
01535   /* Shift the error token.  */
01536   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
01537 
01538   yystate = yyn;
01539   goto yynewstate;
01540 
01541 
01542 /*-------------------------------------.
01543 | yyacceptlab -- YYACCEPT comes here.  |
01544 `-------------------------------------*/
01545 yyacceptlab:
01546   yyresult = 0;
01547   goto yyreturn;
01548 
01549 /*-----------------------------------.
01550 | yyabortlab -- YYABORT comes here.  |
01551 `-----------------------------------*/
01552 yyabortlab:
01553   yyresult = 1;
01554   goto yyreturn;
01555 
01556 #ifndef yyoverflow
01557 /*-------------------------------------------------.
01558 | yyexhaustedlab -- memory exhaustion comes here.  |
01559 `-------------------------------------------------*/
01560 yyexhaustedlab:
01561   yyerror (YY_("memory exhausted"));
01562   yyresult = 2;
01563   /* Fall through.  */
01564 #endif
01565 
01566 yyreturn:
01567   if (yychar != YYEOF && yychar != YYEMPTY)
01568      yydestruct ("Cleanup: discarding lookahead",
01569          yytoken, &yylval);
01570   /* Do not reclaim the symbols of the rule which action triggered
01571      this YYABORT or YYACCEPT.  */
01572   YYPOPSTACK (yylen);
01573   YY_STACK_PRINT (yyss, yyssp);
01574   while (yyssp != yyss)
01575     {
01576       yydestruct ("Cleanup: popping",
01577           yystos[*yyssp], yyvsp);
01578       YYPOPSTACK (1);
01579     }
01580 #ifndef yyoverflow
01581   if (yyss != yyssa)
01582     YYSTACK_FREE (yyss);
01583 #endif
01584 #if YYERROR_VERBOSE
01585   if (yymsg != yymsgbuf)
01586     YYSTACK_FREE (yymsg);
01587 #endif
01588   return yyresult;
01589 }
01590 
01591 
01592 #line 68 "src/cframe_parser.y"
01593 
01594 
01595 // In the face of an invalid field value, we are universally going to just not
01596 // touch the cframe. This works out nice for some values and not so nice for
01597 // others, but in general it always works and is a predictable result that
01598 // doesn't create values that will blow up other things.
01599 void parse_avpair(cframe_t *cf, char *fieldName, char *fieldVal) {
01600     int ival;
01601     int valid_ival = 1;
01602     double dval;
01603     int valid_dval = 1;
01604     double nmeaval;
01605     int valid_nmeaval = 1;
01606 
01607     // Convert values over to different types and do error checking
01608     errno = 0;
01609     ival = strtol(fieldVal, NULL, 10);
01610     if(errno != 0)
01611         valid_ival = 0;
01612 
01613     errno = 0;
01614     dval = strtod(fieldVal, NULL);
01615     if(errno != 0)
01616         valid_dval = 0;
01617 
01618     nmeaval = nmea_to_deg(fieldVal);
01619     if(isnan(nmeaval))
01620         valid_nmeaval = 0;
01621 
01622     // Header
01623     if(!strcmp(fieldName, "MsgLength")) {
01624         if(valid_ival)
01625             cf->msg_len = ival;
01626         else
01627             DEBUG1("invalid ival for MsgLength");
01628     } else if(!strcmp(fieldName, "VehMsgCount")) {
01629         if(valid_ival)
01630             cf->seqno = ival;
01631         else
01632             DEBUG1("invalid ival for VehMsgCount");
01633     } else if(!strcmp(fieldName, "TimeStamp")) {
01634     if(valid_ival)
01635             cf->timestamp = ival;
01636         else
01637             DEBUG1("invalid ival for TimeStamp");
01638     }
01639 
01640     // Steering
01641     else if(!strcmp(fieldName, "CmdTurnRadius")) {
01642         if(valid_dval)
01643             cf->cmd_irad = dval;
01644         else
01645             DEBUG1("invalid dval for CmdTurnRadius");
01646     } else if(!strcmp(fieldName, "StatusTurnRadius")) {
01647         if(valid_dval)
01648             cf->cur_irad = dval;
01649         else
01650             DEBUG1("invalid dval for StatusTurnRadius");
01651     } else if(!strcmp(fieldName, "StatusSteeringPosLimitError")) {
01652         strncpy(cf->steer_limit_error, fieldVal,
01653                 sizeof(cf->steer_limit_error) - 1);
01654         cf->steer_limit_error[sizeof(cf->steer_limit_error) - 1] = 0;
01655     }
01656 
01657     // Speed
01658     else if(!strcmp(fieldName, "CmdVehSpeed")) {
01659         if(valid_dval)
01660             cf->cmd_speed = dval;
01661         else
01662             DEBUG1("invalid dval for CmdVehSpeed");
01663     } else if(!strcmp(fieldName, "StatusVehSpeed")) {
01664         if(valid_dval)
01665             cf->cur_speed = dval;
01666         else
01667             DEBUG1("invalid dval for StatusVehSpeed");
01668     } else if(!strcmp(fieldName, "StatusPercentThrottle")) {
01669         if(valid_dval)
01670             cf->cur_throttle = dval;
01671         else
01672             DEBUG1("invalid dval for StatusPercentThrottle");
01673     } else if(!strcmp(fieldName, "StatusVehSpeedLimitError")) {
01674         strncpy(cf->speed_limit_error, fieldVal,
01675                 sizeof(cf->speed_limit_error) - 1);
01676         cf->speed_limit_error[sizeof(cf->speed_limit_error) - 1] = 0;
01677     }
01678 
01679     // GPS
01680     else if(!strcmp(fieldName, "GPSLat")) {
01681         if(valid_nmeaval)
01682             cf->gps_lat = nmeaval;
01683         else
01684             DEBUG1("invalid nmeaval for GPSLat");
01685     } else if(!strcmp(fieldName, "GPSLon")) {
01686         if(valid_nmeaval)
01687             cf->gps_lon = nmeaval;
01688         else
01689             DEBUG1("invalid nmeaval for GPSLon");
01690     } else if(!strcmp(fieldName, "GPSSpdE")) {
01691         if(valid_dval)
01692             cf->gps_speed_east = dval;
01693         else
01694             DEBUG1("invalid dval for GPSSpdE");
01695     } else if(!strcmp(fieldName, "GPSSpdN")) {
01696         if(valid_dval)
01697             cf->gps_speed_north = dval;
01698         else
01699             DEBUG1("invalid dval for GPSSpdN");
01700      } else if(!strcmp(fieldName, "GPSEstimatedPositionError") ||
01701             !strcmp(fieldName, "GPSEstPositionError")) {
01702         if(valid_dval)
01703             cf->gps_epe = dval;
01704         else
01705             DEBUG1("invalid dval for GPSEstimatedPositionError");
01706     } else if(!strcmp(fieldName, "GPSStatus")) {
01707         strncpy(cf->gps_status, fieldVal, sizeof(cf->gps_status) - 1);
01708         cf->gps_status[sizeof(cf->gps_status) - 1] = 0;
01709     }
01710 
01711     // Connection status
01712     else if(!strcmp(fieldName, "StatusComm")) {
01713         strncpy(cf->status, fieldVal, sizeof(cf->status) - 1);
01714         cf->status[sizeof(cf->status) - 1] = 0;
01715     }
01716 
01717     // Desired system mode
01718     else if(!strcmp(fieldName, "CmdSystemMode")) {
01719         strncpy(cf->cmd_mode, fieldVal, sizeof(cf->cmd_mode) - 1);
01720         cf->cmd_mode[sizeof(cf->cmd_mode) - 1] = 0;
01721     }
01722 
01723     // System mode
01724     else if(!strcmp(fieldName, "StatusSystemMode")) {
01725         strncpy(cf->cur_mode, fieldVal, sizeof(cf->cur_mode) - 1);
01726         cf->cur_mode[sizeof(cf->cur_mode) - 1] = 0;
01727     }
01728 
01729     // Error code
01730     else if(!strcmp(fieldName, "StatusErrorCode")) {
01731         if(valid_ival)
01732             cf->error_code = ival;
01733         else
01734             DEBUG1("invalid ival for StatusErrorCode");
01735     }
01736 
01737     else
01738         DEBUG1("unexpected attribute: %s", fieldName);
01739 }
01740 
01741 int parse_msg(cframe_t *cf, char *msg) {
01742     int result;
01743     YY_BUFFER_STATE buf;
01744 
01745     buf = cframe_scan_string(msg);
01746     result = yyparse(cf);
01747     cframe_delete_buffer(buf);
01748 
01749     return result;
01750 }
01751 

Generated on Thu Sep 6 13:13:10 2007 for driver by  doxygen 1.3.9.1