cyendra

Azarath Metrion Zinthos

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

flex

 1 %{
 2 #include <stdio.h>
 3 #include "mycalc.tab.h"
 4 
 5 int yywrap(void) {return 1;}
 6 %}
 7 
 8 %%
 9 
10 "+"    return ADD;
11 "-"    return SUB;
12 "*"    return MUL;
13 "/"    return DIV;
14 "("    return LP;
15 ")"    return RP;
16 "\n"   return CR;
17 ([1-9][0-9]*)|0|([0-9]+\.[0-9]+) {
18     double temp;
19     sscanf(yytext, "%lf", &temp);
20     yylval.double_value = temp;
21     return DOUBLE_LITERAL;
22 }
23 [ \t] ;
24 . {
25     fprintf(stderr, "lexical error.\n");
26     exit(1);
27 }
28 
29 %%

bison

 1 %{
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4 #define YYDEBUG 1
 5 %}
 6 %union {
 7     int int_value;
 8     double double_value;
 9 }
10 %token <double_value> DOUBLE_LITERAL
11 %token ADD SUB MUL DIV CR LP RP
12 %type <double_value> expression term primary_expression
13 
14 %%
15 
16 line_list
17     : line
18     | line_list line
19     ;
20 line
21     : expression CR
22     {
23         printf(">>%lf\n", $1);
24     }
25 expression
26     : term
27     | expression ADD term
28     {
29         $$ = $1 + $3;
30     }
31     | expression SUB term
32     {
33         $$ = $1 - $3;
34     }
35     ;
36 term
37     : primary_expression
38     | term MUL primary_expression
39     {
40         $$ = $1 * $3;
41     }
42     | term DIV primary_expression
43     {
44         $$ = $1 / $3;
45     }
46     ;
47 primary_expression
48     : DOUBLE_LITERAL
49     | SUB primary_expression
50     {
51         $$ = -$2;
52     }
53     | LP expression RP
54     {
55         $$ = $2;
56     }
57    ;
58 
59 %%
60 
61 int yyerror(char const *str) 
62 {
63     extern char *yytext;
64     fprintf(stderr, "parser error near %s\n", yytext);
65     return 0;
66 }
67 
68 int main()
69 {
70     extern int yyparse(void);
71     extern FILE *yyin;
72     yyin = stdin;
73     if (yyparse()) 
74     {
75         fprintf(stderr, "Error ! Error! Error!\n");
76         exit(1);
77     }
78     return 0;
79 }

bison -dv mycalc.y

flex mycalc.l

cc -o mycalc mycalc.tab.c lex.yy.c

 

 1 /* A Bison parser, made by GNU Bison 3.0.2.  */
 2 
 3 /* Bison interface for Yacc-like parsers in C
 4 
 5    Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
 6 
 7    This program is free software: you can redistribute it and/or modify
 8    it under the terms of the GNU General Public License as published by
 9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29 
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32 
33 #ifndef YY_YY_MYCALC_TAB_H_INCLUDED
34 # define YY_YY_MYCALC_TAB_H_INCLUDED
35 /* Debug traces.  */
36 #ifndef YYDEBUG
37 # define YYDEBUG 0
38 #endif
39 #if YYDEBUG
40 extern int yydebug;
41 #endif
42 
43 /* Token type.  */
44 #ifndef YYTOKENTYPE
45 # define YYTOKENTYPE
46   enum yytokentype
47   {
48     DOUBLE_LITERAL = 258,
49     ADD = 259,
50     SUB = 260,
51     MUL = 261,
52     DIV = 262,
53     CR = 263,
54     LP = 264,
55     RP = 265
56   };
57 #endif
58 
59 /* Value type.  */
60 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
61 typedef union YYSTYPE YYSTYPE;
62 union YYSTYPE
63 {
64 #line 6 "mycalc.y" /* yacc.c:1909  */
65 
66     int int_value;
67     double double_value;
68 
69 #line 70 "mycalc.tab.h" /* yacc.c:1909  */
70 };
71 # define YYSTYPE_IS_TRIVIAL 1
72 # define YYSTYPE_IS_DECLARED 1
73 #endif
74 
75 
76 extern YYSTYPE yylval;
77 
78 int yyparse (void);
79 
80 #endif /* !YY_YY_MYCALC_TAB_H_INCLUDED  */
mycalc.tab.h
   1 /* A Bison parser, made by GNU Bison 3.0.2.  */
   2 
   3 /* Bison implementation for Yacc-like parsers in C
   4 
   5    Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
   6 
   7    This program is free software: you can redistribute it and/or modify
   8    it under the terms of the GNU General Public License as published by
   9    the Free Software Foundation, either version 3 of the License, or
  10    (at your option) any later version.
  11 
  12    This program is distributed in the hope that it will be useful,
  13    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15    GNU General Public License for more details.
  16 
  17    You should have received a copy of the GNU General Public License
  18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
  19 
  20 /* As a special exception, you may create a larger work that contains
  21    part or all of the Bison parser skeleton and distribute that work
  22    under terms of your choice, so long as that work isn't itself a
  23    parser generator using the skeleton or a modified version thereof
  24    as a parser skeleton.  Alternatively, if you modify or redistribute
  25    the parser skeleton itself, you may (at your option) remove this
  26    special exception, which will cause the skeleton and the resulting
  27    Bison output files to be licensed under the GNU General Public
  28    License without this special exception.
  29 
  30    This special exception was added by the Free Software Foundation in
  31    version 2.2 of Bison.  */
  32 
  33 /* C LALR(1) parser skeleton written by Richard Stallman, by
  34    simplifying the original so-called "semantic" parser.  */
  35 
  36 /* All symbols defined below should begin with yy or YY, to avoid
  37    infringing on user name space.  This should be done even for local
  38    variables, as they might otherwise be expanded by user macros.
  39    There are some unavoidable exceptions within include files to
  40    define necessary library symbols; they are noted "INFRINGES ON
  41    USER NAME SPACE" below.  */
  42 
  43 /* Identify Bison output.  */
  44 #define YYBISON 1
  45 
  46 /* Bison version.  */
  47 #define YYBISON_VERSION "3.0.2"
  48 
  49 /* Skeleton name.  */
  50 #define YYSKELETON_NAME "yacc.c"
  51 
  52 /* Pure parsers.  */
  53 #define YYPURE 0
  54 
  55 /* Push parsers.  */
  56 #define YYPUSH 0
  57 
  58 /* Pull parsers.  */
  59 #define YYPULL 1
  60 
  61 
  62 
  63 
  64 /* Copy the first part of user declarations.  */
  65 #line 1 "mycalc.y" /* yacc.c:339  */
  66 
  67 #include <stdio.h>
  68 #include <stdlib.h>
  69 #define YYDEBUG 1
  70 
  71 #line 72 "mycalc.tab.c" /* yacc.c:339  */
  72 
  73 # ifndef YY_NULLPTR
  74 #  if defined __cplusplus && 201103L <= __cplusplus
  75 #   define YY_NULLPTR nullptr
  76 #  else
  77 #   define YY_NULLPTR 0
  78 #  endif
  79 # endif
  80 
  81 /* Enabling verbose error messages.  */
  82 #ifdef YYERROR_VERBOSE
  83 # undef YYERROR_VERBOSE
  84 # define YYERROR_VERBOSE 1
  85 #else
  86 # define YYERROR_VERBOSE 0
  87 #endif
  88 
  89 /* In a future release of Bison, this section will be replaced
  90    by #include "mycalc.tab.h".  */
  91 #ifndef YY_YY_MYCALC_TAB_H_INCLUDED
  92 # define YY_YY_MYCALC_TAB_H_INCLUDED
  93 /* Debug traces.  */
  94 #ifndef YYDEBUG
  95 # define YYDEBUG 0
  96 #endif
  97 #if YYDEBUG
  98 extern int yydebug;
  99 #endif
 100 
 101 /* Token type.  */
 102 #ifndef YYTOKENTYPE
 103 # define YYTOKENTYPE
 104   enum yytokentype
 105   {
 106     DOUBLE_LITERAL = 258,
 107     ADD = 259,
 108     SUB = 260,
 109     MUL = 261,
 110     DIV = 262,
 111     CR = 263,
 112     LP = 264,
 113     RP = 265
 114   };
 115 #endif
 116 
 117 /* Value type.  */
 118 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 119 typedef union YYSTYPE YYSTYPE;
 120 union YYSTYPE
 121 {
 122 #line 6 "mycalc.y" /* yacc.c:355  */
 123 
 124     int int_value;
 125     double double_value;
 126 
 127 #line 128 "mycalc.tab.c" /* yacc.c:355  */
 128 };
 129 # define YYSTYPE_IS_TRIVIAL 1
 130 # define YYSTYPE_IS_DECLARED 1
 131 #endif
 132 
 133 
 134 extern YYSTYPE yylval;
 135 
 136 int yyparse (void);
 137 
 138 #endif /* !YY_YY_MYCALC_TAB_H_INCLUDED  */
 139 
 140 /* Copy the second part of user declarations.  */
 141 
 142 #line 143 "mycalc.tab.c" /* yacc.c:358  */
 143 
 144 #ifdef short
 145 # undef short
 146 #endif
 147 
 148 #ifdef YYTYPE_UINT8
 149 typedef YYTYPE_UINT8 yytype_uint8;
 150 #else
 151 typedef unsigned char yytype_uint8;
 152 #endif
 153 
 154 #ifdef YYTYPE_INT8
 155 typedef YYTYPE_INT8 yytype_int8;
 156 #else
 157 typedef signed char yytype_int8;
 158 #endif
 159 
 160 #ifdef YYTYPE_UINT16
 161 typedef YYTYPE_UINT16 yytype_uint16;
 162 #else
 163 typedef unsigned short int yytype_uint16;
 164 #endif
 165 
 166 #ifdef YYTYPE_INT16
 167 typedef YYTYPE_INT16 yytype_int16;
 168 #else
 169 typedef short int yytype_int16;
 170 #endif
 171 
 172 #ifndef YYSIZE_T
 173 # ifdef __SIZE_TYPE__
 174 #  define YYSIZE_T __SIZE_TYPE__
 175 # elif defined size_t
 176 #  define YYSIZE_T size_t
 177 # elif ! defined YYSIZE_T
 178 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
 179 #  define YYSIZE_T size_t
 180 # else
 181 #  define YYSIZE_T unsigned int
 182 # endif
 183 #endif
 184 
 185 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
 186 
 187 #ifndef YY_
 188 # if defined YYENABLE_NLS && YYENABLE_NLS
 189 #  if ENABLE_NLS
 190 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
 191 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
 192 #  endif
 193 # endif
 194 # ifndef YY_
 195 #  define YY_(Msgid) Msgid
 196 # endif
 197 #endif
 198 
 199 #ifndef YY_ATTRIBUTE
 200 # if (defined __GNUC__                                               \
 201       && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
 202      || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
 203 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
 204 # else
 205 #  define YY_ATTRIBUTE(Spec) /* empty */
 206 # endif
 207 #endif
 208 
 209 #ifndef YY_ATTRIBUTE_PURE
 210 # define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
 211 #endif
 212 
 213 #ifndef YY_ATTRIBUTE_UNUSED
 214 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
 215 #endif
 216 
 217 #if !defined _Noreturn \
 218      && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
 219 # if defined _MSC_VER && 1200 <= _MSC_VER
 220 #  define _Noreturn __declspec (noreturn)
 221 # else
 222 #  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
 223 # endif
 224 #endif
 225 
 226 /* Suppress unused-variable warnings by "using" E.  */
 227 #if ! defined lint || defined __GNUC__
 228 # define YYUSE(E) ((void) (E))
 229 #else
 230 # define YYUSE(E) /* empty */
 231 #endif
 232 
 233 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
 234 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
 235 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
 236     _Pragma ("GCC diagnostic push") \
 237     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
 238     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
 239 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
 240     _Pragma ("GCC diagnostic pop")
 241 #else
 242 # define YY_INITIAL_VALUE(Value) Value
 243 #endif
 244 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
 245 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
 246 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
 247 #endif
 248 #ifndef YY_INITIAL_VALUE
 249 # define YY_INITIAL_VALUE(Value) /* Nothing. */
 250 #endif
 251 
 252 
 253 #if ! defined yyoverflow || YYERROR_VERBOSE
 254 
 255 /* The parser invokes alloca or malloc; define the necessary symbols.  */
 256 
 257 # ifdef YYSTACK_USE_ALLOCA
 258 #  if YYSTACK_USE_ALLOCA
 259 #   ifdef __GNUC__
 260 #    define YYSTACK_ALLOC __builtin_alloca
 261 #   elif defined __BUILTIN_VA_ARG_INCR
 262 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
 263 #   elif defined _AIX
 264 #    define YYSTACK_ALLOC __alloca
 265 #   elif defined _MSC_VER
 266 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
 267 #    define alloca _alloca
 268 #   else
 269 #    define YYSTACK_ALLOC alloca
 270 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
 271 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
 272       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
 273 #     ifndef EXIT_SUCCESS
 274 #      define EXIT_SUCCESS 0
 275 #     endif
 276 #    endif
 277 #   endif
 278 #  endif
 279 # endif
 280 
 281 # ifdef YYSTACK_ALLOC
 282    /* Pacify GCC's 'empty if-body' warning.  */
 283 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
 284 #  ifndef YYSTACK_ALLOC_MAXIMUM
 285     /* The OS might guarantee only one guard page at the bottom of the stack,
 286        and a page size can be as small as 4096 bytes.  So we cannot safely
 287        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
 288        to allow for a few compiler-allocated temporary stack slots.  */
 289 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
 290 #  endif
 291 # else
 292 #  define YYSTACK_ALLOC YYMALLOC
 293 #  define YYSTACK_FREE YYFREE
 294 #  ifndef YYSTACK_ALLOC_MAXIMUM
 295 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
 296 #  endif
 297 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
 298        && ! ((defined YYMALLOC || defined malloc) \
 299              && (defined YYFREE || defined free)))
 300 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
 301 #   ifndef EXIT_SUCCESS
 302 #    define EXIT_SUCCESS 0
 303 #   endif
 304 #  endif
 305 #  ifndef YYMALLOC
 306 #   define YYMALLOC malloc
 307 #   if ! defined malloc && ! defined EXIT_SUCCESS
 308 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
 309 #   endif
 310 #  endif
 311 #  ifndef YYFREE
 312 #   define YYFREE free
 313 #   if ! defined free && ! defined EXIT_SUCCESS
 314 void free (void *); /* INFRINGES ON USER NAME SPACE */
 315 #   endif
 316 #  endif
 317 # endif
 318 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
 319 
 320 
 321 #if (! defined yyoverflow \
 322      && (! defined __cplusplus \
 323          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
 324 
 325 /* A type that is properly aligned for any stack member.  */
 326 union yyalloc
 327 {
 328   yytype_int16 yyss_alloc;
 329   YYSTYPE yyvs_alloc;
 330 };
 331 
 332 /* The size of the maximum gap between one aligned stack and the next.  */
 333 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
 334 
 335 /* The size of an array large to enough to hold all stacks, each with
 336    N elements.  */
 337 # define YYSTACK_BYTES(N) \
 338      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
 339       + YYSTACK_GAP_MAXIMUM)
 340 
 341 # define YYCOPY_NEEDED 1
 342 
 343 /* Relocate STACK from its old location to the new one.  The
 344    local variables YYSIZE and YYSTACKSIZE give the old and new number of
 345    elements in the stack, and YYPTR gives the new location of the
 346    stack.  Advance YYPTR to a properly aligned location for the next
 347    stack.  */
 348 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
 349     do                                                                  \
 350       {                                                                 \
 351         YYSIZE_T yynewbytes;                                            \
 352         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
 353         Stack = &yyptr->Stack_alloc;                                    \
 354         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
 355         yyptr += yynewbytes / sizeof (*yyptr);                          \
 356       }                                                                 \
 357     while (0)
 358 
 359 #endif
 360 
 361 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
 362 /* Copy COUNT objects from SRC to DST.  The source and destination do
 363    not overlap.  */
 364 # ifndef YYCOPY
 365 #  if defined __GNUC__ && 1 < __GNUC__
 366 #   define YYCOPY(Dst, Src, Count) \
 367       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
 368 #  else
 369 #   define YYCOPY(Dst, Src, Count)              \
 370       do                                        \
 371         {                                       \
 372           YYSIZE_T yyi;                         \
 373           for (yyi = 0; yyi < (Count); yyi++)   \
 374             (Dst)[yyi] = (Src)[yyi];            \
 375         }                                       \
 376       while (0)
 377 #  endif
 378 # endif
 379 #endif /* !YYCOPY_NEEDED */
 380 
 381 /* YYFINAL -- State number of the termination state.  */
 382 #define YYFINAL  11
 383 /* YYLAST -- Last index in YYTABLE.  */
 384 #define YYLAST   22
 385 
 386 /* YYNTOKENS -- Number of terminals.  */
 387 #define YYNTOKENS  11
 388 /* YYNNTS -- Number of nonterminals.  */
 389 #define YYNNTS  6
 390 /* YYNRULES -- Number of rules.  */
 391 #define YYNRULES  13
 392 /* YYNSTATES -- Number of states.  */
 393 #define YYNSTATES  23
 394 
 395 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
 396    by yylex, with out-of-bounds checking.  */
 397 #define YYUNDEFTOK  2
 398 #define YYMAXUTOK   265
 399 
 400 #define YYTRANSLATE(YYX)                                                \
 401   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 402 
 403 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
 404    as returned by yylex, without out-of-bounds checking.  */
 405 static const yytype_uint8 yytranslate[] =
 406 {
 407        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 408        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 409        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 410        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 411        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 412        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 413        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 414        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 415        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 416        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 417        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 418        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 419        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 420        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 421        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 422        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 423        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 424        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 425        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 426        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 427        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 428        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 429        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 430        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 431        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 432        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
 433        5,     6,     7,     8,     9,    10
 434 };
 435 
 436 #if YYDEBUG
 437   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 438 static const yytype_uint8 yyrline[] =
 439 {
 440        0,    17,    17,    18,    21,    26,    27,    31,    37,    38,
 441       42,    48,    49,    53
 442 };
 443 #endif
 444 
 445 #if YYDEBUG || YYERROR_VERBOSE || 0
 446 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
 447    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
 448 static const char *const yytname[] =
 449 {
 450   "$end", "error", "$undefined", "DOUBLE_LITERAL", "ADD", "SUB", "MUL",
 451   "DIV", "CR", "LP", "RP", "$accept", "line_list", "line", "expression",
 452   "term", "primary_expression", YY_NULLPTR
 453 };
 454 #endif
 455 
 456 # ifdef YYPRINT
 457 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
 458    (internal) symbol number NUM (which must be that of a token).  */
 459 static const yytype_uint16 yytoknum[] =
 460 {
 461        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
 462      265
 463 };
 464 # endif
 465 
 466 #define YYPACT_NINF -3
 467 
 468 #define yypact_value_is_default(Yystate) \
 469   (!!((Yystate) == (-3)))
 470 
 471 #define YYTABLE_NINF -1
 472 
 473 #define yytable_value_is_error(Yytable_value) \
 474   0
 475 
 476   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
 477      STATE-NUM.  */
 478 static const yytype_int8 yypact[] =
 479 {
 480        0,    -3,     0,     0,     1,    -3,    12,     5,    -3,    -3,
 481        3,    -3,    -3,     0,     0,    -3,     0,     0,    -3,     5,
 482        5,    -3,    -3
 483 };
 484 
 485   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
 486      Performed when YYTABLE does not specify something else to do.  Zero
 487      means the default is an error.  */
 488 static const yytype_uint8 yydefact[] =
 489 {
 490        0,    11,     0,     0,     0,     2,     0,     5,     8,    12,
 491        0,     1,     3,     0,     0,     4,     0,     0,    13,     6,
 492        7,     9,    10
 493 };
 494 
 495   /* YYPGOTO[NTERM-NUM].  */
 496 static const yytype_int8 yypgoto[] =
 497 {
 498       -3,    -3,    14,    -1,     8,    -2
 499 };
 500 
 501   /* YYDEFGOTO[NTERM-NUM].  */
 502 static const yytype_int8 yydefgoto[] =
 503 {
 504       -1,     4,     5,     6,     7,     8
 505 };
 506 
 507   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
 508      positive, shift that token.  If negative, reduce the rule whose
 509      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 510 static const yytype_uint8 yytable[] =
 511 {
 512        9,    11,    10,     1,     1,     2,     2,    13,    14,     3,
 513        3,    16,    17,    18,    21,    22,    13,    14,    12,     0,
 514       15,    19,    20
 515 };
 516 
 517 static const yytype_int8 yycheck[] =
 518 {
 519        2,     0,     3,     3,     3,     5,     5,     4,     5,     9,
 520        9,     6,     7,    10,    16,    17,     4,     5,     4,    -1,
 521        8,    13,    14
 522 };
 523 
 524   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
 525      symbol of state STATE-NUM.  */
 526 static const yytype_uint8 yystos[] =
 527 {
 528        0,     3,     5,     9,    12,    13,    14,    15,    16,    16,
 529       14,     0,    13,     4,     5,     8,     6,     7,    10,    15,
 530       15,    16,    16
 531 };
 532 
 533   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 534 static const yytype_uint8 yyr1[] =
 535 {
 536        0,    11,    12,    12,    13,    14,    14,    14,    15,    15,
 537       15,    16,    16,    16
 538 };
 539 
 540   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
 541 static const yytype_uint8 yyr2[] =
 542 {
 543        0,     2,     1,     2,     2,     1,     3,     3,     1,     3,
 544        3,     1,     2,     3
 545 };
 546 
 547 
 548 #define yyerrok         (yyerrstatus = 0)
 549 #define yyclearin       (yychar = YYEMPTY)
 550 #define YYEMPTY         (-2)
 551 #define YYEOF           0
 552 
 553 #define YYACCEPT        goto yyacceptlab
 554 #define YYABORT         goto yyabortlab
 555 #define YYERROR         goto yyerrorlab
 556 
 557 
 558 #define YYRECOVERING()  (!!yyerrstatus)
 559 
 560 #define YYBACKUP(Token, Value)                                  \
 561 do                                                              \
 562   if (yychar == YYEMPTY)                                        \
 563     {                                                           \
 564       yychar = (Token);                                         \
 565       yylval = (Value);                                         \
 566       YYPOPSTACK (yylen);                                       \
 567       yystate = *yyssp;                                         \
 568       goto yybackup;                                            \
 569     }                                                           \
 570   else                                                          \
 571     {                                                           \
 572       yyerror (YY_("syntax error: cannot back up")); \
 573       YYERROR;                                                  \
 574     }                                                           \
 575 while (0)
 576 
 577 /* Error token number */
 578 #define YYTERROR        1
 579 #define YYERRCODE       256
 580 
 581 
 582 
 583 /* Enable debugging if requested.  */
 584 #if YYDEBUG
 585 
 586 # ifndef YYFPRINTF
 587 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
 588 #  define YYFPRINTF fprintf
 589 # endif
 590 
 591 # define YYDPRINTF(Args)                        \
 592 do {                                            \
 593   if (yydebug)                                  \
 594     YYFPRINTF Args;                             \
 595 } while (0)
 596 
 597 /* This macro is provided for backward compatibility. */
 598 #ifndef YY_LOCATION_PRINT
 599 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 600 #endif
 601 
 602 
 603 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
 604 do {                                                                      \
 605   if (yydebug)                                                            \
 606     {                                                                     \
 607       YYFPRINTF (stderr, "%s ", Title);                                   \
 608       yy_symbol_print (stderr,                                            \
 609                   Type, Value); \
 610       YYFPRINTF (stderr, "\n");                                           \
 611     }                                                                     \
 612 } while (0)
 613 
 614 
 615 /*----------------------------------------.
 616 | Print this symbol's value on YYOUTPUT.  |
 617 `----------------------------------------*/
 618 
 619 static void
 620 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
 621 {
 622   FILE *yyo = yyoutput;
 623   YYUSE (yyo);
 624   if (!yyvaluep)
 625     return;
 626 # ifdef YYPRINT
 627   if (yytype < YYNTOKENS)
 628     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 629 # endif
 630   YYUSE (yytype);
 631 }
 632 
 633 
 634 /*--------------------------------.
 635 | Print this symbol on YYOUTPUT.  |
 636 `--------------------------------*/
 637 
 638 static void
 639 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
 640 {
 641   YYFPRINTF (yyoutput, "%s %s (",
 642              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
 643 
 644   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
 645   YYFPRINTF (yyoutput, ")");
 646 }
 647 
 648 /*------------------------------------------------------------------.
 649 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
 650 | TOP (included).                                                   |
 651 `------------------------------------------------------------------*/
 652 
 653 static void
 654 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
 655 {
 656   YYFPRINTF (stderr, "Stack now");
 657   for (; yybottom <= yytop; yybottom++)
 658     {
 659       int yybot = *yybottom;
 660       YYFPRINTF (stderr, " %d", yybot);
 661     }
 662   YYFPRINTF (stderr, "\n");
 663 }
 664 
 665 # define YY_STACK_PRINT(Bottom, Top)                            \
 666 do {                                                            \
 667   if (yydebug)                                                  \
 668     yy_stack_print ((Bottom), (Top));                           \
 669 } while (0)
 670 
 671 
 672 /*------------------------------------------------.
 673 | Report that the YYRULE is going to be reduced.  |
 674 `------------------------------------------------*/
 675 
 676 static void
 677 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
 678 {
 679   unsigned long int yylno = yyrline[yyrule];
 680   int yynrhs = yyr2[yyrule];
 681   int yyi;
 682   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
 683              yyrule - 1, yylno);
 684   /* The symbols being reduced.  */
 685   for (yyi = 0; yyi < yynrhs; yyi++)
 686     {
 687       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
 688       yy_symbol_print (stderr,
 689                        yystos[yyssp[yyi + 1 - yynrhs]],
 690                        &(yyvsp[(yyi + 1) - (yynrhs)])
 691                                               );
 692       YYFPRINTF (stderr, "\n");
 693     }
 694 }
 695 
 696 # define YY_REDUCE_PRINT(Rule)          \
 697 do {                                    \
 698   if (yydebug)                          \
 699     yy_reduce_print (yyssp, yyvsp, Rule); \
 700 } while (0)
 701 
 702 /* Nonzero means print parse trace.  It is left uninitialized so that
 703    multiple parsers can coexist.  */
 704 int yydebug;
 705 #else /* !YYDEBUG */
 706 # define YYDPRINTF(Args)
 707 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
 708 # define YY_STACK_PRINT(Bottom, Top)
 709 # define YY_REDUCE_PRINT(Rule)
 710 #endif /* !YYDEBUG */
 711 
 712 
 713 /* YYINITDEPTH -- initial size of the parser's stacks.  */
 714 #ifndef YYINITDEPTH
 715 # define YYINITDEPTH 200
 716 #endif
 717 
 718 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
 719    if the built-in stack extension method is used).
 720 
 721    Do not make this value too large; the results are undefined if
 722    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
 723    evaluated with infinite-precision integer arithmetic.  */
 724 
 725 #ifndef YYMAXDEPTH
 726 # define YYMAXDEPTH 10000
 727 #endif
 728 
 729 
 730 #if YYERROR_VERBOSE
 731 
 732 # ifndef yystrlen
 733 #  if defined __GLIBC__ && defined _STRING_H
 734 #   define yystrlen strlen
 735 #  else
 736 /* Return the length of YYSTR.  */
 737 static YYSIZE_T
 738 yystrlen (const char *yystr)
 739 {
 740   YYSIZE_T yylen;
 741   for (yylen = 0; yystr[yylen]; yylen++)
 742     continue;
 743   return yylen;
 744 }
 745 #  endif
 746 # endif
 747 
 748 # ifndef yystpcpy
 749 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
 750 #   define yystpcpy stpcpy
 751 #  else
 752 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
 753    YYDEST.  */
 754 static char *
 755 yystpcpy (char *yydest, const char *yysrc)
 756 {
 757   char *yyd = yydest;
 758   const char *yys = yysrc;
 759 
 760   while ((*yyd++ = *yys++) != '\0')
 761     continue;
 762 
 763   return yyd - 1;
 764 }
 765 #  endif
 766 # endif
 767 
 768 # ifndef yytnamerr
 769 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
 770    quotes and backslashes, so that it's suitable for yyerror.  The
 771    heuristic is that double-quoting is unnecessary unless the string
 772    contains an apostrophe, a comma, or backslash (other than
 773    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
 774    null, do not copy; instead, return the length of what the result
 775    would have been.  */
 776 static YYSIZE_T
 777 yytnamerr (char *yyres, const char *yystr)
 778 {
 779   if (*yystr == '"')
 780     {
 781       YYSIZE_T yyn = 0;
 782       char const *yyp = yystr;
 783 
 784       for (;;)
 785         switch (*++yyp)
 786           {
 787           case '\'':
 788           case ',':
 789             goto do_not_strip_quotes;
 790 
 791           case '\\':
 792             if (*++yyp != '\\')
 793               goto do_not_strip_quotes;
 794             /* Fall through.  */
 795           default:
 796             if (yyres)
 797               yyres[yyn] = *yyp;
 798             yyn++;
 799             break;
 800 
 801           case '"':
 802             if (yyres)
 803               yyres[yyn] = '\0';
 804             return yyn;
 805           }
 806     do_not_strip_quotes: ;
 807     }
 808 
 809   if (! yyres)
 810     return yystrlen (yystr);
 811 
 812   return yystpcpy (yyres, yystr) - yyres;
 813 }
 814 # endif
 815 
 816 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
 817    about the unexpected token YYTOKEN for the state stack whose top is
 818    YYSSP.
 819 
 820    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
 821    not large enough to hold the message.  In that case, also set
 822    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
 823    required number of bytes is too large to store.  */
 824 static int
 825 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
 826                 yytype_int16 *yyssp, int yytoken)
 827 {
 828   YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
 829   YYSIZE_T yysize = yysize0;
 830   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
 831   /* Internationalized format string. */
 832   const char *yyformat = YY_NULLPTR;
 833   /* Arguments of yyformat. */
 834   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
 835   /* Number of reported tokens (one for the "unexpected", one per
 836      "expected"). */
 837   int yycount = 0;
 838 
 839   /* There are many possibilities here to consider:
 840      - If this state is a consistent state with a default action, then
 841        the only way this function was invoked is if the default action
 842        is an error action.  In that case, don't check for expected
 843        tokens because there are none.
 844      - The only way there can be no lookahead present (in yychar) is if
 845        this state is a consistent state with a default action.  Thus,
 846        detecting the absence of a lookahead is sufficient to determine
 847        that there is no unexpected or expected token to report.  In that
 848        case, just report a simple "syntax error".
 849      - Don't assume there isn't a lookahead just because this state is a
 850        consistent state with a default action.  There might have been a
 851        previous inconsistent state, consistent state with a non-default
 852        action, or user semantic action that manipulated yychar.
 853      - Of course, the expected token list depends on states to have
 854        correct lookahead information, and it depends on the parser not
 855        to perform extra reductions after fetching a lookahead from the
 856        scanner and before detecting a syntax error.  Thus, state merging
 857        (from LALR or IELR) and default reductions corrupt the expected
 858        token list.  However, the list is correct for canonical LR with
 859        one exception: it will still contain any token that will not be
 860        accepted due to an error action in a later state.
 861   */
 862   if (yytoken != YYEMPTY)
 863     {
 864       int yyn = yypact[*yyssp];
 865       yyarg[yycount++] = yytname[yytoken];
 866       if (!yypact_value_is_default (yyn))
 867         {
 868           /* Start YYX at -YYN if negative to avoid negative indexes in
 869              YYCHECK.  In other words, skip the first -YYN actions for
 870              this state because they are default actions.  */
 871           int yyxbegin = yyn < 0 ? -yyn : 0;
 872           /* Stay within bounds of both yycheck and yytname.  */
 873           int yychecklim = YYLAST - yyn + 1;
 874           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
 875           int yyx;
 876 
 877           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 878             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
 879                 && !yytable_value_is_error (yytable[yyx + yyn]))
 880               {
 881                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
 882                   {
 883                     yycount = 1;
 884                     yysize = yysize0;
 885                     break;
 886                   }
 887                 yyarg[yycount++] = yytname[yyx];
 888                 {
 889                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
 890                   if (! (yysize <= yysize1
 891                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
 892                     return 2;
 893                   yysize = yysize1;
 894                 }
 895               }
 896         }
 897     }
 898 
 899   switch (yycount)
 900     {
 901 # define YYCASE_(N, S)                      \
 902       case N:                               \
 903         yyformat = S;                       \
 904       break
 905       YYCASE_(0, YY_("syntax error"));
 906       YYCASE_(1, YY_("syntax error, unexpected %s"));
 907       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
 908       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
 909       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
 910       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
 911 # undef YYCASE_
 912     }
 913 
 914   {
 915     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
 916     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
 917       return 2;
 918     yysize = yysize1;
 919   }
 920 
 921   if (*yymsg_alloc < yysize)
 922     {
 923       *yymsg_alloc = 2 * yysize;
 924       if (! (yysize <= *yymsg_alloc
 925              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
 926         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
 927       return 1;
 928     }
 929 
 930   /* Avoid sprintf, as that infringes on the user's name space.
 931      Don't have undefined behavior even if the translation
 932      produced a string with the wrong number of "%s"s.  */
 933   {
 934     char *yyp = *yymsg;
 935     int yyi = 0;
 936     while ((*yyp = *yyformat) != '\0')
 937       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
 938         {
 939           yyp += yytnamerr (yyp, yyarg[yyi++]);
 940           yyformat += 2;
 941         }
 942       else
 943         {
 944           yyp++;
 945           yyformat++;
 946         }
 947   }
 948   return 0;
 949 }
 950 #endif /* YYERROR_VERBOSE */
 951 
 952 /*-----------------------------------------------.
 953 | Release the memory associated to this symbol.  |
 954 `-----------------------------------------------*/
 955 
 956 static void
 957 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
 958 {
 959   YYUSE (yyvaluep);
 960   if (!yymsg)
 961     yymsg = "Deleting";
 962   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
 963 
 964   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
 965   YYUSE (yytype);
 966   YY_IGNORE_MAYBE_UNINITIALIZED_END
 967 }
 968 
 969 
 970 
 971 
 972 /* The lookahead symbol.  */
 973 int yychar;
 974 
 975 /* The semantic value of the lookahead symbol.  */
 976 YYSTYPE yylval;
 977 /* Number of syntax errors so far.  */
 978 int yynerrs;
 979 
 980 
 981 /*----------.
 982 | yyparse.  |
 983 `----------*/
 984 
 985 int
 986 yyparse (void)
 987 {
 988     int yystate;
 989     /* Number of tokens to shift before error messages enabled.  */
 990     int yyerrstatus;
 991 
 992     /* The stacks and their tools:
 993        'yyss': related to states.
 994        'yyvs': related to semantic values.
 995 
 996        Refer to the stacks through separate pointers, to allow yyoverflow
 997        to reallocate them elsewhere.  */
 998 
 999     /* The state stack.  */
1000     yytype_int16 yyssa[YYINITDEPTH];
1001     yytype_int16 *yyss;
1002     yytype_int16 *yyssp;
1003 
1004     /* The semantic value stack.  */
1005     YYSTYPE yyvsa[YYINITDEPTH];
1006     YYSTYPE *yyvs;
1007     YYSTYPE *yyvsp;
1008 
1009     YYSIZE_T yystacksize;
1010 
1011   int yyn;
1012   int yyresult;
1013   /* Lookahead token as an internal (translated) token number.  */
1014   int yytoken = 0;
1015   /* The variables used to return semantic value and location from the
1016      action routines.  */
1017   YYSTYPE yyval;
1018 
1019 #if YYERROR_VERBOSE
1020   /* Buffer for error messages, and its allocated size.  */
1021   char yymsgbuf[128];
1022   char *yymsg = yymsgbuf;
1023   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1024 #endif
1025 
1026 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1027 
1028   /* The number of symbols on the RHS of the reduced rule.
1029      Keep to zero when no symbol should be popped.  */
1030   int yylen = 0;
1031 
1032   yyssp = yyss = yyssa;
1033   yyvsp = yyvs = yyvsa;
1034   yystacksize = YYINITDEPTH;
1035 
1036   YYDPRINTF ((stderr, "Starting parse\n"));
1037 
1038   yystate = 0;
1039   yyerrstatus = 0;
1040   yynerrs = 0;
1041   yychar = YYEMPTY; /* Cause a token to be read.  */
1042   goto yysetstate;
1043 
1044 /*------------------------------------------------------------.
1045 | yynewstate -- Push a new state, which is found in yystate.  |
1046 `------------------------------------------------------------*/
1047  yynewstate:
1048   /* In all cases, when you get here, the value and location stacks
1049      have just been pushed.  So pushing a state here evens the stacks.  */
1050   yyssp++;
1051 
1052  yysetstate:
1053   *yyssp = yystate;
1054 
1055   if (yyss + yystacksize - 1 <= yyssp)
1056     {
1057       /* Get the current used size of the three stacks, in elements.  */
1058       YYSIZE_T yysize = yyssp - yyss + 1;
1059 
1060 #ifdef yyoverflow
1061       {
1062         /* Give user a chance to reallocate the stack.  Use copies of
1063            these so that the &'s don't force the real ones into
1064            memory.  */
1065         YYSTYPE *yyvs1 = yyvs;
1066         yytype_int16 *yyss1 = yyss;
1067 
1068         /* Each stack pointer address is followed by the size of the
1069            data in use in that stack, in bytes.  This used to be a
1070            conditional around just the two extra args, but that might
1071            be undefined if yyoverflow is a macro.  */
1072         yyoverflow (YY_("memory exhausted"),
1073                     &yyss1, yysize * sizeof (*yyssp),
1074                     &yyvs1, yysize * sizeof (*yyvsp),
1075                     &yystacksize);
1076 
1077         yyss = yyss1;
1078         yyvs = yyvs1;
1079       }
1080 #else /* no yyoverflow */
1081 # ifndef YYSTACK_RELOCATE
1082       goto yyexhaustedlab;
1083 # else
1084       /* Extend the stack our own way.  */
1085       if (YYMAXDEPTH <= yystacksize)
1086         goto yyexhaustedlab;
1087       yystacksize *= 2;
1088       if (YYMAXDEPTH < yystacksize)
1089         yystacksize = YYMAXDEPTH;
1090 
1091       {
1092         yytype_int16 *yyss1 = yyss;
1093         union yyalloc *yyptr =
1094           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1095         if (! yyptr)
1096           goto yyexhaustedlab;
1097         YYSTACK_RELOCATE (yyss_alloc, yyss);
1098         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1099 #  undef YYSTACK_RELOCATE
1100         if (yyss1 != yyssa)
1101           YYSTACK_FREE (yyss1);
1102       }
1103 # endif
1104 #endif /* no yyoverflow */
1105 
1106       yyssp = yyss + yysize - 1;
1107       yyvsp = yyvs + yysize - 1;
1108 
1109       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1110                   (unsigned long int) yystacksize));
1111 
1112       if (yyss + yystacksize - 1 <= yyssp)
1113         YYABORT;
1114     }
1115 
1116   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1117 
1118   if (yystate == YYFINAL)
1119     YYACCEPT;
1120 
1121   goto yybackup;
1122 
1123 /*-----------.
1124 | yybackup.  |
1125 `-----------*/
1126 yybackup:
1127 
1128   /* Do appropriate processing given the current state.  Read a
1129      lookahead token if we need one and don't already have one.  */
1130 
1131   /* First try to decide what to do without reference to lookahead token.  */
1132   yyn = yypact[yystate];
1133   if (yypact_value_is_default (yyn))
1134     goto yydefault;
1135 
1136   /* Not known => get a lookahead token if don't already have one.  */
1137 
1138   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1139   if (yychar == YYEMPTY)
1140     {
1141       YYDPRINTF ((stderr, "Reading a token: "));
1142       yychar = yylex ();
1143     }
1144 
1145   if (yychar <= YYEOF)
1146     {
1147       yychar = yytoken = YYEOF;
1148       YYDPRINTF ((stderr, "Now at end of input.\n"));
1149     }
1150   else
1151     {
1152       yytoken = YYTRANSLATE (yychar);
1153       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1154     }
1155 
1156   /* If the proper action on seeing token YYTOKEN is to reduce or to
1157      detect an error, take that action.  */
1158   yyn += yytoken;
1159   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1160     goto yydefault;
1161   yyn = yytable[yyn];
1162   if (yyn <= 0)
1163     {
1164       if (yytable_value_is_error (yyn))
1165         goto yyerrlab;
1166       yyn = -yyn;
1167       goto yyreduce;
1168     }
1169 
1170   /* Count tokens shifted since error; after three, turn off error
1171      status.  */
1172   if (yyerrstatus)
1173     yyerrstatus--;
1174 
1175   /* Shift the lookahead token.  */
1176   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1177 
1178   /* Discard the shifted token.  */
1179   yychar = YYEMPTY;
1180 
1181   yystate = yyn;
1182   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1183   *++yyvsp = yylval;
1184   YY_IGNORE_MAYBE_UNINITIALIZED_END
1185 
1186   goto yynewstate;
1187 
1188 
1189 /*-----------------------------------------------------------.
1190 | yydefault -- do the default action for the current state.  |
1191 `-----------------------------------------------------------*/
1192 yydefault:
1193   yyn = yydefact[yystate];
1194   if (yyn == 0)
1195     goto yyerrlab;
1196   goto yyreduce;
1197 
1198 
1199 /*-----------------------------.
1200 | yyreduce -- Do a reduction.  |
1201 `-----------------------------*/
1202 yyreduce:
1203   /* yyn is the number of a rule to reduce with.  */
1204   yylen = yyr2[yyn];
1205 
1206   /* If YYLEN is nonzero, implement the default value of the action:
1207      '$$ = $1'.
1208 
1209      Otherwise, the following line sets YYVAL to garbage.
1210      This behavior is undocumented and Bison
1211      users should not rely upon it.  Assigning to YYVAL
1212      unconditionally makes the parser a bit smaller, and it avoids a
1213      GCC warning that YYVAL may be used uninitialized.  */
1214   yyval = yyvsp[1-yylen];
1215 
1216 
1217   YY_REDUCE_PRINT (yyn);
1218   switch (yyn)
1219     {
1220         case 4:
1221 #line 22 "mycalc.y" /* yacc.c:1646  */
1222     {
1223         printf(">>%lf\n", (yyvsp[-1].double_value));
1224     }
1225 #line 1226 "mycalc.tab.c" /* yacc.c:1646  */
1226     break;
1227 
1228   case 6:
1229 #line 28 "mycalc.y" /* yacc.c:1646  */
1230     {
1231         (yyval.double_value) = (yyvsp[-2].double_value) + (yyvsp[0].double_value);
1232     }
1233 #line 1234 "mycalc.tab.c" /* yacc.c:1646  */
1234     break;
1235 
1236   case 7:
1237 #line 32 "mycalc.y" /* yacc.c:1646  */
1238     {
1239         (yyval.double_value) = (yyvsp[-2].double_value) - (yyvsp[0].double_value);
1240     }
1241 #line 1242 "mycalc.tab.c" /* yacc.c:1646  */
1242     break;
1243 
1244   case 9:
1245 #line 39 "mycalc.y" /* yacc.c:1646  */
1246     {
1247         (yyval.double_value) = (yyvsp[-2].double_value) * (yyvsp[0].double_value);
1248     }
1249 #line 1250 "mycalc.tab.c" /* yacc.c:1646  */
1250     break;
1251 
1252   case 10:
1253 #line 43 "mycalc.y" /* yacc.c:1646  */
1254     {
1255         (yyval.double_value) = (yyvsp[-2].double_value) / (yyvsp[0].double_value);
1256     }
1257 #line 1258 "mycalc.tab.c" /* yacc.c:1646  */
1258     break;
1259 
1260   case 12:
1261 #line 50 "mycalc.y" /* yacc.c:1646  */
1262     {
1263         (yyval.double_value) = -(yyvsp[0].double_value);
1264     }
1265 #line 1266 "mycalc.tab.c" /* yacc.c:1646  */
1266     break;
1267 
1268   case 13:
1269 #line 54 "mycalc.y" /* yacc.c:1646  */
1270     {
1271         (yyval.double_value) = (yyvsp[-1].double_value);
1272     }
1273 #line 1274 "mycalc.tab.c" /* yacc.c:1646  */
1274     break;
1275 
1276 
1277 #line 1278 "mycalc.tab.c" /* yacc.c:1646  */
1278       default: break;
1279     }
1280   /* User semantic actions sometimes alter yychar, and that requires
1281      that yytoken be updated with the new translation.  We take the
1282      approach of translating immediately before every use of yytoken.
1283      One alternative is translating here after every semantic action,
1284      but that translation would be missed if the semantic action invokes
1285      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1286      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1287      incorrect destructor might then be invoked immediately.  In the
1288      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1289      to an incorrect destructor call or verbose syntax error message
1290      before the lookahead is translated.  */
1291   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1292 
1293   YYPOPSTACK (yylen);
1294   yylen = 0;
1295   YY_STACK_PRINT (yyss, yyssp);
1296 
1297   *++yyvsp = yyval;
1298 
1299   /* Now 'shift' the result of the reduction.  Determine what state
1300      that goes to, based on the state we popped back to and the rule
1301      number reduced by.  */
1302 
1303   yyn = yyr1[yyn];
1304 
1305   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1306   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1307     yystate = yytable[yystate];
1308   else
1309     yystate = yydefgoto[yyn - YYNTOKENS];
1310 
1311   goto yynewstate;
1312 
1313 
1314 /*--------------------------------------.
1315 | yyerrlab -- here on detecting error.  |
1316 `--------------------------------------*/
1317 yyerrlab:
1318   /* Make sure we have latest lookahead translation.  See comments at
1319      user semantic actions for why this is necessary.  */
1320   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1321 
1322   /* If not already recovering from an error, report this error.  */
1323   if (!yyerrstatus)
1324     {
1325       ++yynerrs;
1326 #if ! YYERROR_VERBOSE
1327       yyerror (YY_("syntax error"));
1328 #else
1329 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1330                                         yyssp, yytoken)
1331       {
1332         char const *yymsgp = YY_("syntax error");
1333         int yysyntax_error_status;
1334         yysyntax_error_status = YYSYNTAX_ERROR;
1335         if (yysyntax_error_status == 0)
1336           yymsgp = yymsg;
1337         else if (yysyntax_error_status == 1)
1338           {
1339             if (yymsg != yymsgbuf)
1340               YYSTACK_FREE (yymsg);
1341             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1342             if (!yymsg)
1343               {
1344                 yymsg = yymsgbuf;
1345                 yymsg_alloc = sizeof yymsgbuf;
1346                 yysyntax_error_status = 2;
1347               }
1348             else
1349               {
1350                 yysyntax_error_status = YYSYNTAX_ERROR;
1351                 yymsgp = yymsg;
1352               }
1353           }
1354         yyerror (yymsgp);
1355         if (yysyntax_error_status == 2)
1356           goto yyexhaustedlab;
1357       }
1358 # undef YYSYNTAX_ERROR
1359 #endif
1360     }
1361 
1362 
1363 
1364   if (yyerrstatus == 3)
1365     {
1366       /* If just tried and failed to reuse lookahead token after an
1367          error, discard it.  */
1368 
1369       if (yychar <= YYEOF)
1370         {
1371           /* Return failure if at end of input.  */
1372           if (yychar == YYEOF)
1373             YYABORT;
1374         }
1375       else
1376         {
1377           yydestruct ("Error: discarding",
1378                       yytoken, &yylval);
1379           yychar = YYEMPTY;
1380         }
1381     }
1382 
1383   /* Else will try to reuse lookahead token after shifting the error
1384      token.  */
1385   goto yyerrlab1;
1386 
1387 
1388 /*---------------------------------------------------.
1389 | yyerrorlab -- error raised explicitly by YYERROR.  |
1390 `---------------------------------------------------*/
1391 yyerrorlab:
1392 
1393   /* Pacify compilers like GCC when the user code never invokes
1394      YYERROR and the label yyerrorlab therefore never appears in user
1395      code.  */
1396   if (/*CONSTCOND*/ 0)
1397      goto yyerrorlab;
1398 
1399   /* Do not reclaim the symbols of the rule whose action triggered
1400      this YYERROR.  */
1401   YYPOPSTACK (yylen);
1402   yylen = 0;
1403   YY_STACK_PRINT (yyss, yyssp);
1404   yystate = *yyssp;
1405   goto yyerrlab1;
1406 
1407 
1408 /*-------------------------------------------------------------.
1409 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1410 `-------------------------------------------------------------*/
1411 yyerrlab1:
1412   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1413 
1414   for (;;)
1415     {
1416       yyn = yypact[yystate];
1417       if (!yypact_value_is_default (yyn))
1418         {
1419           yyn += YYTERROR;
1420           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1421             {
1422               yyn = yytable[yyn];
1423               if (0 < yyn)
1424                 break;
1425             }
1426         }
1427 
1428       /* Pop the current state because it cannot handle the error token.  */
1429       if (yyssp == yyss)
1430         YYABORT;
1431 
1432 
1433       yydestruct ("Error: popping",
1434                   yystos[yystate], yyvsp);
1435       YYPOPSTACK (1);
1436       yystate = *yyssp;
1437       YY_STACK_PRINT (yyss, yyssp);
1438     }
1439 
1440   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1441   *++yyvsp = yylval;
1442   YY_IGNORE_MAYBE_UNINITIALIZED_END
1443 
1444 
1445   /* Shift the error token.  */
1446   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1447 
1448   yystate = yyn;
1449   goto yynewstate;
1450 
1451 
1452 /*-------------------------------------.
1453 | yyacceptlab -- YYACCEPT comes here.  |
1454 `-------------------------------------*/
1455 yyacceptlab:
1456   yyresult = 0;
1457   goto yyreturn;
1458 
1459 /*-----------------------------------.
1460 | yyabortlab -- YYABORT comes here.  |
1461 `-----------------------------------*/
1462 yyabortlab:
1463   yyresult = 1;
1464   goto yyreturn;
1465 
1466 #if !defined yyoverflow || YYERROR_VERBOSE
1467 /*-------------------------------------------------.
1468 | yyexhaustedlab -- memory exhaustion comes here.  |
1469 `-------------------------------------------------*/
1470 yyexhaustedlab:
1471   yyerror (YY_("memory exhausted"));
1472   yyresult = 2;
1473   /* Fall through.  */
1474 #endif
1475 
1476 yyreturn:
1477   if (yychar != YYEMPTY)
1478     {
1479       /* Make sure we have latest lookahead translation.  See comments at
1480          user semantic actions for why this is necessary.  */
1481       yytoken = YYTRANSLATE (yychar);
1482       yydestruct ("Cleanup: discarding lookahead",
1483                   yytoken, &yylval);
1484     }
1485   /* Do not reclaim the symbols of the rule whose action triggered
1486      this YYABORT or YYACCEPT.  */
1487   YYPOPSTACK (yylen);
1488   YY_STACK_PRINT (yyss, yyssp);
1489   while (yyssp != yyss)
1490     {
1491       yydestruct ("Cleanup: popping",
1492                   yystos[*yyssp], yyvsp);
1493       YYPOPSTACK (1);
1494     }
1495 #ifndef yyoverflow
1496   if (yyss != yyssa)
1497     YYSTACK_FREE (yyss);
1498 #endif
1499 #if YYERROR_VERBOSE
1500   if (yymsg != yymsgbuf)
1501     YYSTACK_FREE (yymsg);
1502 #endif
1503   return yyresult;
1504 }
1505 #line 59 "mycalc.y" /* yacc.c:1906  */
1506 
1507 
1508 int yyerror(char const *str) 
1509 {
1510     extern char *yytext;
1511     fprintf(stderr, "parser error near %s\n", yytext);
1512     return 0;
1513 }
1514 
1515 int main()
1516 {
1517     extern int yyparse(void);
1518     extern FILE *yyin;
1519     yyin = stdin;
1520     if (yyparse()) 
1521     {
1522         fprintf(stderr, "Error ! Error! Error!\n");
1523         exit(1);
1524     }
1525     return 0;
1526 }
mycalc.tab.c
   1 #line 3 "lex.yy.c"
   2 
   3 #define  YY_INT_ALIGNED short int
   4 
   5 /* A lexical scanner generated by flex */
   6 
   7 #define FLEX_SCANNER
   8 #define YY_FLEX_MAJOR_VERSION 2
   9 #define YY_FLEX_MINOR_VERSION 5
  10 #define YY_FLEX_SUBMINOR_VERSION 35
  11 #if YY_FLEX_SUBMINOR_VERSION > 0
  12 #define FLEX_BETA
  13 #endif
  14 
  15 /* First, we deal with  platform-specific or compiler-specific issues. */
  16 
  17 /* begin standard C headers. */
  18 #include <stdio.h>
  19 #include <string.h>
  20 #include <errno.h>
  21 #include <stdlib.h>
  22 
  23 /* end standard C headers. */
  24 
  25 /* flex integer type definitions */
  26 
  27 #ifndef FLEXINT_H
  28 #define FLEXINT_H
  29 
  30 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
  31 
  32 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  33 
  34 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  35  * if you want the limit (max/min) macros for int types. 
  36  */
  37 #ifndef __STDC_LIMIT_MACROS
  38 #define __STDC_LIMIT_MACROS 1
  39 #endif
  40 
  41 #include <inttypes.h>
  42 typedef int8_t flex_int8_t;
  43 typedef uint8_t flex_uint8_t;
  44 typedef int16_t flex_int16_t;
  45 typedef uint16_t flex_uint16_t;
  46 typedef int32_t flex_int32_t;
  47 typedef uint32_t flex_uint32_t;
  48 #else
  49 typedef signed char flex_int8_t;
  50 typedef short int flex_int16_t;
  51 typedef int flex_int32_t;
  52 typedef unsigned char flex_uint8_t; 
  53 typedef unsigned short int flex_uint16_t;
  54 typedef unsigned int flex_uint32_t;
  55 
  56 /* Limits of integral types. */
  57 #ifndef INT8_MIN
  58 #define INT8_MIN               (-128)
  59 #endif
  60 #ifndef INT16_MIN
  61 #define INT16_MIN              (-32767-1)
  62 #endif
  63 #ifndef INT32_MIN
  64 #define INT32_MIN              (-2147483647-1)
  65 #endif
  66 #ifndef INT8_MAX
  67 #define INT8_MAX               (127)
  68 #endif
  69 #ifndef INT16_MAX
  70 #define INT16_MAX              (32767)
  71 #endif
  72 #ifndef INT32_MAX
  73 #define INT32_MAX              (2147483647)
  74 #endif
  75 #ifndef UINT8_MAX
  76 #define UINT8_MAX              (255U)
  77 #endif
  78 #ifndef UINT16_MAX
  79 #define UINT16_MAX             (65535U)
  80 #endif
  81 #ifndef UINT32_MAX
  82 #define UINT32_MAX             (4294967295U)
  83 #endif
  84 
  85 #endif /* ! C99 */
  86 
  87 #endif /* ! FLEXINT_H */
  88 
  89 #ifdef __cplusplus
  90 
  91 /* The "const" storage-class-modifier is valid. */
  92 #define YY_USE_CONST
  93 
  94 #else    /* ! __cplusplus */
  95 
  96 /* C99 requires __STDC__ to be defined as 1. */
  97 #if defined (__STDC__)
  98 
  99 #define YY_USE_CONST
 100 
 101 #endif    /* defined (__STDC__) */
 102 #endif    /* ! __cplusplus */
 103 
 104 #ifdef YY_USE_CONST
 105 #define yyconst const
 106 #else
 107 #define yyconst
 108 #endif
 109 
 110 /* Returned upon end-of-file. */
 111 #define YY_NULL 0
 112 
 113 /* Promotes a possibly negative, possibly signed char to an unsigned
 114  * integer for use as an array index.  If the signed char is negative,
 115  * we want to instead treat it as an 8-bit unsigned char, hence the
 116  * double cast.
 117  */
 118 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
 119 
 120 /* Enter a start condition.  This macro really ought to take a parameter,
 121  * but we do it the disgusting crufty way forced on us by the ()-less
 122  * definition of BEGIN.
 123  */
 124 #define BEGIN (yy_start) = 1 + 2 *
 125 
 126 /* Translate the current start state into a value that can be later handed
 127  * to BEGIN to return to the state.  The YYSTATE alias is for lex
 128  * compatibility.
 129  */
 130 #define YY_START (((yy_start) - 1) / 2)
 131 #define YYSTATE YY_START
 132 
 133 /* Action number for EOF rule of a given start state. */
 134 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
 135 
 136 /* Special action meaning "start processing a new file". */
 137 #define YY_NEW_FILE yyrestart(yyin  )
 138 
 139 #define YY_END_OF_BUFFER_CHAR 0
 140 
 141 /* Size of default input buffer. */
 142 #ifndef YY_BUF_SIZE
 143 #ifdef __ia64__
 144 /* On IA-64, the buffer size is 16k, not 8k.
 145  * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
 146  * Ditto for the __ia64__ case accordingly.
 147  */
 148 #define YY_BUF_SIZE 32768
 149 #else
 150 #define YY_BUF_SIZE 16384
 151 #endif /* __ia64__ */
 152 #endif
 153 
 154 /* The state buf must be large enough to hold one state per character in the main buffer.
 155  */
 156 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
 157 
 158 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
 159 #define YY_TYPEDEF_YY_BUFFER_STATE
 160 typedef struct yy_buffer_state *YY_BUFFER_STATE;
 161 #endif
 162 
 163 extern int yyleng;
 164 
 165 extern FILE *yyin, *yyout;
 166 
 167 #define EOB_ACT_CONTINUE_SCAN 0
 168 #define EOB_ACT_END_OF_FILE 1
 169 #define EOB_ACT_LAST_MATCH 2
 170 
 171     #define YY_LESS_LINENO(n)
 172     
 173 /* Return all but the first "n" matched characters back to the input stream. */
 174 #define yyless(n) \
 175     do \
 176         { \
 177         /* Undo effects of setting up yytext. */ \
 178         int yyless_macro_arg = (n); \
 179         YY_LESS_LINENO(yyless_macro_arg);\
 180         *yy_cp = (yy_hold_char); \
 181         YY_RESTORE_YY_MORE_OFFSET \
 182         (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
 183         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
 184         } \
 185     while ( 0 )
 186 
 187 #define unput(c) yyunput( c, (yytext_ptr)  )
 188 
 189 #ifndef YY_TYPEDEF_YY_SIZE_T
 190 #define YY_TYPEDEF_YY_SIZE_T
 191 typedef size_t yy_size_t;
 192 #endif
 193 
 194 #ifndef YY_STRUCT_YY_BUFFER_STATE
 195 #define YY_STRUCT_YY_BUFFER_STATE
 196 struct yy_buffer_state
 197     {
 198     FILE *yy_input_file;
 199 
 200     char *yy_ch_buf;        /* input buffer */
 201     char *yy_buf_pos;        /* current position in input buffer */
 202 
 203     /* Size of input buffer in bytes, not including room for EOB
 204      * characters.
 205      */
 206     yy_size_t yy_buf_size;
 207 
 208     /* Number of characters read into yy_ch_buf, not including EOB
 209      * characters.
 210      */
 211     int yy_n_chars;
 212 
 213     /* Whether we "own" the buffer - i.e., we know we created it,
 214      * and can realloc() it to grow it, and should free() it to
 215      * delete it.
 216      */
 217     int yy_is_our_buffer;
 218 
 219     /* Whether this is an "interactive" input source; if so, and
 220      * if we're using stdio for input, then we want to use getc()
 221      * instead of fread(), to make sure we stop fetching input after
 222      * each newline.
 223      */
 224     int yy_is_interactive;
 225 
 226     /* Whether we're considered to be at the beginning of a line.
 227      * If so, '^' rules will be active on the next match, otherwise
 228      * not.
 229      */
 230     int yy_at_bol;
 231 
 232     int yy_bs_lineno; /**< The line count. */
 233     int yy_bs_column; /**< The column count. */
 234     
 235     /* Whether to try to fill the input buffer when we reach the
 236      * end of it.
 237      */
 238     int yy_fill_buffer;
 239 
 240     int yy_buffer_status;
 241 
 242 #define YY_BUFFER_NEW 0
 243 #define YY_BUFFER_NORMAL 1
 244     /* When an EOF's been seen but there's still some text to process
 245      * then we mark the buffer as YY_EOF_PENDING, to indicate that we
 246      * shouldn't try reading from the input source any more.  We might
 247      * still have a bunch of tokens to match, though, because of
 248      * possible backing-up.
 249      *
 250      * When we actually see the EOF, we change the status to "new"
 251      * (via yyrestart()), so that the user can continue scanning by
 252      * just pointing yyin at a new input file.
 253      */
 254 #define YY_BUFFER_EOF_PENDING 2
 255 
 256     };
 257 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
 258 
 259 /* Stack of input buffers. */
 260 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
 261 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
 262 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
 263 
 264 /* We provide macros for accessing buffer states in case in the
 265  * future we want to put the buffer states in a more general
 266  * "scanner state".
 267  *
 268  * Returns the top of the stack, or NULL.
 269  */
 270 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
 271                           ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
 272                           : NULL)
 273 
 274 /* Same as previous macro, but useful when we know that the buffer stack is not
 275  * NULL or when we need an lvalue. For internal use only.
 276  */
 277 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
 278 
 279 /* yy_hold_char holds the character lost when yytext is formed. */
 280 static char yy_hold_char;
 281 static int yy_n_chars;        /* number of characters read into yy_ch_buf */
 282 int yyleng;
 283 
 284 /* Points to current character in buffer. */
 285 static char *yy_c_buf_p = (char *) 0;
 286 static int yy_init = 0;        /* whether we need to initialize */
 287 static int yy_start = 0;    /* start state number */
 288 
 289 /* Flag which is used to allow yywrap()'s to do buffer switches
 290  * instead of setting up a fresh yyin.  A bit of a hack ...
 291  */
 292 static int yy_did_buffer_switch_on_eof;
 293 
 294 void yyrestart (FILE *input_file  );
 295 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
 296 YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
 297 void yy_delete_buffer (YY_BUFFER_STATE b  );
 298 void yy_flush_buffer (YY_BUFFER_STATE b  );
 299 void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
 300 void yypop_buffer_state (void );
 301 
 302 static void yyensure_buffer_stack (void );
 303 static void yy_load_buffer_state (void );
 304 static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
 305 
 306 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
 307 
 308 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
 309 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
 310 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len  );
 311 
 312 void *yyalloc (yy_size_t  );
 313 void *yyrealloc (void *,yy_size_t  );
 314 void yyfree (void *  );
 315 
 316 #define yy_new_buffer yy_create_buffer
 317 
 318 #define yy_set_interactive(is_interactive) \
 319     { \
 320     if ( ! YY_CURRENT_BUFFER ){ \
 321         yyensure_buffer_stack (); \
 322         YY_CURRENT_BUFFER_LVALUE =    \
 323             yy_create_buffer(yyin,YY_BUF_SIZE ); \
 324     } \
 325     YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
 326     }
 327 
 328 #define yy_set_bol(at_bol) \
 329     { \
 330     if ( ! YY_CURRENT_BUFFER ){\
 331         yyensure_buffer_stack (); \
 332         YY_CURRENT_BUFFER_LVALUE =    \
 333             yy_create_buffer(yyin,YY_BUF_SIZE ); \
 334     } \
 335     YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
 336     }
 337 
 338 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
 339 
 340 /* Begin user sect3 */
 341 
 342 typedef unsigned char YY_CHAR;
 343 
 344 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
 345 
 346 typedef int yy_state_type;
 347 
 348 extern int yylineno;
 349 
 350 int yylineno = 1;
 351 
 352 extern char *yytext;
 353 #define yytext_ptr yytext
 354 
 355 static yy_state_type yy_get_previous_state (void );
 356 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
 357 static int yy_get_next_buffer (void );
 358 static void yy_fatal_error (yyconst char msg[]  );
 359 
 360 /* Done after the current pattern has been matched and before the
 361  * corresponding action - sets up yytext.
 362  */
 363 #define YY_DO_BEFORE_ACTION \
 364     (yytext_ptr) = yy_bp; \
 365     yyleng = (size_t) (yy_cp - yy_bp); \
 366     (yy_hold_char) = *yy_cp; \
 367     *yy_cp = '\0'; \
 368     (yy_c_buf_p) = yy_cp;
 369 
 370 #define YY_NUM_RULES 11
 371 #define YY_END_OF_BUFFER 12
 372 /* This struct is not used in this scanner,
 373    but its presence is necessary. */
 374 struct yy_trans_info
 375     {
 376     flex_int32_t yy_verify;
 377     flex_int32_t yy_nxt;
 378     };
 379 static yyconst flex_int16_t yy_accept[20] =
 380     {   0,
 381         0,    0,   12,   10,    9,    7,    5,    6,    3,    1,
 382         2,    4,    8,    8,    0,    0,    8,    8,    0
 383     } ;
 384 
 385 static yyconst flex_int32_t yy_ec[256] =
 386     {   0,
 387         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
 388         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 389         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 390         1,    2,    1,    1,    1,    1,    1,    1,    1,    4,
 391         5,    6,    7,    1,    8,    9,   10,   11,   12,   12,
 392        12,   12,   12,   12,   12,   12,   12,    1,    1,    1,
 393         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 394         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 395         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 396         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 397 
 398         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 399         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 400         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 401         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 402         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 403         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 404         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 405         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 406         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 407         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 408 
 409         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 410         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 411         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 412         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 413         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 414         1,    1,    1,    1,    1
 415     } ;
 416 
 417 static yyconst flex_int32_t yy_meta[13] =
 418     {   0,
 419         1,    1,    1,    1,    1,    1,    1,    1,    2,    1,
 420         3,    3
 421     } ;
 422 
 423 static yyconst flex_int16_t yy_base[23] =
 424     {   0,
 425         0,    0,   22,   23,   23,   23,   23,   23,   23,   23,
 426        23,   23,   12,   11,    0,   10,    9,    0,   23,   11,
 427        13,   14
 428     } ;
 429 
 430 static yyconst flex_int16_t yy_def[23] =
 431     {   0,
 432        19,    1,   19,   19,   19,   19,   19,   19,   19,   19,
 433        19,   19,   20,   21,   22,   20,   21,   22,    0,   19,
 434        19,   19
 435     } ;
 436 
 437 static yyconst flex_int16_t yy_nxt[36] =
 438     {   0,
 439         4,    5,    6,    7,    8,    9,   10,   11,    4,   12,
 440        13,   14,   16,   16,   17,   17,   18,   15,   15,   15,
 441        15,   19,    3,   19,   19,   19,   19,   19,   19,   19,
 442        19,   19,   19,   19,   19
 443     } ;
 444 
 445 static yyconst flex_int16_t yy_chk[36] =
 446     {   0,
 447         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
 448         1,    1,   20,   20,   21,   21,   22,   17,   16,   14,
 449        13,    3,   19,   19,   19,   19,   19,   19,   19,   19,
 450        19,   19,   19,   19,   19
 451     } ;
 452 
 453 static yy_state_type yy_last_accepting_state;
 454 static char *yy_last_accepting_cpos;
 455 
 456 extern int yy_flex_debug;
 457 int yy_flex_debug = 0;
 458 
 459 /* The intent behind this definition is that it'll catch
 460  * any uses of REJECT which flex missed.
 461  */
 462 #define REJECT reject_used_but_not_detected
 463 #define yymore() yymore_used_but_not_detected
 464 #define YY_MORE_ADJ 0
 465 #define YY_RESTORE_YY_MORE_OFFSET
 466 char *yytext;
 467 #line 1 "mycalc.l"
 468 #line 2 "mycalc.l"
 469 #include <stdio.h>
 470 #include "mycalc.tab.h"
 471 
 472 int yywrap(void) {return 1;}
 473 #line 475 "lex.yy.c"
 474 
 475 #define INITIAL 0
 476 
 477 #ifndef YY_NO_UNISTD_H
 478 /* Special case for "unistd.h", since it is non-ANSI. We include it way
 479  * down here because we want the user's section 1 to have been scanned first.
 480  * The user has a chance to override it with an option.
 481  */
 482 #include <unistd.h>
 483 #endif
 484 
 485 #ifndef YY_EXTRA_TYPE
 486 #define YY_EXTRA_TYPE void *
 487 #endif
 488 
 489 static int yy_init_globals (void );
 490 
 491 /* Accessor methods to globals.
 492    These are made visible to non-reentrant scanners for convenience. */
 493 
 494 int yylex_destroy (void );
 495 
 496 int yyget_debug (void );
 497 
 498 void yyset_debug (int debug_flag  );
 499 
 500 YY_EXTRA_TYPE yyget_extra (void );
 501 
 502 void yyset_extra (YY_EXTRA_TYPE user_defined  );
 503 
 504 FILE *yyget_in (void );
 505 
 506 void yyset_in  (FILE * in_str  );
 507 
 508 FILE *yyget_out (void );
 509 
 510 void yyset_out  (FILE * out_str  );
 511 
 512 int yyget_leng (void );
 513 
 514 char *yyget_text (void );
 515 
 516 int yyget_lineno (void );
 517 
 518 void yyset_lineno (int line_number  );
 519 
 520 /* Macros after this point can all be overridden by user definitions in
 521  * section 1.
 522  */
 523 
 524 #ifndef YY_SKIP_YYWRAP
 525 #ifdef __cplusplus
 526 extern "C" int yywrap (void );
 527 #else
 528 extern int yywrap (void );
 529 #endif
 530 #endif
 531 
 532     static void yyunput (int c,char *buf_ptr  );
 533     
 534 #ifndef yytext_ptr
 535 static void yy_flex_strncpy (char *,yyconst char *,int );
 536 #endif
 537 
 538 #ifdef YY_NEED_STRLEN
 539 static int yy_flex_strlen (yyconst char * );
 540 #endif
 541 
 542 #ifndef YY_NO_INPUT
 543 
 544 #ifdef __cplusplus
 545 static int yyinput (void );
 546 #else
 547 static int input (void );
 548 #endif
 549 
 550 #endif
 551 
 552 /* Amount of stuff to slurp up with each read. */
 553 #ifndef YY_READ_BUF_SIZE
 554 #ifdef __ia64__
 555 /* On IA-64, the buffer size is 16k, not 8k */
 556 #define YY_READ_BUF_SIZE 16384
 557 #else
 558 #define YY_READ_BUF_SIZE 8192
 559 #endif /* __ia64__ */
 560 #endif
 561 
 562 /* Copy whatever the last rule matched to the standard output. */
 563 #ifndef ECHO
 564 /* This used to be an fputs(), but since the string might contain NUL's,
 565  * we now use fwrite().
 566  */
 567 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
 568 #endif
 569 
 570 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
 571  * is returned in "result".
 572  */
 573 #ifndef YY_INPUT
 574 #define YY_INPUT(buf,result,max_size) \
 575     if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 576         { \
 577         int c = '*'; \
 578         size_t n; \
 579         for ( n = 0; n < max_size && \
 580                  (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 581             buf[n] = (char) c; \
 582         if ( c == '\n' ) \
 583             buf[n++] = (char) c; \
 584         if ( c == EOF && ferror( yyin ) ) \
 585             YY_FATAL_ERROR( "input in flex scanner failed" ); \
 586         result = n; \
 587         } \
 588     else \
 589         { \
 590         errno=0; \
 591         while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
 592             { \
 593             if( errno != EINTR) \
 594                 { \
 595                 YY_FATAL_ERROR( "input in flex scanner failed" ); \
 596                 break; \
 597                 } \
 598             errno=0; \
 599             clearerr(yyin); \
 600             } \
 601         }\
 602 \
 603 
 604 #endif
 605 
 606 /* No semi-colon after return; correct usage is to write "yyterminate();" -
 607  * we don't want an extra ';' after the "return" because that will cause
 608  * some compilers to complain about unreachable statements.
 609  */
 610 #ifndef yyterminate
 611 #define yyterminate() return YY_NULL
 612 #endif
 613 
 614 /* Number of entries by which start-condition stack grows. */
 615 #ifndef YY_START_STACK_INCR
 616 #define YY_START_STACK_INCR 25
 617 #endif
 618 
 619 /* Report a fatal error. */
 620 #ifndef YY_FATAL_ERROR
 621 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
 622 #endif
 623 
 624 /* end tables serialization structures and prototypes */
 625 
 626 /* Default declaration of generated scanner - a define so the user can
 627  * easily add parameters.
 628  */
 629 #ifndef YY_DECL
 630 #define YY_DECL_IS_OURS 1
 631 
 632 extern int yylex (void);
 633 
 634 #define YY_DECL int yylex (void)
 635 #endif /* !YY_DECL */
 636 
 637 /* Code executed at the beginning of each rule, after yytext and yyleng
 638  * have been set up.
 639  */
 640 #ifndef YY_USER_ACTION
 641 #define YY_USER_ACTION
 642 #endif
 643 
 644 /* Code executed at the end of each rule. */
 645 #ifndef YY_BREAK
 646 #define YY_BREAK break;
 647 #endif
 648 
 649 #define YY_RULE_SETUP \
 650     YY_USER_ACTION
 651 
 652 /** The main scanner function which does all the work.
 653  */
 654 YY_DECL
 655 {
 656     register yy_state_type yy_current_state;
 657     register char *yy_cp, *yy_bp;
 658     register int yy_act;
 659     
 660 #line 8 "mycalc.l"
 661 
 662 
 663 #line 665 "lex.yy.c"
 664 
 665     if ( !(yy_init) )
 666         {
 667         (yy_init) = 1;
 668 
 669 #ifdef YY_USER_INIT
 670         YY_USER_INIT;
 671 #endif
 672 
 673         if ( ! (yy_start) )
 674             (yy_start) = 1;    /* first start state */
 675 
 676         if ( ! yyin )
 677             yyin = stdin;
 678 
 679         if ( ! yyout )
 680             yyout = stdout;
 681 
 682         if ( ! YY_CURRENT_BUFFER ) {
 683             yyensure_buffer_stack ();
 684             YY_CURRENT_BUFFER_LVALUE =
 685                 yy_create_buffer(yyin,YY_BUF_SIZE );
 686         }
 687 
 688         yy_load_buffer_state( );
 689         }
 690 
 691     while ( 1 )        /* loops until end-of-file is reached */
 692         {
 693         yy_cp = (yy_c_buf_p);
 694 
 695         /* Support of yytext. */
 696         *yy_cp = (yy_hold_char);
 697 
 698         /* yy_bp points to the position in yy_ch_buf of the start of
 699          * the current run.
 700          */
 701         yy_bp = yy_cp;
 702 
 703         yy_current_state = (yy_start);
 704 yy_match:
 705         do
 706             {
 707             register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
 708             if ( yy_accept[yy_current_state] )
 709                 {
 710                 (yy_last_accepting_state) = yy_current_state;
 711                 (yy_last_accepting_cpos) = yy_cp;
 712                 }
 713             while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 714                 {
 715                 yy_current_state = (int) yy_def[yy_current_state];
 716                 if ( yy_current_state >= 20 )
 717                     yy_c = yy_meta[(unsigned int) yy_c];
 718                 }
 719             yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 720             ++yy_cp;
 721             }
 722         while ( yy_base[yy_current_state] != 23 );
 723 
 724 yy_find_action:
 725         yy_act = yy_accept[yy_current_state];
 726         if ( yy_act == 0 )
 727             { /* have to back up */
 728             yy_cp = (yy_last_accepting_cpos);
 729             yy_current_state = (yy_last_accepting_state);
 730             yy_act = yy_accept[yy_current_state];
 731             }
 732 
 733         YY_DO_BEFORE_ACTION;
 734 
 735 do_action:    /* This label is used only to access EOF actions. */
 736 
 737         switch ( yy_act )
 738     { /* beginning of action switch */
 739             case 0: /* must back up */
 740             /* undo the effects of YY_DO_BEFORE_ACTION */
 741             *yy_cp = (yy_hold_char);
 742             yy_cp = (yy_last_accepting_cpos);
 743             yy_current_state = (yy_last_accepting_state);
 744             goto yy_find_action;
 745 
 746 case 1:
 747 YY_RULE_SETUP
 748 #line 10 "mycalc.l"
 749 return ADD;
 750     YY_BREAK
 751 case 2:
 752 YY_RULE_SETUP
 753 #line 11 "mycalc.l"
 754 return SUB;
 755     YY_BREAK
 756 case 3:
 757 YY_RULE_SETUP
 758 #line 12 "mycalc.l"
 759 return MUL;
 760     YY_BREAK
 761 case 4:
 762 YY_RULE_SETUP
 763 #line 13 "mycalc.l"
 764 return DIV;
 765     YY_BREAK
 766 case 5:
 767 YY_RULE_SETUP
 768 #line 14 "mycalc.l"
 769 return LP;
 770     YY_BREAK
 771 case 6:
 772 YY_RULE_SETUP
 773 #line 15 "mycalc.l"
 774 return RP;
 775     YY_BREAK
 776 case 7:
 777 /* rule 7 can match eol */
 778 YY_RULE_SETUP
 779 #line 16 "mycalc.l"
 780 return CR;
 781     YY_BREAK
 782 case 8:
 783 YY_RULE_SETUP
 784 #line 17 "mycalc.l"
 785 {
 786     double temp;
 787     sscanf(yytext, "%lf", &temp);
 788     yylval.double_value = temp;
 789     return DOUBLE_LITERAL;
 790 }
 791     YY_BREAK
 792 case 9:
 793 YY_RULE_SETUP
 794 #line 23 "mycalc.l"
 795 ;
 796     YY_BREAK
 797 case 10:
 798 YY_RULE_SETUP
 799 #line 24 "mycalc.l"
 800 {
 801     fprintf(stderr, "lexical error.\n");
 802     exit(1);
 803 }
 804     YY_BREAK
 805 case 11:
 806 YY_RULE_SETUP
 807 #line 29 "mycalc.l"
 808 ECHO;
 809     YY_BREAK
 810 #line 812 "lex.yy.c"
 811 case YY_STATE_EOF(INITIAL):
 812     yyterminate();
 813 
 814     case YY_END_OF_BUFFER:
 815         {
 816         /* Amount of text matched not including the EOB char. */
 817         int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
 818 
 819         /* Undo the effects of YY_DO_BEFORE_ACTION. */
 820         *yy_cp = (yy_hold_char);
 821         YY_RESTORE_YY_MORE_OFFSET
 822 
 823         if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
 824             {
 825             /* We're scanning a new file or input source.  It's
 826              * possible that this happened because the user
 827              * just pointed yyin at a new source and called
 828              * yylex().  If so, then we have to assure
 829              * consistency between YY_CURRENT_BUFFER and our
 830              * globals.  Here is the right place to do so, because
 831              * this is the first action (other than possibly a
 832              * back-up) that will match for the new input source.
 833              */
 834             (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
 835             YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
 836             YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
 837             }
 838 
 839         /* Note that here we test for yy_c_buf_p "<=" to the position
 840          * of the first EOB in the buffer, since yy_c_buf_p will
 841          * already have been incremented past the NUL character
 842          * (since all states make transitions on EOB to the
 843          * end-of-buffer state).  Contrast this with the test
 844          * in input().
 845          */
 846         if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
 847             { /* This was really a NUL. */
 848             yy_state_type yy_next_state;
 849 
 850             (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
 851 
 852             yy_current_state = yy_get_previous_state(  );
 853 
 854             /* Okay, we're now positioned to make the NUL
 855              * transition.  We couldn't have
 856              * yy_get_previous_state() go ahead and do it
 857              * for us because it doesn't know how to deal
 858              * with the possibility of jamming (and we don't
 859              * want to build jamming into it because then it
 860              * will run more slowly).
 861              */
 862 
 863             yy_next_state = yy_try_NUL_trans( yy_current_state );
 864 
 865             yy_bp = (yytext_ptr) + YY_MORE_ADJ;
 866 
 867             if ( yy_next_state )
 868                 {
 869                 /* Consume the NUL. */
 870                 yy_cp = ++(yy_c_buf_p);
 871                 yy_current_state = yy_next_state;
 872                 goto yy_match;
 873                 }
 874 
 875             else
 876                 {
 877                 yy_cp = (yy_c_buf_p);
 878                 goto yy_find_action;
 879                 }
 880             }
 881 
 882         else switch ( yy_get_next_buffer(  ) )
 883             {
 884             case EOB_ACT_END_OF_FILE:
 885                 {
 886                 (yy_did_buffer_switch_on_eof) = 0;
 887 
 888                 if ( yywrap( ) )
 889                     {
 890                     /* Note: because we've taken care in
 891                      * yy_get_next_buffer() to have set up
 892                      * yytext, we can now set up
 893                      * yy_c_buf_p so that if some total
 894                      * hoser (like flex itself) wants to
 895                      * call the scanner after we return the
 896                      * YY_NULL, it'll still work - another
 897                      * YY_NULL will get returned.
 898                      */
 899                     (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
 900 
 901                     yy_act = YY_STATE_EOF(YY_START);
 902                     goto do_action;
 903                     }
 904 
 905                 else
 906                     {
 907                     if ( ! (yy_did_buffer_switch_on_eof) )
 908                         YY_NEW_FILE;
 909                     }
 910                 break;
 911                 }
 912 
 913             case EOB_ACT_CONTINUE_SCAN:
 914                 (yy_c_buf_p) =
 915                     (yytext_ptr) + yy_amount_of_matched_text;
 916 
 917                 yy_current_state = yy_get_previous_state(  );
 918 
 919                 yy_cp = (yy_c_buf_p);
 920                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
 921                 goto yy_match;
 922 
 923             case EOB_ACT_LAST_MATCH:
 924                 (yy_c_buf_p) =
 925                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
 926 
 927                 yy_current_state = yy_get_previous_state(  );
 928 
 929                 yy_cp = (yy_c_buf_p);
 930                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
 931                 goto yy_find_action;
 932             }
 933         break;
 934         }
 935 
 936     default:
 937         YY_FATAL_ERROR(
 938             "fatal flex scanner internal error--no action found" );
 939     } /* end of action switch */
 940         } /* end of scanning one token */
 941 } /* end of yylex */
 942 
 943 /* yy_get_next_buffer - try to read in a new buffer
 944  *
 945  * Returns a code representing an action:
 946  *    EOB_ACT_LAST_MATCH -
 947  *    EOB_ACT_CONTINUE_SCAN - continue scanning from current position
 948  *    EOB_ACT_END_OF_FILE - end of file
 949  */
 950 static int yy_get_next_buffer (void)
 951 {
 952         register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
 953     register char *source = (yytext_ptr);
 954     register int number_to_move, i;
 955     int ret_val;
 956 
 957     if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
 958         YY_FATAL_ERROR(
 959         "fatal flex scanner internal error--end of buffer missed" );
 960 
 961     if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
 962         { /* Don't try to fill the buffer, so this is an EOF. */
 963         if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
 964             {
 965             /* We matched a single character, the EOB, so
 966              * treat this as a final EOF.
 967              */
 968             return EOB_ACT_END_OF_FILE;
 969             }
 970 
 971         else
 972             {
 973             /* We matched some text prior to the EOB, first
 974              * process it.
 975              */
 976             return EOB_ACT_LAST_MATCH;
 977             }
 978         }
 979 
 980     /* Try to read more data. */
 981 
 982     /* First move last chars to start of buffer. */
 983     number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
 984 
 985     for ( i = 0; i < number_to_move; ++i )
 986         *(dest++) = *(source++);
 987 
 988     if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
 989         /* don't do the read, it's not guaranteed to return an EOF,
 990          * just force an EOF
 991          */
 992         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
 993 
 994     else
 995         {
 996             int num_to_read =
 997             YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
 998 
 999         while ( num_to_read <= 0 )
1000             { /* Not enough room in the buffer - grow it. */
1001 
1002             /* just a shorter name for the current buffer */
1003             YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1004 
1005             int yy_c_buf_p_offset =
1006                 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1007 
1008             if ( b->yy_is_our_buffer )
1009                 {
1010                 int new_size = b->yy_buf_size * 2;
1011 
1012                 if ( new_size <= 0 )
1013                     b->yy_buf_size += b->yy_buf_size / 8;
1014                 else
1015                     b->yy_buf_size *= 2;
1016 
1017                 b->yy_ch_buf = (char *)
1018                     /* Include room in for 2 EOB chars. */
1019                     yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
1020                 }
1021             else
1022                 /* Can't grow it, we don't own it. */
1023                 b->yy_ch_buf = 0;
1024 
1025             if ( ! b->yy_ch_buf )
1026                 YY_FATAL_ERROR(
1027                 "fatal error - scanner input buffer overflow" );
1028 
1029             (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1030 
1031             num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1032                         number_to_move - 1;
1033 
1034             }
1035 
1036         if ( num_to_read > YY_READ_BUF_SIZE )
1037             num_to_read = YY_READ_BUF_SIZE;
1038 
1039         /* Read in more data. */
1040         YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1041             (yy_n_chars), (size_t) num_to_read );
1042 
1043         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1044         }
1045 
1046     if ( (yy_n_chars) == 0 )
1047         {
1048         if ( number_to_move == YY_MORE_ADJ )
1049             {
1050             ret_val = EOB_ACT_END_OF_FILE;
1051             yyrestart(yyin  );
1052             }
1053 
1054         else
1055             {
1056             ret_val = EOB_ACT_LAST_MATCH;
1057             YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1058                 YY_BUFFER_EOF_PENDING;
1059             }
1060         }
1061 
1062     else
1063         ret_val = EOB_ACT_CONTINUE_SCAN;
1064 
1065     if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1066         /* Extend the array by 50%, plus the number we really need. */
1067         yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1068         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
1069         if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1070             YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1071     }
1072 
1073     (yy_n_chars) += number_to_move;
1074     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1075     YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1076 
1077     (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1078 
1079     return ret_val;
1080 }
1081 
1082 /* yy_get_previous_state - get the state just before the EOB char was reached */
1083 
1084     static yy_state_type yy_get_previous_state (void)
1085 {
1086     register yy_state_type yy_current_state;
1087     register char *yy_cp;
1088     
1089     yy_current_state = (yy_start);
1090 
1091     for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1092         {
1093         register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1094         if ( yy_accept[yy_current_state] )
1095             {
1096             (yy_last_accepting_state) = yy_current_state;
1097             (yy_last_accepting_cpos) = yy_cp;
1098             }
1099         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1100             {
1101             yy_current_state = (int) yy_def[yy_current_state];
1102             if ( yy_current_state >= 20 )
1103                 yy_c = yy_meta[(unsigned int) yy_c];
1104             }
1105         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1106         }
1107 
1108     return yy_current_state;
1109 }
1110 
1111 /* yy_try_NUL_trans - try to make a transition on the NUL character
1112  *
1113  * synopsis
1114  *    next_state = yy_try_NUL_trans( current_state );
1115  */
1116     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
1117 {
1118     register int yy_is_jam;
1119         register char *yy_cp = (yy_c_buf_p);
1120 
1121     register YY_CHAR yy_c = 1;
1122     if ( yy_accept[yy_current_state] )
1123         {
1124         (yy_last_accepting_state) = yy_current_state;
1125         (yy_last_accepting_cpos) = yy_cp;
1126         }
1127     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1128         {
1129         yy_current_state = (int) yy_def[yy_current_state];
1130         if ( yy_current_state >= 20 )
1131             yy_c = yy_meta[(unsigned int) yy_c];
1132         }
1133     yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1134     yy_is_jam = (yy_current_state == 19);
1135 
1136     return yy_is_jam ? 0 : yy_current_state;
1137 }
1138 
1139     static void yyunput (int c, register char * yy_bp )
1140 {
1141     register char *yy_cp;
1142     
1143     yy_cp = (yy_c_buf_p);
1144 
1145     /* undo effects of setting up yytext */
1146     *yy_cp = (yy_hold_char);
1147 
1148     if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1149         { /* need to shift things up to make room */
1150         /* +2 for EOB chars. */
1151         register int number_to_move = (yy_n_chars) + 2;
1152         register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1153                     YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1154         register char *source =
1155                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1156 
1157         while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1158             *--dest = *--source;
1159 
1160         yy_cp += (int) (dest - source);
1161         yy_bp += (int) (dest - source);
1162         YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1163             (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1164 
1165         if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1166             YY_FATAL_ERROR( "flex scanner push-back overflow" );
1167         }
1168 
1169     *--yy_cp = (char) c;
1170 
1171     (yytext_ptr) = yy_bp;
1172     (yy_hold_char) = *yy_cp;
1173     (yy_c_buf_p) = yy_cp;
1174 }
1175 
1176 #ifndef YY_NO_INPUT
1177 #ifdef __cplusplus
1178     static int yyinput (void)
1179 #else
1180     static int input  (void)
1181 #endif
1182 
1183 {
1184     int c;
1185     
1186     *(yy_c_buf_p) = (yy_hold_char);
1187 
1188     if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1189         {
1190         /* yy_c_buf_p now points to the character we want to return.
1191          * If this occurs *before* the EOB characters, then it's a
1192          * valid NUL; if not, then we've hit the end of the buffer.
1193          */
1194         if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1195             /* This was really a NUL. */
1196             *(yy_c_buf_p) = '\0';
1197 
1198         else
1199             { /* need more input */
1200             int offset = (yy_c_buf_p) - (yytext_ptr);
1201             ++(yy_c_buf_p);
1202 
1203             switch ( yy_get_next_buffer(  ) )
1204                 {
1205                 case EOB_ACT_LAST_MATCH:
1206                     /* This happens because yy_g_n_b()
1207                      * sees that we've accumulated a
1208                      * token and flags that we need to
1209                      * try matching the token before
1210                      * proceeding.  But for input(),
1211                      * there's no matching to consider.
1212                      * So convert the EOB_ACT_LAST_MATCH
1213                      * to EOB_ACT_END_OF_FILE.
1214                      */
1215 
1216                     /* Reset buffer status. */
1217                     yyrestart(yyin );
1218 
1219                     /*FALLTHROUGH*/
1220 
1221                 case EOB_ACT_END_OF_FILE:
1222                     {
1223                     if ( yywrap( ) )
1224                         return EOF;
1225 
1226                     if ( ! (yy_did_buffer_switch_on_eof) )
1227                         YY_NEW_FILE;
1228 #ifdef __cplusplus
1229                     return yyinput();
1230 #else
1231                     return input();
1232 #endif
1233                     }
1234 
1235                 case EOB_ACT_CONTINUE_SCAN:
1236                     (yy_c_buf_p) = (yytext_ptr) + offset;
1237                     break;
1238                 }
1239             }
1240         }
1241 
1242     c = *(unsigned char *) (yy_c_buf_p);    /* cast for 8-bit char's */
1243     *(yy_c_buf_p) = '\0';    /* preserve yytext */
1244     (yy_hold_char) = *++(yy_c_buf_p);
1245 
1246     return c;
1247 }
1248 #endif    /* ifndef YY_NO_INPUT */
1249 
1250 /** Immediately switch to a different input stream.
1251  * @param input_file A readable stream.
1252  * 
1253  * @note This function does not reset the start condition to @c INITIAL .
1254  */
1255     void yyrestart  (FILE * input_file )
1256 {
1257     
1258     if ( ! YY_CURRENT_BUFFER ){
1259         yyensure_buffer_stack ();
1260         YY_CURRENT_BUFFER_LVALUE =
1261             yy_create_buffer(yyin,YY_BUF_SIZE );
1262     }
1263 
1264     yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1265     yy_load_buffer_state( );
1266 }
1267 
1268 /** Switch to a different input buffer.
1269  * @param new_buffer The new input buffer.
1270  * 
1271  */
1272     void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1273 {
1274     
1275     /* TODO. We should be able to replace this entire function body
1276      * with
1277      *        yypop_buffer_state();
1278      *        yypush_buffer_state(new_buffer);
1279      */
1280     yyensure_buffer_stack ();
1281     if ( YY_CURRENT_BUFFER == new_buffer )
1282         return;
1283 
1284     if ( YY_CURRENT_BUFFER )
1285         {
1286         /* Flush out information for old buffer. */
1287         *(yy_c_buf_p) = (yy_hold_char);
1288         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1289         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1290         }
1291 
1292     YY_CURRENT_BUFFER_LVALUE = new_buffer;
1293     yy_load_buffer_state( );
1294 
1295     /* We don't actually know whether we did this switch during
1296      * EOF (yywrap()) processing, but the only time this flag
1297      * is looked at is after yywrap() is called, so it's safe
1298      * to go ahead and always set it.
1299      */
1300     (yy_did_buffer_switch_on_eof) = 1;
1301 }
1302 
1303 static void yy_load_buffer_state  (void)
1304 {
1305         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1306     (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1307     yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1308     (yy_hold_char) = *(yy_c_buf_p);
1309 }
1310 
1311 /** Allocate and initialize an input buffer state.
1312  * @param file A readable stream.
1313  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1314  * 
1315  * @return the allocated buffer state.
1316  */
1317     YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
1318 {
1319     YY_BUFFER_STATE b;
1320     
1321     b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1322     if ( ! b )
1323         YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1324 
1325     b->yy_buf_size = size;
1326 
1327     /* yy_ch_buf has to be 2 characters longer than the size given because
1328      * we need to put in 2 end-of-buffer characters.
1329      */
1330     b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
1331     if ( ! b->yy_ch_buf )
1332         YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1333 
1334     b->yy_is_our_buffer = 1;
1335 
1336     yy_init_buffer(b,file );
1337 
1338     return b;
1339 }
1340 
1341 /** Destroy the buffer.
1342  * @param b a buffer created with yy_create_buffer()
1343  * 
1344  */
1345     void yy_delete_buffer (YY_BUFFER_STATE  b )
1346 {
1347     
1348     if ( ! b )
1349         return;
1350 
1351     if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1352         YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1353 
1354     if ( b->yy_is_our_buffer )
1355         yyfree((void *) b->yy_ch_buf  );
1356 
1357     yyfree((void *) b  );
1358 }
1359 
1360 #ifndef __cplusplus
1361 extern int isatty (int );
1362 #endif /* __cplusplus */
1363     
1364 /* Initializes or reinitializes a buffer.
1365  * This function is sometimes called more than once on the same buffer,
1366  * such as during a yyrestart() or at EOF.
1367  */
1368     static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1369 
1370 {
1371     int oerrno = errno;
1372     
1373     yy_flush_buffer(b );
1374 
1375     b->yy_input_file = file;
1376     b->yy_fill_buffer = 1;
1377 
1378     /* If b is the current buffer, then yy_init_buffer was _probably_
1379      * called from yyrestart() or through yy_get_next_buffer.
1380      * In that case, we don't want to reset the lineno or column.
1381      */
1382     if (b != YY_CURRENT_BUFFER){
1383         b->yy_bs_lineno = 1;
1384         b->yy_bs_column = 0;
1385     }
1386 
1387         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1388     
1389     errno = oerrno;
1390 }
1391 
1392 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1393  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1394  * 
1395  */
1396     void yy_flush_buffer (YY_BUFFER_STATE  b )
1397 {
1398         if ( ! b )
1399         return;
1400 
1401     b->yy_n_chars = 0;
1402 
1403     /* We always need two end-of-buffer characters.  The first causes
1404      * a transition to the end-of-buffer state.  The second causes
1405      * a jam in that state.
1406      */
1407     b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1408     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1409 
1410     b->yy_buf_pos = &b->yy_ch_buf[0];
1411 
1412     b->yy_at_bol = 1;
1413     b->yy_buffer_status = YY_BUFFER_NEW;
1414 
1415     if ( b == YY_CURRENT_BUFFER )
1416         yy_load_buffer_state( );
1417 }
1418 
1419 /** Pushes the new state onto the stack. The new state becomes
1420  *  the current state. This function will allocate the stack
1421  *  if necessary.
1422  *  @param new_buffer The new state.
1423  *  
1424  */
1425 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1426 {
1427         if (new_buffer == NULL)
1428         return;
1429 
1430     yyensure_buffer_stack();
1431 
1432     /* This block is copied from yy_switch_to_buffer. */
1433     if ( YY_CURRENT_BUFFER )
1434         {
1435         /* Flush out information for old buffer. */
1436         *(yy_c_buf_p) = (yy_hold_char);
1437         YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1438         YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1439         }
1440 
1441     /* Only push if top exists. Otherwise, replace top. */
1442     if (YY_CURRENT_BUFFER)
1443         (yy_buffer_stack_top)++;
1444     YY_CURRENT_BUFFER_LVALUE = new_buffer;
1445 
1446     /* copied from yy_switch_to_buffer. */
1447     yy_load_buffer_state( );
1448     (yy_did_buffer_switch_on_eof) = 1;
1449 }
1450 
1451 /** Removes and deletes the top of the stack, if present.
1452  *  The next element becomes the new top.
1453  *  
1454  */
1455 void yypop_buffer_state (void)
1456 {
1457         if (!YY_CURRENT_BUFFER)
1458         return;
1459 
1460     yy_delete_buffer(YY_CURRENT_BUFFER );
1461     YY_CURRENT_BUFFER_LVALUE = NULL;
1462     if ((yy_buffer_stack_top) > 0)
1463         --(yy_buffer_stack_top);
1464 
1465     if (YY_CURRENT_BUFFER) {
1466         yy_load_buffer_state( );
1467         (yy_did_buffer_switch_on_eof) = 1;
1468     }
1469 }
1470 
1471 /* Allocates the stack if it does not exist.
1472  *  Guarantees space for at least one push.
1473  */
1474 static void yyensure_buffer_stack (void)
1475 {
1476     int num_to_alloc;
1477     
1478     if (!(yy_buffer_stack)) {
1479 
1480         /* First allocation is just for 2 elements, since we don't know if this
1481          * scanner will even need a stack. We use 2 instead of 1 to avoid an
1482          * immediate realloc on the next call.
1483          */
1484         num_to_alloc = 1;
1485         (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1486                                 (num_to_alloc * sizeof(struct yy_buffer_state*)
1487                                 );
1488         if ( ! (yy_buffer_stack) )
1489             YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1490                                   
1491         memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1492                 
1493         (yy_buffer_stack_max) = num_to_alloc;
1494         (yy_buffer_stack_top) = 0;
1495         return;
1496     }
1497 
1498     if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1499 
1500         /* Increase the buffer to prepare for a possible push. */
1501         int grow_size = 8 /* arbitrary grow size */;
1502 
1503         num_to_alloc = (yy_buffer_stack_max) + grow_size;
1504         (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1505                                 ((yy_buffer_stack),
1506                                 num_to_alloc * sizeof(struct yy_buffer_state*)
1507                                 );
1508         if ( ! (yy_buffer_stack) )
1509             YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1510 
1511         /* zero only the new slots.*/
1512         memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1513         (yy_buffer_stack_max) = num_to_alloc;
1514     }
1515 }
1516 
1517 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1518  * @param base the character buffer
1519  * @param size the size in bytes of the character buffer
1520  * 
1521  * @return the newly allocated buffer state object. 
1522  */
1523 YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
1524 {
1525     YY_BUFFER_STATE b;
1526     
1527     if ( size < 2 ||
1528          base[size-2] != YY_END_OF_BUFFER_CHAR ||
1529          base[size-1] != YY_END_OF_BUFFER_CHAR )
1530         /* They forgot to leave room for the EOB's. */
1531         return 0;
1532 
1533     b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1534     if ( ! b )
1535         YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1536 
1537     b->yy_buf_size = size - 2;    /* "- 2" to take care of EOB's */
1538     b->yy_buf_pos = b->yy_ch_buf = base;
1539     b->yy_is_our_buffer = 0;
1540     b->yy_input_file = 0;
1541     b->yy_n_chars = b->yy_buf_size;
1542     b->yy_is_interactive = 0;
1543     b->yy_at_bol = 1;
1544     b->yy_fill_buffer = 0;
1545     b->yy_buffer_status = YY_BUFFER_NEW;
1546 
1547     yy_switch_to_buffer(b  );
1548 
1549     return b;
1550 }
1551 
1552 /** Setup the input buffer state to scan a string. The next call to yylex() will
1553  * scan from a @e copy of @a str.
1554  * @param yystr a NUL-terminated string to scan
1555  * 
1556  * @return the newly allocated buffer state object.
1557  * @note If you want to scan bytes that may contain NUL values, then use
1558  *       yy_scan_bytes() instead.
1559  */
1560 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1561 {
1562     
1563     return yy_scan_bytes(yystr,strlen(yystr) );
1564 }
1565 
1566 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1567  * scan from a @e copy of @a bytes.
1568  * @param yybytes the byte buffer to scan
1569  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1570  * 
1571  * @return the newly allocated buffer state object.
1572  */
1573 YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len )
1574 {
1575     YY_BUFFER_STATE b;
1576     char *buf;
1577     yy_size_t n;
1578     int i;
1579     
1580     /* Get memory for full buffer, including space for trailing EOB's. */
1581     n = _yybytes_len + 2;
1582     buf = (char *) yyalloc(n  );
1583     if ( ! buf )
1584         YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1585 
1586     for ( i = 0; i < _yybytes_len; ++i )
1587         buf[i] = yybytes[i];
1588 
1589     buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1590 
1591     b = yy_scan_buffer(buf,n );
1592     if ( ! b )
1593         YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1594 
1595     /* It's okay to grow etc. this buffer, and we should throw it
1596      * away when we're done.
1597      */
1598     b->yy_is_our_buffer = 1;
1599 
1600     return b;
1601 }
1602 
1603 #ifndef YY_EXIT_FAILURE
1604 #define YY_EXIT_FAILURE 2
1605 #endif
1606 
1607 static void yy_fatal_error (yyconst char* msg )
1608 {
1609         (void) fprintf( stderr, "%s\n", msg );
1610     exit( YY_EXIT_FAILURE );
1611 }
1612 
1613 /* Redefine yyless() so it works in section 3 code. */
1614 
1615 #undef yyless
1616 #define yyless(n) \
1617     do \
1618         { \
1619         /* Undo effects of setting up yytext. */ \
1620         int yyless_macro_arg = (n); \
1621         YY_LESS_LINENO(yyless_macro_arg);\
1622         yytext[yyleng] = (yy_hold_char); \
1623         (yy_c_buf_p) = yytext + yyless_macro_arg; \
1624         (yy_hold_char) = *(yy_c_buf_p); \
1625         *(yy_c_buf_p) = '\0'; \
1626         yyleng = yyless_macro_arg; \
1627         } \
1628     while ( 0 )
1629 
1630 /* Accessor  methods (get/set functions) to struct members. */
1631 
1632 /** Get the current line number.
1633  * 
1634  */
1635 int yyget_lineno  (void)
1636 {
1637         
1638     return yylineno;
1639 }
1640 
1641 /** Get the input stream.
1642  * 
1643  */
1644 FILE *yyget_in  (void)
1645 {
1646         return yyin;
1647 }
1648 
1649 /** Get the output stream.
1650  * 
1651  */
1652 FILE *yyget_out  (void)
1653 {
1654         return yyout;
1655 }
1656 
1657 /** Get the length of the current token.
1658  * 
1659  */
1660 int yyget_leng  (void)
1661 {
1662         return yyleng;
1663 }
1664 
1665 /** Get the current token.
1666  * 
1667  */
1668 
1669 char *yyget_text  (void)
1670 {
1671         return yytext;
1672 }
1673 
1674 /** Set the current line number.
1675  * @param line_number
1676  * 
1677  */
1678 void yyset_lineno (int  line_number )
1679 {
1680     
1681     yylineno = line_number;
1682 }
1683 
1684 /** Set the input stream. This does not discard the current
1685  * input buffer.
1686  * @param in_str A readable stream.
1687  * 
1688  * @see yy_switch_to_buffer
1689  */
1690 void yyset_in (FILE *  in_str )
1691 {
1692         yyin = in_str ;
1693 }
1694 
1695 void yyset_out (FILE *  out_str )
1696 {
1697         yyout = out_str ;
1698 }
1699 
1700 int yyget_debug  (void)
1701 {
1702         return yy_flex_debug;
1703 }
1704 
1705 void yyset_debug (int  bdebug )
1706 {
1707         yy_flex_debug = bdebug ;
1708 }
1709 
1710 static int yy_init_globals (void)
1711 {
1712         /* Initialization is the same as for the non-reentrant scanner.
1713      * This function is called from yylex_destroy(), so don't allocate here.
1714      */
1715 
1716     (yy_buffer_stack) = 0;
1717     (yy_buffer_stack_top) = 0;
1718     (yy_buffer_stack_max) = 0;
1719     (yy_c_buf_p) = (char *) 0;
1720     (yy_init) = 0;
1721     (yy_start) = 0;
1722 
1723 /* Defined in main.c */
1724 #ifdef YY_STDINIT
1725     yyin = stdin;
1726     yyout = stdout;
1727 #else
1728     yyin = (FILE *) 0;
1729     yyout = (FILE *) 0;
1730 #endif
1731 
1732     /* For future reference: Set errno on error, since we are called by
1733      * yylex_init()
1734      */
1735     return 0;
1736 }
1737 
1738 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
1739 int yylex_destroy  (void)
1740 {
1741     
1742     /* Pop the buffer stack, destroying each element. */
1743     while(YY_CURRENT_BUFFER){
1744         yy_delete_buffer(YY_CURRENT_BUFFER  );
1745         YY_CURRENT_BUFFER_LVALUE = NULL;
1746         yypop_buffer_state();
1747     }
1748 
1749     /* Destroy the stack itself. */
1750     yyfree((yy_buffer_stack) );
1751     (yy_buffer_stack) = NULL;
1752 
1753     /* Reset the globals. This is important in a non-reentrant scanner so the next time
1754      * yylex() is called, initialization will occur. */
1755     yy_init_globals( );
1756 
1757     return 0;
1758 }
1759 
1760 /*
1761  * Internal utility routines.
1762  */
1763 
1764 #ifndef yytext_ptr
1765 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1766 {
1767     register int i;
1768     for ( i = 0; i < n; ++i )
1769         s1[i] = s2[i];
1770 }
1771 #endif
1772 
1773 #ifdef YY_NEED_STRLEN
1774 static int yy_flex_strlen (yyconst char * s )
1775 {
1776     register int n;
1777     for ( n = 0; s[n]; ++n )
1778         ;
1779 
1780     return n;
1781 }
1782 #endif
1783 
1784 void *yyalloc (yy_size_t  size )
1785 {
1786     return (void *) malloc( size );
1787 }
1788 
1789 void *yyrealloc  (void * ptr, yy_size_t  size )
1790 {
1791     /* The cast to (char *) in the following accommodates both
1792      * implementations that use char* generic pointers, and those
1793      * that use void* generic pointers.  It works with the latter
1794      * because both ANSI C and C++ allow castless assignment from
1795      * any pointer type to void*, and deal with argument conversions
1796      * as though doing an assignment.
1797      */
1798     return (void *) realloc( (char *) ptr, size );
1799 }
1800 
1801 void yyfree (void * ptr )
1802 {
1803     free( (char *) ptr );    /* see yyrealloc() for (char *) cast */
1804 }
1805 
1806 #define YYTABLES_NAME "yytables"
1807 
1808 #line 29 "mycalc.l"
lex.yy.c

 

posted on 2014-12-27 17:19  cyendra  阅读(1373)  评论(0编辑  收藏  举报