Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563728 views
1
#line 2 "calclex.c"
2
/* A lexical scanner generated by flex */
3
4
/* Scanner skeleton version:
5
* $Header: /home/cvsfiles/gmp42/demos/calc/calclex.c,v 1.1.1.1 2006/03/14 15:57:54 tege Exp $
6
*/
7
8
#define FLEX_SCANNER
9
#define YY_FLEX_MAJOR_VERSION 2
10
#define YY_FLEX_MINOR_VERSION 5
11
12
#include <stdio.h>
13
#include <errno.h>
14
15
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
16
#ifdef c_plusplus
17
#ifndef __cplusplus
18
#define __cplusplus
19
#endif
20
#endif
21
22
23
#ifdef __cplusplus
24
25
#include <stdlib.h>
26
#ifndef _WIN32
27
#include <unistd.h>
28
#endif
29
30
/* Use prototypes in function declarations. */
31
#define YY_USE_PROTOS
32
33
/* The "const" storage-class-modifier is valid. */
34
#define YY_USE_CONST
35
36
#else /* ! __cplusplus */
37
38
#if __STDC__
39
40
#define YY_USE_PROTOS
41
#define YY_USE_CONST
42
43
#endif /* __STDC__ */
44
#endif /* ! __cplusplus */
45
46
#ifdef __TURBOC__
47
#pragma warn -rch
48
#pragma warn -use
49
#include <io.h>
50
#include <stdlib.h>
51
#define YY_USE_CONST
52
#define YY_USE_PROTOS
53
#endif
54
55
#ifdef YY_USE_CONST
56
#define yyconst const
57
#else
58
#define yyconst
59
#endif
60
61
62
#ifdef YY_USE_PROTOS
63
#define YY_PROTO(proto) proto
64
#else
65
#define YY_PROTO(proto) ()
66
#endif
67
68
/* Returned upon end-of-file. */
69
#define YY_NULL 0
70
71
/* Promotes a possibly negative, possibly signed char to an unsigned
72
* integer for use as an array index. If the signed char is negative,
73
* we want to instead treat it as an 8-bit unsigned char, hence the
74
* double cast.
75
*/
76
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
77
78
/* Enter a start condition. This macro really ought to take a parameter,
79
* but we do it the disgusting crufty way forced on us by the ()-less
80
* definition of BEGIN.
81
*/
82
#define BEGIN yy_start = 1 + 2 *
83
84
/* Translate the current start state into a value that can be later handed
85
* to BEGIN to return to the state. The YYSTATE alias is for lex
86
* compatibility.
87
*/
88
#define YY_START ((yy_start - 1) / 2)
89
#define YYSTATE YY_START
90
91
/* Action number for EOF rule of a given start state. */
92
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
93
94
/* Special action meaning "start processing a new file". */
95
#define YY_NEW_FILE yyrestart( yyin )
96
97
#define YY_END_OF_BUFFER_CHAR 0
98
99
/* Size of default input buffer. */
100
#define YY_BUF_SIZE 16384
101
102
typedef struct yy_buffer_state *YY_BUFFER_STATE;
103
104
extern int yyleng;
105
extern FILE *yyin, *yyout;
106
107
#define EOB_ACT_CONTINUE_SCAN 0
108
#define EOB_ACT_END_OF_FILE 1
109
#define EOB_ACT_LAST_MATCH 2
110
111
/* The funky do-while in the following #define is used to turn the definition
112
* int a single C statement (which needs a semi-colon terminator). This
113
* avoids problems with code like:
114
*
115
* if ( condition_holds )
116
* yyless( 5 );
117
* else
118
* do_something_else();
119
*
120
* Prior to using the do-while the compiler would get upset at the
121
* "else" because it interpreted the "if" statement as being all
122
* done when it reached the ';' after the yyless() call.
123
*/
124
125
/* Return all but the first 'n' matched characters back to the input stream. */
126
127
#define yyless(n) \
128
do \
129
{ \
130
/* Undo effects of setting up yytext. */ \
131
*yy_cp = yy_hold_char; \
132
YY_RESTORE_YY_MORE_OFFSET \
133
yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
134
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
135
} \
136
while ( 0 )
137
138
#define unput(c) yyunput( c, yytext_ptr )
139
140
/* The following is because we cannot portably get our hands on size_t
141
* (without autoconf's help, which isn't available because we want
142
* flex-generated scanners to compile on their own).
143
*/
144
typedef unsigned int yy_size_t;
145
146
147
struct yy_buffer_state
148
{
149
FILE *yy_input_file;
150
151
char *yy_ch_buf; /* input buffer */
152
char *yy_buf_pos; /* current position in input buffer */
153
154
/* Size of input buffer in bytes, not including room for EOB
155
* characters.
156
*/
157
yy_size_t yy_buf_size;
158
159
/* Number of characters read into yy_ch_buf, not including EOB
160
* characters.
161
*/
162
int yy_n_chars;
163
164
/* Whether we "own" the buffer - i.e., we know we created it,
165
* and can realloc() it to grow it, and should free() it to
166
* delete it.
167
*/
168
int yy_is_our_buffer;
169
170
/* Whether this is an "interactive" input source; if so, and
171
* if we're using stdio for input, then we want to use getc()
172
* instead of fread(), to make sure we stop fetching input after
173
* each newline.
174
*/
175
int yy_is_interactive;
176
177
/* Whether we're considered to be at the beginning of a line.
178
* If so, '^' rules will be active on the next match, otherwise
179
* not.
180
*/
181
int yy_at_bol;
182
183
/* Whether to try to fill the input buffer when we reach the
184
* end of it.
185
*/
186
int yy_fill_buffer;
187
188
int yy_buffer_status;
189
#define YY_BUFFER_NEW 0
190
#define YY_BUFFER_NORMAL 1
191
/* When an EOF's been seen but there's still some text to process
192
* then we mark the buffer as YY_EOF_PENDING, to indicate that we
193
* shouldn't try reading from the input source any more. We might
194
* still have a bunch of tokens to match, though, because of
195
* possible backing-up.
196
*
197
* When we actually see the EOF, we change the status to "new"
198
* (via yyrestart()), so that the user can continue scanning by
199
* just pointing yyin at a new input file.
200
*/
201
#define YY_BUFFER_EOF_PENDING 2
202
};
203
204
static YY_BUFFER_STATE yy_current_buffer = 0;
205
206
/* We provide macros for accessing buffer states in case in the
207
* future we want to put the buffer states in a more general
208
* "scanner state".
209
*/
210
#define YY_CURRENT_BUFFER yy_current_buffer
211
212
213
/* yy_hold_char holds the character lost when yytext is formed. */
214
static char yy_hold_char;
215
216
static int yy_n_chars; /* number of characters read into yy_ch_buf */
217
218
219
int yyleng;
220
221
/* Points to current character in buffer. */
222
static char *yy_c_buf_p = (char *) 0;
223
static int yy_init = 1; /* whether we need to initialize */
224
static int yy_start = 0; /* start state number */
225
226
/* Flag which is used to allow yywrap()'s to do buffer switches
227
* instead of setting up a fresh yyin. A bit of a hack ...
228
*/
229
static int yy_did_buffer_switch_on_eof;
230
231
void yyrestart YY_PROTO(( FILE *input_file ));
232
233
void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
234
void yy_load_buffer_state YY_PROTO(( void ));
235
YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
236
void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
237
void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
238
void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
239
#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
240
241
YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
242
YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
243
YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
244
245
static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
246
static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
247
static void yy_flex_free YY_PROTO(( void * ));
248
249
#define yy_new_buffer yy_create_buffer
250
251
#define yy_set_interactive(is_interactive) \
252
{ \
253
if ( ! yy_current_buffer ) \
254
yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
255
yy_current_buffer->yy_is_interactive = is_interactive; \
256
}
257
258
#define yy_set_bol(at_bol) \
259
{ \
260
if ( ! yy_current_buffer ) \
261
yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
262
yy_current_buffer->yy_at_bol = at_bol; \
263
}
264
265
#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
266
267
typedef unsigned char YY_CHAR;
268
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
269
typedef int yy_state_type;
270
extern char *yytext;
271
#define yytext_ptr yytext
272
273
static yy_state_type yy_get_previous_state YY_PROTO(( void ));
274
static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
275
static int yy_get_next_buffer YY_PROTO(( void ));
276
static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
277
278
/* Done after the current pattern has been matched and before the
279
* corresponding action - sets up yytext.
280
*/
281
#define YY_DO_BEFORE_ACTION \
282
yytext_ptr = yy_bp; \
283
yyleng = (int) (yy_cp - yy_bp); \
284
yy_hold_char = *yy_cp; \
285
*yy_cp = '\0'; \
286
yy_c_buf_p = yy_cp;
287
288
#define YY_NUM_RULES 19
289
#define YY_END_OF_BUFFER 20
290
static yyconst short int yy_accept[39] =
291
{ 0,
292
0, 0, 20, 18, 1, 2, 7, 6, 7, 18,
293
16, 16, 2, 7, 7, 7, 16, 17, 18, 18,
294
11, 6, 5, 6, 14, 16, 0, 12, 8, 10,
295
9, 13, 16, 17, 3, 15, 4, 0
296
} ;
297
298
static yyconst int yy_ec[256] =
299
{ 0,
300
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
301
1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
302
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
303
1, 2, 4, 1, 5, 1, 6, 7, 1, 6,
304
6, 6, 6, 6, 6, 1, 6, 8, 9, 9,
305
9, 9, 9, 9, 9, 9, 9, 1, 10, 11,
306
12, 13, 1, 1, 14, 14, 14, 14, 14, 14,
307
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
308
15, 15, 15, 15, 15, 15, 15, 16, 15, 15,
309
1, 17, 1, 6, 1, 1, 15, 15, 15, 15,
310
311
15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
312
15, 15, 15, 15, 15, 15, 15, 15, 15, 16,
313
15, 15, 1, 18, 1, 1, 1, 1, 1, 1,
314
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
315
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
316
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
317
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
318
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
319
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
320
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
321
322
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
323
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
324
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
325
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
326
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
327
1, 1, 1, 1, 1
328
} ;
329
330
static yyconst int yy_meta[19] =
331
{ 0,
332
1, 1, 1, 1, 1, 1, 1, 2, 2, 1,
333
1, 1, 1, 2, 3, 2, 1, 1
334
} ;
335
336
static yyconst short int yy_base[43] =
337
{ 0,
338
0, 0, 39, 49, 49, 49, 26, 16, 49, 30,
339
20, 19, 49, 9, 22, 10, 9, 0, 29, 13,
340
49, 23, 49, 24, 49, 0, 0, 49, 49, 49,
341
49, 49, 13, 0, 49, 49, 49, 49, 41, 28,
342
43, 45
343
} ;
344
345
static yyconst short int yy_def[43] =
346
{ 0,
347
38, 1, 38, 38, 38, 38, 38, 39, 38, 38,
348
40, 40, 38, 38, 38, 38, 41, 42, 38, 38,
349
38, 39, 38, 39, 38, 12, 12, 38, 38, 38,
350
38, 38, 41, 42, 38, 38, 38, 0, 38, 38,
351
38, 38
352
} ;
353
354
static yyconst short int yy_nxt[68] =
355
{ 0,
356
4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
357
14, 15, 16, 17, 18, 18, 19, 20, 23, 28,
358
29, 31, 32, 34, 34, 23, 37, 34, 34, 26,
359
36, 35, 24, 30, 38, 27, 25, 21, 38, 24,
360
24, 22, 22, 22, 33, 33, 34, 34, 3, 38,
361
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
362
38, 38, 38, 38, 38, 38, 38
363
} ;
364
365
static yyconst short int yy_chk[68] =
366
{ 0,
367
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
368
1, 1, 1, 1, 1, 1, 1, 1, 8, 14,
369
14, 16, 16, 17, 17, 22, 24, 33, 33, 40,
370
20, 19, 8, 15, 12, 11, 10, 7, 3, 22,
371
24, 39, 39, 39, 41, 41, 42, 42, 38, 38,
372
38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
373
38, 38, 38, 38, 38, 38, 38
374
} ;
375
376
static yy_state_type yy_last_accepting_state;
377
static char *yy_last_accepting_cpos;
378
379
/* The intent behind this definition is that it'll catch
380
* any uses of REJECT which flex missed.
381
*/
382
#define REJECT reject_used_but_not_detected
383
#define yymore() yymore_used_but_not_detected
384
#define YY_MORE_ADJ 0
385
#define YY_RESTORE_YY_MORE_OFFSET
386
char *yytext;
387
#line 1 "calclex.l"
388
#define INITIAL 0
389
/* Lexical analyzer for calc program.
390
391
Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
392
393
This file is part of the GNU MP Library.
394
395
This program is free software; you can redistribute it and/or modify it under
396
the terms of the GNU General Public License as published by the Free Software
397
Foundation; either version 2 of the License, or (at your option) any later
398
version.
399
400
This program is distributed in the hope that it will be useful, but WITHOUT ANY
401
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
402
PARTICULAR PURPOSE. See the GNU General Public License for more details.
403
404
You should have received a copy of the GNU General Public License along with
405
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
406
Street, Fifth Floor, Boston, MA 02110-1301, USA. */
407
#line 21 "calclex.l"
408
#include <string.h>
409
#include "calc-common.h"
410
411
412
#if WITH_READLINE
413
/* Let GNU flex use readline. See the calcread.c redefined input() for a
414
way that might work for a standard lex too. */
415
#define YY_INPUT(buf,result,max_size) \
416
result = calc_input (buf, max_size);
417
#endif
418
419
420
/* Non-zero when reading the second or subsequent line of an expression,
421
used to give a different prompt when using readline. */
422
int calc_more_input = 0;
423
424
425
const struct calc_keywords_t calc_keywords[] = {
426
{ "abs", ABS },
427
{ "bin", BIN },
428
{ "decimal", DECIMAL },
429
{ "fib", FIB },
430
{ "hex", HEX },
431
{ "help", HELP },
432
{ "gcd", GCD },
433
{ "kron", KRON },
434
{ "lcm", LCM },
435
{ "lucnum", LUCNUM },
436
{ "nextprime", NEXTPRIME },
437
{ "powm", POWM },
438
{ "quit", QUIT },
439
{ "root", ROOT },
440
{ "sqrt", SQRT },
441
{ NULL }
442
};
443
#line 444 "calclex.c"
444
445
/* Macros after this point can all be overridden by user definitions in
446
* section 1.
447
*/
448
449
#ifndef YY_SKIP_YYWRAP
450
#ifdef __cplusplus
451
extern "C" int yywrap YY_PROTO(( void ));
452
#else
453
extern int yywrap YY_PROTO(( void ));
454
#endif
455
#endif
456
457
#ifndef YY_NO_UNPUT
458
static void yyunput YY_PROTO(( int c, char *buf_ptr ));
459
#endif
460
461
#ifndef yytext_ptr
462
static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
463
#endif
464
465
#ifdef YY_NEED_STRLEN
466
static int yy_flex_strlen YY_PROTO(( yyconst char * ));
467
#endif
468
469
#ifndef YY_NO_INPUT
470
#ifdef __cplusplus
471
static int yyinput YY_PROTO(( void ));
472
#else
473
static int input YY_PROTO(( void ));
474
#endif
475
#endif
476
477
#if YY_STACK_USED
478
static int yy_start_stack_ptr = 0;
479
static int yy_start_stack_depth = 0;
480
static int *yy_start_stack = 0;
481
#ifndef YY_NO_PUSH_STATE
482
static void yy_push_state YY_PROTO(( int new_state ));
483
#endif
484
#ifndef YY_NO_POP_STATE
485
static void yy_pop_state YY_PROTO(( void ));
486
#endif
487
#ifndef YY_NO_TOP_STATE
488
static int yy_top_state YY_PROTO(( void ));
489
#endif
490
491
#else
492
#define YY_NO_PUSH_STATE 1
493
#define YY_NO_POP_STATE 1
494
#define YY_NO_TOP_STATE 1
495
#endif
496
497
#ifdef YY_MALLOC_DECL
498
YY_MALLOC_DECL
499
#else
500
#if __STDC__
501
#ifndef __cplusplus
502
#include <stdlib.h>
503
#endif
504
#else
505
/* Just try to get by without declaring the routines. This will fail
506
* miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
507
* or sizeof(void*) != sizeof(int).
508
*/
509
#endif
510
#endif
511
512
/* Amount of stuff to slurp up with each read. */
513
#ifndef YY_READ_BUF_SIZE
514
#define YY_READ_BUF_SIZE 8192
515
#endif
516
517
/* Copy whatever the last rule matched to the standard output. */
518
519
#ifndef ECHO
520
/* This used to be an fputs(), but since the string might contain NUL's,
521
* we now use fwrite().
522
*/
523
#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
524
#endif
525
526
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
527
* is returned in "result".
528
*/
529
#ifndef YY_INPUT
530
#define YY_INPUT(buf,result,max_size) \
531
if ( yy_current_buffer->yy_is_interactive ) \
532
{ \
533
int c = '*', n; \
534
for ( n = 0; n < max_size && \
535
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
536
buf[n] = (char) c; \
537
if ( c == '\n' ) \
538
buf[n++] = (char) c; \
539
if ( c == EOF && ferror( yyin ) ) \
540
YY_FATAL_ERROR( "input in flex scanner failed" ); \
541
result = n; \
542
} \
543
else \
544
{ \
545
errno=0; \
546
while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
547
{ \
548
if( errno != EINTR) \
549
{ \
550
YY_FATAL_ERROR( "input in flex scanner failed" ); \
551
break; \
552
} \
553
errno=0; \
554
clearerr(yyin); \
555
} \
556
}
557
#endif
558
559
/* No semi-colon after return; correct usage is to write "yyterminate();" -
560
* we don't want an extra ';' after the "return" because that will cause
561
* some compilers to complain about unreachable statements.
562
*/
563
#ifndef yyterminate
564
#define yyterminate() return YY_NULL
565
#endif
566
567
/* Number of entries by which start-condition stack grows. */
568
#ifndef YY_START_STACK_INCR
569
#define YY_START_STACK_INCR 25
570
#endif
571
572
/* Report a fatal error. */
573
#ifndef YY_FATAL_ERROR
574
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
575
#endif
576
577
/* Default declaration of generated scanner - a define so the user can
578
* easily add parameters.
579
*/
580
#ifndef YY_DECL
581
#define YY_DECL int yylex YY_PROTO(( void ))
582
#endif
583
584
/* Code executed at the beginning of each rule, after yytext and yyleng
585
* have been set up.
586
*/
587
#ifndef YY_USER_ACTION
588
#define YY_USER_ACTION
589
#endif
590
591
/* Code executed at the end of each rule. */
592
#ifndef YY_BREAK
593
#define YY_BREAK break;
594
#endif
595
596
#define YY_RULE_SETUP \
597
YY_USER_ACTION
598
599
YY_DECL
600
{
601
register yy_state_type yy_current_state;
602
register char *yy_cp, *yy_bp;
603
register int yy_act;
604
605
#line 58 "calclex.l"
606
607
608
#line 609 "calclex.c"
609
610
if ( yy_init )
611
{
612
yy_init = 0;
613
614
#ifdef YY_USER_INIT
615
YY_USER_INIT;
616
#endif
617
618
if ( ! yy_start )
619
yy_start = 1; /* first start state */
620
621
if ( ! yyin )
622
yyin = stdin;
623
624
if ( ! yyout )
625
yyout = stdout;
626
627
if ( ! yy_current_buffer )
628
yy_current_buffer =
629
yy_create_buffer( yyin, YY_BUF_SIZE );
630
631
yy_load_buffer_state();
632
}
633
634
while ( 1 ) /* loops until end-of-file is reached */
635
{
636
yy_cp = yy_c_buf_p;
637
638
/* Support of yytext. */
639
*yy_cp = yy_hold_char;
640
641
/* yy_bp points to the position in yy_ch_buf of the start of
642
* the current run.
643
*/
644
yy_bp = yy_cp;
645
646
yy_current_state = yy_start;
647
yy_match:
648
do
649
{
650
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
651
if ( yy_accept[yy_current_state] )
652
{
653
yy_last_accepting_state = yy_current_state;
654
yy_last_accepting_cpos = yy_cp;
655
}
656
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
657
{
658
yy_current_state = (int) yy_def[yy_current_state];
659
if ( yy_current_state >= 39 )
660
yy_c = yy_meta[(unsigned int) yy_c];
661
}
662
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
663
++yy_cp;
664
}
665
while ( yy_base[yy_current_state] != 49 );
666
667
yy_find_action:
668
yy_act = yy_accept[yy_current_state];
669
if ( yy_act == 0 )
670
{ /* have to back up */
671
yy_cp = yy_last_accepting_cpos;
672
yy_current_state = yy_last_accepting_state;
673
yy_act = yy_accept[yy_current_state];
674
}
675
676
YY_DO_BEFORE_ACTION;
677
678
679
do_action: /* This label is used only to access EOF actions. */
680
681
682
switch ( yy_act )
683
{ /* beginning of action switch */
684
case 0: /* must back up */
685
/* undo the effects of YY_DO_BEFORE_ACTION */
686
*yy_cp = yy_hold_char;
687
yy_cp = yy_last_accepting_cpos;
688
yy_current_state = yy_last_accepting_state;
689
goto yy_find_action;
690
691
case 1:
692
YY_RULE_SETUP
693
#line 60 "calclex.l"
694
{ /* white space is skipped */ }
695
YY_BREAK
696
case 2:
697
YY_RULE_SETUP
698
#line 62 "calclex.l"
699
{ /* semicolon or newline separates statements */
700
calc_more_input = 0;
701
return EOS; }
702
YY_BREAK
703
case 3:
704
YY_RULE_SETUP
705
#line 65 "calclex.l"
706
{ /* escaped newlines are skipped */ }
707
YY_BREAK
708
case 4:
709
YY_RULE_SETUP
710
#line 68 "calclex.l"
711
{
712
/* comment through to escaped newline is skipped */ }
713
YY_BREAK
714
case 5:
715
YY_RULE_SETUP
716
#line 70 "calclex.l"
717
{ /* comment through to newline is a separator */
718
calc_more_input = 0;
719
return EOS; }
720
YY_BREAK
721
case 6:
722
YY_RULE_SETUP
723
#line 73 "calclex.l"
724
{ /* comment through to EOF skipped */ }
725
YY_BREAK
726
case 7:
727
YY_RULE_SETUP
728
#line 76 "calclex.l"
729
{ return yytext[0]; }
730
YY_BREAK
731
case 8:
732
YY_RULE_SETUP
733
#line 77 "calclex.l"
734
{ return LE; }
735
YY_BREAK
736
case 9:
737
YY_RULE_SETUP
738
#line 78 "calclex.l"
739
{ return GE; }
740
YY_BREAK
741
case 10:
742
YY_RULE_SETUP
743
#line 79 "calclex.l"
744
{ return EQ; }
745
YY_BREAK
746
case 11:
747
YY_RULE_SETUP
748
#line 80 "calclex.l"
749
{ return NE; }
750
YY_BREAK
751
case 12:
752
YY_RULE_SETUP
753
#line 81 "calclex.l"
754
{ return LSHIFT; }
755
YY_BREAK
756
case 13:
757
YY_RULE_SETUP
758
#line 82 "calclex.l"
759
{ return RSHIFT; }
760
YY_BREAK
761
case 14:
762
YY_RULE_SETUP
763
#line 83 "calclex.l"
764
{ return LAND; }
765
YY_BREAK
766
case 15:
767
YY_RULE_SETUP
768
#line 84 "calclex.l"
769
{ return LOR; }
770
YY_BREAK
771
case 16:
772
YY_RULE_SETUP
773
#line 86 "calclex.l"
774
{
775
yylval.str = yytext;
776
return NUMBER; }
777
YY_BREAK
778
case 17:
779
YY_RULE_SETUP
780
#line 90 "calclex.l"
781
{
782
int i;
783
784
for (i = 0; calc_keywords[i].name != NULL; i++)
785
if (strcmp (yytext, calc_keywords[i].name) == 0)
786
return calc_keywords[i].value;
787
788
if (yytext[0] >= 'a' && yytext[0] <= 'z' && yytext[1] == '\0')
789
{
790
yylval.var = yytext[0] - 'a';
791
return VARIABLE;
792
}
793
794
return BAD;
795
}
796
YY_BREAK
797
case 18:
798
YY_RULE_SETUP
799
#line 106 "calclex.l"
800
{ return BAD; }
801
YY_BREAK
802
case 19:
803
YY_RULE_SETUP
804
#line 108 "calclex.l"
805
ECHO;
806
YY_BREAK
807
#line 808 "calclex.c"
808
case YY_STATE_EOF(INITIAL):
809
yyterminate();
810
811
case YY_END_OF_BUFFER:
812
{
813
/* Amount of text matched not including the EOB char. */
814
int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
815
816
/* Undo the effects of YY_DO_BEFORE_ACTION. */
817
*yy_cp = yy_hold_char;
818
YY_RESTORE_YY_MORE_OFFSET
819
820
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
821
{
822
/* We're scanning a new file or input source. It's
823
* possible that this happened because the user
824
* just pointed yyin at a new source and called
825
* yylex(). If so, then we have to assure
826
* consistency between yy_current_buffer and our
827
* globals. Here is the right place to do so, because
828
* this is the first action (other than possibly a
829
* back-up) that will match for the new input source.
830
*/
831
yy_n_chars = yy_current_buffer->yy_n_chars;
832
yy_current_buffer->yy_input_file = yyin;
833
yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
834
}
835
836
/* Note that here we test for yy_c_buf_p "<=" to the position
837
* of the first EOB in the buffer, since yy_c_buf_p will
838
* already have been incremented past the NUL character
839
* (since all states make transitions on EOB to the
840
* end-of-buffer state). Contrast this with the test
841
* in input().
842
*/
843
if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
844
{ /* This was really a NUL. */
845
yy_state_type yy_next_state;
846
847
yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
848
849
yy_current_state = yy_get_previous_state();
850
851
/* Okay, we're now positioned to make the NUL
852
* transition. We couldn't have
853
* yy_get_previous_state() go ahead and do it
854
* for us because it doesn't know how to deal
855
* with the possibility of jamming (and we don't
856
* want to build jamming into it because then it
857
* will run more slowly).
858
*/
859
860
yy_next_state = yy_try_NUL_trans( yy_current_state );
861
862
yy_bp = yytext_ptr + YY_MORE_ADJ;
863
864
if ( yy_next_state )
865
{
866
/* Consume the NUL. */
867
yy_cp = ++yy_c_buf_p;
868
yy_current_state = yy_next_state;
869
goto yy_match;
870
}
871
872
else
873
{
874
yy_cp = yy_c_buf_p;
875
goto yy_find_action;
876
}
877
}
878
879
else switch ( yy_get_next_buffer() )
880
{
881
case EOB_ACT_END_OF_FILE:
882
{
883
yy_did_buffer_switch_on_eof = 0;
884
885
if ( yywrap() )
886
{
887
/* Note: because we've taken care in
888
* yy_get_next_buffer() to have set up
889
* yytext, we can now set up
890
* yy_c_buf_p so that if some total
891
* hoser (like flex itself) wants to
892
* call the scanner after we return the
893
* YY_NULL, it'll still work - another
894
* YY_NULL will get returned.
895
*/
896
yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
897
898
yy_act = YY_STATE_EOF(YY_START);
899
goto do_action;
900
}
901
902
else
903
{
904
if ( ! yy_did_buffer_switch_on_eof )
905
YY_NEW_FILE;
906
}
907
break;
908
}
909
910
case EOB_ACT_CONTINUE_SCAN:
911
yy_c_buf_p =
912
yytext_ptr + yy_amount_of_matched_text;
913
914
yy_current_state = yy_get_previous_state();
915
916
yy_cp = yy_c_buf_p;
917
yy_bp = yytext_ptr + YY_MORE_ADJ;
918
goto yy_match;
919
920
case EOB_ACT_LAST_MATCH:
921
yy_c_buf_p =
922
&yy_current_buffer->yy_ch_buf[yy_n_chars];
923
924
yy_current_state = yy_get_previous_state();
925
926
yy_cp = yy_c_buf_p;
927
yy_bp = yytext_ptr + YY_MORE_ADJ;
928
goto yy_find_action;
929
}
930
break;
931
}
932
933
default:
934
YY_FATAL_ERROR(
935
"fatal flex scanner internal error--no action found" );
936
} /* end of action switch */
937
} /* end of scanning one token */
938
} /* end of yylex */
939
940
941
/* yy_get_next_buffer - try to read in a new buffer
942
*
943
* Returns a code representing an action:
944
* EOB_ACT_LAST_MATCH -
945
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
946
* EOB_ACT_END_OF_FILE - end of file
947
*/
948
949
static int yy_get_next_buffer()
950
{
951
register char *dest = yy_current_buffer->yy_ch_buf;
952
register char *source = yytext_ptr;
953
register int number_to_move, i;
954
int ret_val;
955
956
if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
957
YY_FATAL_ERROR(
958
"fatal flex scanner internal error--end of buffer missed" );
959
960
if ( yy_current_buffer->yy_fill_buffer == 0 )
961
{ /* Don't try to fill the buffer, so this is an EOF. */
962
if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
963
{
964
/* We matched a single character, the EOB, so
965
* treat this as a final EOF.
966
*/
967
return EOB_ACT_END_OF_FILE;
968
}
969
970
else
971
{
972
/* We matched some text prior to the EOB, first
973
* process it.
974
*/
975
return EOB_ACT_LAST_MATCH;
976
}
977
}
978
979
/* Try to read more data. */
980
981
/* First move last chars to start of buffer. */
982
number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
983
984
for ( i = 0; i < number_to_move; ++i )
985
*(dest++) = *(source++);
986
987
if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
988
/* don't do the read, it's not guaranteed to return an EOF,
989
* just force an EOF
990
*/
991
yy_current_buffer->yy_n_chars = yy_n_chars = 0;
992
993
else
994
{
995
int num_to_read =
996
yy_current_buffer->yy_buf_size - number_to_move - 1;
997
998
while ( num_to_read <= 0 )
999
{ /* Not enough room in the buffer - grow it. */
1000
#ifdef YY_USES_REJECT
1001
YY_FATAL_ERROR(
1002
"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1003
#else
1004
1005
/* just a shorter name for the current buffer */
1006
YY_BUFFER_STATE b = yy_current_buffer;
1007
1008
int yy_c_buf_p_offset =
1009
(int) (yy_c_buf_p - b->yy_ch_buf);
1010
1011
if ( b->yy_is_our_buffer )
1012
{
1013
int new_size = b->yy_buf_size * 2;
1014
1015
if ( new_size <= 0 )
1016
b->yy_buf_size += b->yy_buf_size / 8;
1017
else
1018
b->yy_buf_size *= 2;
1019
1020
b->yy_ch_buf = (char *)
1021
/* Include room in for 2 EOB chars. */
1022
yy_flex_realloc( (void *) b->yy_ch_buf,
1023
b->yy_buf_size + 2 );
1024
}
1025
else
1026
/* Can't grow it, we don't own it. */
1027
b->yy_ch_buf = 0;
1028
1029
if ( ! b->yy_ch_buf )
1030
YY_FATAL_ERROR(
1031
"fatal error - scanner input buffer overflow" );
1032
1033
yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1034
1035
num_to_read = yy_current_buffer->yy_buf_size -
1036
number_to_move - 1;
1037
#endif
1038
}
1039
1040
if ( num_to_read > YY_READ_BUF_SIZE )
1041
num_to_read = YY_READ_BUF_SIZE;
1042
1043
/* Read in more data. */
1044
YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1045
yy_n_chars, num_to_read );
1046
1047
yy_current_buffer->yy_n_chars = yy_n_chars;
1048
}
1049
1050
if ( yy_n_chars == 0 )
1051
{
1052
if ( number_to_move == YY_MORE_ADJ )
1053
{
1054
ret_val = EOB_ACT_END_OF_FILE;
1055
yyrestart( yyin );
1056
}
1057
1058
else
1059
{
1060
ret_val = EOB_ACT_LAST_MATCH;
1061
yy_current_buffer->yy_buffer_status =
1062
YY_BUFFER_EOF_PENDING;
1063
}
1064
}
1065
1066
else
1067
ret_val = EOB_ACT_CONTINUE_SCAN;
1068
1069
yy_n_chars += number_to_move;
1070
yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1071
yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1072
1073
yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1074
1075
return ret_val;
1076
}
1077
1078
1079
/* yy_get_previous_state - get the state just before the EOB char was reached */
1080
1081
static yy_state_type yy_get_previous_state()
1082
{
1083
register yy_state_type yy_current_state;
1084
register char *yy_cp;
1085
1086
yy_current_state = yy_start;
1087
1088
for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1089
{
1090
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1091
if ( yy_accept[yy_current_state] )
1092
{
1093
yy_last_accepting_state = yy_current_state;
1094
yy_last_accepting_cpos = yy_cp;
1095
}
1096
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1097
{
1098
yy_current_state = (int) yy_def[yy_current_state];
1099
if ( yy_current_state >= 39 )
1100
yy_c = yy_meta[(unsigned int) yy_c];
1101
}
1102
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1103
}
1104
1105
return yy_current_state;
1106
}
1107
1108
1109
/* yy_try_NUL_trans - try to make a transition on the NUL character
1110
*
1111
* synopsis
1112
* next_state = yy_try_NUL_trans( current_state );
1113
*/
1114
1115
#ifdef YY_USE_PROTOS
1116
static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1117
#else
1118
static yy_state_type yy_try_NUL_trans( yy_current_state )
1119
yy_state_type yy_current_state;
1120
#endif
1121
{
1122
register int yy_is_jam;
1123
register char *yy_cp = yy_c_buf_p;
1124
1125
register YY_CHAR yy_c = 1;
1126
if ( yy_accept[yy_current_state] )
1127
{
1128
yy_last_accepting_state = yy_current_state;
1129
yy_last_accepting_cpos = yy_cp;
1130
}
1131
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1132
{
1133
yy_current_state = (int) yy_def[yy_current_state];
1134
if ( yy_current_state >= 39 )
1135
yy_c = yy_meta[(unsigned int) yy_c];
1136
}
1137
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1138
yy_is_jam = (yy_current_state == 38);
1139
1140
return yy_is_jam ? 0 : yy_current_state;
1141
}
1142
1143
1144
#ifndef YY_NO_UNPUT
1145
#ifdef YY_USE_PROTOS
1146
static void yyunput( int c, register char *yy_bp )
1147
#else
1148
static void yyunput( c, yy_bp )
1149
int c;
1150
register char *yy_bp;
1151
#endif
1152
{
1153
register char *yy_cp = yy_c_buf_p;
1154
1155
/* undo effects of setting up yytext */
1156
*yy_cp = yy_hold_char;
1157
1158
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1159
{ /* need to shift things up to make room */
1160
/* +2 for EOB chars. */
1161
register int number_to_move = yy_n_chars + 2;
1162
register char *dest = &yy_current_buffer->yy_ch_buf[
1163
yy_current_buffer->yy_buf_size + 2];
1164
register char *source =
1165
&yy_current_buffer->yy_ch_buf[number_to_move];
1166
1167
while ( source > yy_current_buffer->yy_ch_buf )
1168
*--dest = *--source;
1169
1170
yy_cp += (int) (dest - source);
1171
yy_bp += (int) (dest - source);
1172
yy_current_buffer->yy_n_chars =
1173
yy_n_chars = yy_current_buffer->yy_buf_size;
1174
1175
if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1176
YY_FATAL_ERROR( "flex scanner push-back overflow" );
1177
}
1178
1179
*--yy_cp = (char) c;
1180
1181
1182
yytext_ptr = yy_bp;
1183
yy_hold_char = *yy_cp;
1184
yy_c_buf_p = yy_cp;
1185
}
1186
#endif /* ifndef YY_NO_UNPUT */
1187
1188
1189
#ifdef __cplusplus
1190
static int yyinput()
1191
#else
1192
static int input()
1193
#endif
1194
{
1195
int c;
1196
1197
*yy_c_buf_p = yy_hold_char;
1198
1199
if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1200
{
1201
/* yy_c_buf_p now points to the character we want to return.
1202
* If this occurs *before* the EOB characters, then it's a
1203
* valid NUL; if not, then we've hit the end of the buffer.
1204
*/
1205
if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1206
/* This was really a NUL. */
1207
*yy_c_buf_p = '\0';
1208
1209
else
1210
{ /* need more input */
1211
int offset = yy_c_buf_p - yytext_ptr;
1212
++yy_c_buf_p;
1213
1214
switch ( yy_get_next_buffer() )
1215
{
1216
case EOB_ACT_LAST_MATCH:
1217
/* This happens because yy_g_n_b()
1218
* sees that we've accumulated a
1219
* token and flags that we need to
1220
* try matching the token before
1221
* proceeding. But for input(),
1222
* there's no matching to consider.
1223
* So convert the EOB_ACT_LAST_MATCH
1224
* to EOB_ACT_END_OF_FILE.
1225
*/
1226
1227
/* Reset buffer status. */
1228
yyrestart( yyin );
1229
1230
/* fall through */
1231
1232
case EOB_ACT_END_OF_FILE:
1233
{
1234
if ( yywrap() )
1235
return EOF;
1236
1237
if ( ! yy_did_buffer_switch_on_eof )
1238
YY_NEW_FILE;
1239
#ifdef __cplusplus
1240
return yyinput();
1241
#else
1242
return input();
1243
#endif
1244
}
1245
1246
case EOB_ACT_CONTINUE_SCAN:
1247
yy_c_buf_p = yytext_ptr + offset;
1248
break;
1249
}
1250
}
1251
}
1252
1253
c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1254
*yy_c_buf_p = '\0'; /* preserve yytext */
1255
yy_hold_char = *++yy_c_buf_p;
1256
1257
1258
return c;
1259
}
1260
1261
1262
#ifdef YY_USE_PROTOS
1263
void yyrestart( FILE *input_file )
1264
#else
1265
void yyrestart( input_file )
1266
FILE *input_file;
1267
#endif
1268
{
1269
if ( ! yy_current_buffer )
1270
yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1271
1272
yy_init_buffer( yy_current_buffer, input_file );
1273
yy_load_buffer_state();
1274
}
1275
1276
1277
#ifdef YY_USE_PROTOS
1278
void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1279
#else
1280
void yy_switch_to_buffer( new_buffer )
1281
YY_BUFFER_STATE new_buffer;
1282
#endif
1283
{
1284
if ( yy_current_buffer == new_buffer )
1285
return;
1286
1287
if ( yy_current_buffer )
1288
{
1289
/* Flush out information for old buffer. */
1290
*yy_c_buf_p = yy_hold_char;
1291
yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1292
yy_current_buffer->yy_n_chars = yy_n_chars;
1293
}
1294
1295
yy_current_buffer = new_buffer;
1296
yy_load_buffer_state();
1297
1298
/* We don't actually know whether we did this switch during
1299
* EOF (yywrap()) processing, but the only time this flag
1300
* is looked at is after yywrap() is called, so it's safe
1301
* to go ahead and always set it.
1302
*/
1303
yy_did_buffer_switch_on_eof = 1;
1304
}
1305
1306
1307
#ifdef YY_USE_PROTOS
1308
void yy_load_buffer_state( void )
1309
#else
1310
void yy_load_buffer_state()
1311
#endif
1312
{
1313
yy_n_chars = yy_current_buffer->yy_n_chars;
1314
yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1315
yyin = yy_current_buffer->yy_input_file;
1316
yy_hold_char = *yy_c_buf_p;
1317
}
1318
1319
1320
#ifdef YY_USE_PROTOS
1321
YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1322
#else
1323
YY_BUFFER_STATE yy_create_buffer( file, size )
1324
FILE *file;
1325
int size;
1326
#endif
1327
{
1328
YY_BUFFER_STATE b;
1329
1330
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1331
if ( ! b )
1332
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1333
1334
b->yy_buf_size = size;
1335
1336
/* yy_ch_buf has to be 2 characters longer than the size given because
1337
* we need to put in 2 end-of-buffer characters.
1338
*/
1339
b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1340
if ( ! b->yy_ch_buf )
1341
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1342
1343
b->yy_is_our_buffer = 1;
1344
1345
yy_init_buffer( b, file );
1346
1347
return b;
1348
}
1349
1350
1351
#ifdef YY_USE_PROTOS
1352
void yy_delete_buffer( YY_BUFFER_STATE b )
1353
#else
1354
void yy_delete_buffer( b )
1355
YY_BUFFER_STATE b;
1356
#endif
1357
{
1358
if ( ! b )
1359
return;
1360
1361
if ( b == yy_current_buffer )
1362
yy_current_buffer = (YY_BUFFER_STATE) 0;
1363
1364
if ( b->yy_is_our_buffer )
1365
yy_flex_free( (void *) b->yy_ch_buf );
1366
1367
yy_flex_free( (void *) b );
1368
}
1369
1370
1371
#ifndef _WIN32
1372
#include <unistd.h>
1373
#else
1374
#ifndef YY_ALWAYS_INTERACTIVE
1375
#ifndef YY_NEVER_INTERACTIVE
1376
extern int isatty YY_PROTO(( int ));
1377
#endif
1378
#endif
1379
#endif
1380
1381
#ifdef YY_USE_PROTOS
1382
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1383
#else
1384
void yy_init_buffer( b, file )
1385
YY_BUFFER_STATE b;
1386
FILE *file;
1387
#endif
1388
1389
1390
{
1391
yy_flush_buffer( b );
1392
1393
b->yy_input_file = file;
1394
b->yy_fill_buffer = 1;
1395
1396
#if YY_ALWAYS_INTERACTIVE
1397
b->yy_is_interactive = 1;
1398
#else
1399
#if YY_NEVER_INTERACTIVE
1400
b->yy_is_interactive = 0;
1401
#else
1402
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1403
#endif
1404
#endif
1405
}
1406
1407
1408
#ifdef YY_USE_PROTOS
1409
void yy_flush_buffer( YY_BUFFER_STATE b )
1410
#else
1411
void yy_flush_buffer( b )
1412
YY_BUFFER_STATE b;
1413
#endif
1414
1415
{
1416
if ( ! b )
1417
return;
1418
1419
b->yy_n_chars = 0;
1420
1421
/* We always need two end-of-buffer characters. The first causes
1422
* a transition to the end-of-buffer state. The second causes
1423
* a jam in that state.
1424
*/
1425
b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1426
b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1427
1428
b->yy_buf_pos = &b->yy_ch_buf[0];
1429
1430
b->yy_at_bol = 1;
1431
b->yy_buffer_status = YY_BUFFER_NEW;
1432
1433
if ( b == yy_current_buffer )
1434
yy_load_buffer_state();
1435
}
1436
1437
1438
#ifndef YY_NO_SCAN_BUFFER
1439
#ifdef YY_USE_PROTOS
1440
YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1441
#else
1442
YY_BUFFER_STATE yy_scan_buffer( base, size )
1443
char *base;
1444
yy_size_t size;
1445
#endif
1446
{
1447
YY_BUFFER_STATE b;
1448
1449
if ( size < 2 ||
1450
base[size-2] != YY_END_OF_BUFFER_CHAR ||
1451
base[size-1] != YY_END_OF_BUFFER_CHAR )
1452
/* They forgot to leave room for the EOB's. */
1453
return 0;
1454
1455
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1456
if ( ! b )
1457
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1458
1459
b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1460
b->yy_buf_pos = b->yy_ch_buf = base;
1461
b->yy_is_our_buffer = 0;
1462
b->yy_input_file = 0;
1463
b->yy_n_chars = b->yy_buf_size;
1464
b->yy_is_interactive = 0;
1465
b->yy_at_bol = 1;
1466
b->yy_fill_buffer = 0;
1467
b->yy_buffer_status = YY_BUFFER_NEW;
1468
1469
yy_switch_to_buffer( b );
1470
1471
return b;
1472
}
1473
#endif
1474
1475
1476
#ifndef YY_NO_SCAN_STRING
1477
#ifdef YY_USE_PROTOS
1478
YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1479
#else
1480
YY_BUFFER_STATE yy_scan_string( yy_str )
1481
yyconst char *yy_str;
1482
#endif
1483
{
1484
int len;
1485
for ( len = 0; yy_str[len]; ++len )
1486
;
1487
1488
return yy_scan_bytes( yy_str, len );
1489
}
1490
#endif
1491
1492
1493
#ifndef YY_NO_SCAN_BYTES
1494
#ifdef YY_USE_PROTOS
1495
YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1496
#else
1497
YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1498
yyconst char *bytes;
1499
int len;
1500
#endif
1501
{
1502
YY_BUFFER_STATE b;
1503
char *buf;
1504
yy_size_t n;
1505
int i;
1506
1507
/* Get memory for full buffer, including space for trailing EOB's. */
1508
n = len + 2;
1509
buf = (char *) yy_flex_alloc( n );
1510
if ( ! buf )
1511
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1512
1513
for ( i = 0; i < len; ++i )
1514
buf[i] = bytes[i];
1515
1516
buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1517
1518
b = yy_scan_buffer( buf, n );
1519
if ( ! b )
1520
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1521
1522
/* It's okay to grow etc. this buffer, and we should throw it
1523
* away when we're done.
1524
*/
1525
b->yy_is_our_buffer = 1;
1526
1527
return b;
1528
}
1529
#endif
1530
1531
1532
#ifndef YY_NO_PUSH_STATE
1533
#ifdef YY_USE_PROTOS
1534
static void yy_push_state( int new_state )
1535
#else
1536
static void yy_push_state( new_state )
1537
int new_state;
1538
#endif
1539
{
1540
if ( yy_start_stack_ptr >= yy_start_stack_depth )
1541
{
1542
yy_size_t new_size;
1543
1544
yy_start_stack_depth += YY_START_STACK_INCR;
1545
new_size = yy_start_stack_depth * sizeof( int );
1546
1547
if ( ! yy_start_stack )
1548
yy_start_stack = (int *) yy_flex_alloc( new_size );
1549
1550
else
1551
yy_start_stack = (int *) yy_flex_realloc(
1552
(void *) yy_start_stack, new_size );
1553
1554
if ( ! yy_start_stack )
1555
YY_FATAL_ERROR(
1556
"out of memory expanding start-condition stack" );
1557
}
1558
1559
yy_start_stack[yy_start_stack_ptr++] = YY_START;
1560
1561
BEGIN(new_state);
1562
}
1563
#endif
1564
1565
1566
#ifndef YY_NO_POP_STATE
1567
static void yy_pop_state()
1568
{
1569
if ( --yy_start_stack_ptr < 0 )
1570
YY_FATAL_ERROR( "start-condition stack underflow" );
1571
1572
BEGIN(yy_start_stack[yy_start_stack_ptr]);
1573
}
1574
#endif
1575
1576
1577
#ifndef YY_NO_TOP_STATE
1578
static int yy_top_state()
1579
{
1580
return yy_start_stack[yy_start_stack_ptr - 1];
1581
}
1582
#endif
1583
1584
#ifndef YY_EXIT_FAILURE
1585
#define YY_EXIT_FAILURE 2
1586
#endif
1587
1588
#ifdef YY_USE_PROTOS
1589
static void yy_fatal_error( yyconst char msg[] )
1590
#else
1591
static void yy_fatal_error( msg )
1592
char msg[];
1593
#endif
1594
{
1595
(void) fprintf( stderr, "%s\n", msg );
1596
exit( YY_EXIT_FAILURE );
1597
}
1598
1599
1600
1601
/* Redefine yyless() so it works in section 3 code. */
1602
1603
#undef yyless
1604
#define yyless(n) \
1605
do \
1606
{ \
1607
/* Undo effects of setting up yytext. */ \
1608
yytext[yyleng] = yy_hold_char; \
1609
yy_c_buf_p = yytext + n; \
1610
yy_hold_char = *yy_c_buf_p; \
1611
*yy_c_buf_p = '\0'; \
1612
yyleng = n; \
1613
} \
1614
while ( 0 )
1615
1616
1617
/* Internal utility routines. */
1618
1619
#ifndef yytext_ptr
1620
#ifdef YY_USE_PROTOS
1621
static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1622
#else
1623
static void yy_flex_strncpy( s1, s2, n )
1624
char *s1;
1625
yyconst char *s2;
1626
int n;
1627
#endif
1628
{
1629
register int i;
1630
for ( i = 0; i < n; ++i )
1631
s1[i] = s2[i];
1632
}
1633
#endif
1634
1635
#ifdef YY_NEED_STRLEN
1636
#ifdef YY_USE_PROTOS
1637
static int yy_flex_strlen( yyconst char *s )
1638
#else
1639
static int yy_flex_strlen( s )
1640
yyconst char *s;
1641
#endif
1642
{
1643
register int n;
1644
for ( n = 0; s[n]; ++n )
1645
;
1646
1647
return n;
1648
}
1649
#endif
1650
1651
1652
#ifdef YY_USE_PROTOS
1653
static void *yy_flex_alloc( yy_size_t size )
1654
#else
1655
static void *yy_flex_alloc( size )
1656
yy_size_t size;
1657
#endif
1658
{
1659
return (void *) malloc( size );
1660
}
1661
1662
#ifdef YY_USE_PROTOS
1663
static void *yy_flex_realloc( void *ptr, yy_size_t size )
1664
#else
1665
static void *yy_flex_realloc( ptr, size )
1666
void *ptr;
1667
yy_size_t size;
1668
#endif
1669
{
1670
/* The cast to (char *) in the following accommodates both
1671
* implementations that use char* generic pointers, and those
1672
* that use void* generic pointers. It works with the latter
1673
* because both ANSI C and C++ allow castless assignment from
1674
* any pointer type to void*, and deal with argument conversions
1675
* as though doing an assignment.
1676
*/
1677
return (void *) realloc( (char *) ptr, size );
1678
}
1679
1680
#ifdef YY_USE_PROTOS
1681
static void yy_flex_free( void *ptr )
1682
#else
1683
static void yy_flex_free( ptr )
1684
void *ptr;
1685
#endif
1686
{
1687
free( ptr );
1688
}
1689
1690
#if YY_MAIN
1691
int main()
1692
{
1693
yylex();
1694
return 0;
1695
}
1696
#endif
1697
#line 108 "calclex.l"
1698
1699
1700
int
1701
yywrap ()
1702
{
1703
return 1;
1704
}
1705
1706