1
/* A Bison parser, made by GNU Bison 1.875a. */
3
/* Skeleton parser for Yacc-like parsing with Bison,
4
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA. */
21
/* As a special exception, when this file is copied by Bison into a
22
Bison output file, you may use that output file without restriction.
23
This special exception was added by the Free Software Foundation
24
in version 1.24 of Bison. */
26
/* Written by Richard Stallman by simplifying the original so called
27
``semantic'' parser. */
29
/* All symbols defined below should begin with yy or YY, to avoid
30
infringing on user name space. This should be done even for local
31
variables, as they might otherwise be expanded by user macros.
32
There are some unavoidable exceptions within include files to
33
define necessary library symbols; they are noted "INFRINGES ON
34
USER NAME SPACE" below. */
36
/* Identify Bison output. */
40
#define YYSKELETON_NAME "yacc.c"
45
/* Using locations. */
46
#define YYLSP_NEEDED 1
48
/* If NAME_PREFIX is specified substitute the variables and functions
50
#define yyparse calib_yyparse
51
#define yylex calib_yylex
52
#define yyerror calib_yyerror
53
#define yylval calib_yylval
54
#define yychar calib_yychar
55
#define yydebug calib_yydebug
56
#define yynerrs calib_yynerrs
57
#define yylloc calib_yylloc
62
/* Put the tokens into the symbol table, so that GDB and other debuggers
80
#define T_DRIVER_NAME 258
81
#define T_BOARD_NAME 259
82
#define T_CALIBRATIONS 260
83
#define T_SUBDEVICE 261
84
#define T_CHANNELS 262
97
/* Copy the first part of user declarations. */
98
#line 1 "calib_yacc.y"
102
code for parsing calibration file, generated by bison
104
Copyright (C) 2003 Frank Mori Hess <fmhess@users.sourceforge.net>
106
This library is free software; you can redistribute it and/or
107
modify it under the terms of the GNU Lesser General Public
108
License as published by the Free Software Foundation, version 2.1
111
This library is distributed in the hope that it will be useful,
112
but WITHOUT ANY WARRANTY; without even the implied warranty of
113
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
114
Lesser General Public License for more details.
116
You should have received a copy of the GNU Lesser General Public
117
License along with this library; if not, write to the Free Software
118
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
123
#include "libinternal.h"
126
#include "calib_yacc.h"
128
#define YYERROR_VERBOSE
129
#define YYPARSE_PARAM parse_arg
133
comedi_calibration_t *parsed_file;
134
comedi_caldac_t caldac;
136
} calib_yyparse_private_t;
140
static inline calib_yyparse_private_t* priv( calib_yyparse_private_t *parse_arg)
145
static void free_calibration_setting( comedi_calibration_setting_t *setting )
147
if( setting->channels );
149
free( setting->channels );
150
setting->channels = NULL;
151
setting->num_channels = 0;
153
if( setting->ranges );
155
free( setting->ranges );
156
setting->ranges = NULL;
157
setting->num_ranges = 0;
159
setting->num_arefs = 0;
160
if( setting->caldacs );
162
free( setting->caldacs );
163
setting->caldacs = NULL;
164
setting->num_caldacs = 0;
168
static void free_settings( comedi_calibration_t *file_contents )
172
if( file_contents->settings == NULL ) return;
174
for( i = 0; i < file_contents->num_settings; i++ )
176
free_calibration_setting( &file_contents->settings[ i ] );
178
file_contents->settings = NULL;
181
static int add_calibration_setting( comedi_calibration_t *file_contents )
183
comedi_calibration_setting_t *temp;
185
temp = realloc( file_contents->settings,
186
( file_contents->num_settings + 1 ) * sizeof( comedi_calibration_setting_t ) );
187
if( temp == NULL ) return -1;
188
file_contents->settings = temp;
189
memset( &file_contents->settings[ file_contents->num_settings ],
190
0, sizeof( comedi_calibration_setting_t ) );
192
file_contents->num_settings++;
196
static comedi_calibration_setting_t* current_setting( calib_yyparse_private_t *priv )
200
while( priv->cal_index >= priv->parsed_file->num_settings )
202
retval = add_calibration_setting( priv->parsed_file );
203
if( retval < 0 ) return NULL;
205
return &priv->parsed_file->settings[ priv->cal_index ];
208
static int add_channel( calib_yyparse_private_t *priv, int channel )
211
comedi_calibration_setting_t *setting;
213
setting = current_setting( priv );
214
if( setting == NULL ) return -1;
216
temp = realloc( setting->channels, ( setting->num_channels + 1 ) * sizeof( int ) );
217
if( temp == NULL ) return -1;
218
setting->channels = temp;
219
setting->channels[ setting->num_channels++ ] = channel;
223
static int add_range( calib_yyparse_private_t *priv, int range )
226
comedi_calibration_setting_t *setting;
228
setting = current_setting( priv );
229
if( setting == NULL ) return -1;
231
temp = realloc( setting->ranges, ( setting->num_ranges + 1 ) * sizeof( int ) );
232
if( temp == NULL ) return -1;
233
setting->ranges = temp;
234
setting->ranges[ setting->num_ranges++ ] = range;
238
static int add_aref( calib_yyparse_private_t *priv, int aref )
240
comedi_calibration_setting_t *setting;
242
setting = current_setting( priv );
243
if( setting == NULL ) return -1;
245
if( setting->num_arefs >= sizeof( setting->arefs ) /
246
sizeof( setting->arefs[ 0 ] ) )
248
setting->arefs[ setting->num_arefs++ ] = aref;
252
static int add_caldac( calib_yyparse_private_t *priv,
253
comedi_caldac_t caldac )
255
comedi_caldac_t *temp;
256
comedi_calibration_setting_t *setting;
258
setting = current_setting( priv );
259
if( setting == NULL ) return -1;
261
temp = realloc( setting->caldacs, ( setting->num_caldacs + 1 ) *
262
sizeof( comedi_caldac_t ) );
263
if( temp == NULL ) return -1;
264
setting->caldacs = temp;
265
setting->caldacs[ setting->num_caldacs++ ] = caldac;
269
static comedi_calibration_t* alloc_calib_parse( void )
271
comedi_calibration_t *file_contents;
273
file_contents = malloc( sizeof( *file_contents ) );
274
if( file_contents == NULL ) return file_contents;
275
memset( file_contents, 0, sizeof( *file_contents ) );
276
return file_contents;
279
EXPORT_ALIAS_DEFAULT(_comedi_cleanup_calibration,comedi_cleanup_calibration,0.7.20);
280
extern void _comedi_cleanup_calibration( comedi_calibration_t *file_contents )
282
if( file_contents->driver_name )
284
free( file_contents->driver_name );
285
file_contents->driver_name = NULL;
287
if( file_contents->board_name )
289
free( file_contents->board_name );
290
file_contents->board_name = NULL;
292
free_settings( file_contents );
293
free( file_contents );
294
file_contents = NULL;
297
EXPORT_ALIAS_DEFAULT(_comedi_parse_calibration_file,comedi_parse_calibration_file,0.7.20);
298
extern comedi_calibration_t* _comedi_parse_calibration_file( const char *cal_file_path )
300
calib_yyparse_private_t priv;
303
if( cal_file_path == NULL ) return NULL;
305
priv.parsed_file = alloc_calib_parse();
306
if( priv.parsed_file == NULL ) return NULL;
309
file = fopen( cal_file_path, "r" );
312
COMEDILIB_DEBUG( 3, "failed to open file\n" );
315
calib_yyrestart( file );
316
if( calib_yyparse( &priv ) )
318
comedi_cleanup_calibration( priv.parsed_file );
319
priv.parsed_file = NULL;
322
return priv.parsed_file;
327
/* Enabling traces. */
332
/* Enabling verbose error messages. */
333
#ifdef YYERROR_VERBOSE
334
# undef YYERROR_VERBOSE
335
# define YYERROR_VERBOSE 1
337
# define YYERROR_VERBOSE 0
340
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
341
#line 232 "calib_yacc.y"
342
typedef union YYSTYPE {
346
/* Line 191 of yacc.c. */
347
#line 348 "calib_yacc.c"
348
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
349
# define YYSTYPE_IS_DECLARED 1
350
# define YYSTYPE_IS_TRIVIAL 1
353
#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
354
typedef struct YYLTYPE
361
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
362
# define YYLTYPE_IS_DECLARED 1
363
# define YYLTYPE_IS_TRIVIAL 1
367
/* Copy the second part of user declarations. */
370
/* Line 214 of yacc.c. */
371
#line 372 "calib_yacc.c"
373
#if ! defined (yyoverflow) || YYERROR_VERBOSE
375
/* The parser invokes alloca or malloc; define the necessary symbols. */
377
# if YYSTACK_USE_ALLOCA
378
# define YYSTACK_ALLOC alloca
380
# ifndef YYSTACK_USE_ALLOCA
381
# if defined (alloca) || defined (_ALLOCA_H)
382
# define YYSTACK_ALLOC alloca
385
# define YYSTACK_ALLOC __builtin_alloca
391
# ifdef YYSTACK_ALLOC
392
/* Pacify GCC's `empty if-body' warning. */
393
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
395
# if defined (__STDC__) || defined (__cplusplus)
396
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
397
# define YYSIZE_T size_t
399
# define YYSTACK_ALLOC malloc
400
# define YYSTACK_FREE free
402
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
405
#if (! defined (yyoverflow) \
406
&& (! defined (__cplusplus) \
407
|| (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
409
/* A type that is properly aligned for any stack member. */
417
/* The size of the maximum gap between one aligned stack and the next. */
418
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
420
/* The size of an array large to enough to hold all stacks, each with
422
# define YYSTACK_BYTES(N) \
423
((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
424
+ 2 * YYSTACK_GAP_MAXIMUM)
426
/* Copy COUNT objects from FROM to TO. The source and destination do
430
# define YYCOPY(To, From, Count) \
431
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
433
# define YYCOPY(To, From, Count) \
436
register YYSIZE_T yyi; \
437
for (yyi = 0; yyi < (Count); yyi++) \
438
(To)[yyi] = (From)[yyi]; \
444
/* Relocate STACK from its old location to the new one. The
445
local variables YYSIZE and YYSTACKSIZE give the old and new number of
446
elements in the stack, and YYPTR gives the new location of the
447
stack. Advance YYPTR to a properly aligned location for the next
449
# define YYSTACK_RELOCATE(Stack) \
452
YYSIZE_T yynewbytes; \
453
YYCOPY (&yyptr->Stack, Stack, yysize); \
454
Stack = &yyptr->Stack; \
455
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
456
yyptr += yynewbytes / sizeof (*yyptr); \
462
#if defined (__STDC__) || defined (__cplusplus)
463
typedef signed char yysigned_char;
465
typedef short yysigned_char;
468
/* YYFINAL -- State number of the termination state. */
470
/* YYLAST -- Last index in YYTABLE. */
473
/* YYNTOKENS -- Number of terminals. */
475
/* YYNNTS -- Number of nonterminals. */
477
/* YYNRULES -- Number of rules. */
479
/* YYNRULES -- Number of states. */
482
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
484
#define YYMAXUTOK 270
486
#define YYTRANSLATE(YYX) \
487
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
489
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
490
static const unsigned char yytranslate[] =
492
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496
2, 2, 2, 2, 18, 2, 2, 2, 2, 2,
497
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501
2, 19, 2, 20, 2, 2, 2, 2, 2, 2,
502
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504
2, 2, 2, 16, 2, 17, 2, 2, 2, 2,
505
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
518
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
523
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
525
static const unsigned char yyprhs[] =
527
0, 0, 3, 7, 9, 10, 12, 16, 20, 24,
528
30, 31, 35, 41, 42, 44, 48, 52, 58, 64,
529
70, 76, 77, 79, 83, 85, 86, 88, 92, 94,
530
95, 97, 101, 103, 104, 108, 114, 115, 117, 121,
534
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
535
static const yysigned_char yyrhs[] =
537
22, 0, -1, 16, 23, 17, -1, 1, -1, -1,
538
24, -1, 24, 18, 23, -1, 3, 15, 14, -1,
539
4, 15, 14, -1, 5, 15, 19, 25, 20, -1,
540
-1, 16, 26, 17, -1, 16, 26, 17, 18, 25,
541
-1, -1, 27, -1, 27, 18, 26, -1, 6, 15,
542
13, -1, 7, 15, 19, 28, 20, -1, 8, 15,
543
19, 30, 20, -1, 9, 15, 19, 32, 20, -1,
544
10, 15, 19, 34, 20, -1, -1, 29, -1, 29,
545
18, 28, -1, 13, -1, -1, 31, -1, 31, 18,
546
30, -1, 13, -1, -1, 33, -1, 33, 18, 32,
547
-1, 13, -1, -1, 16, 35, 17, -1, 16, 35,
548
17, 18, 34, -1, -1, 36, -1, 36, 18, 35,
549
-1, 6, 15, 13, -1, 11, 15, 13, -1, 12,
553
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
554
static const unsigned short yyrline[] =
556
0, 246, 246, 247, 254, 255, 256, 259, 264, 269,
557
272, 273, 274, 277, 278, 279, 282, 289, 290, 291,
558
292, 295, 296, 297, 300, 303, 304, 305, 308, 311,
559
312, 313, 316, 319, 320, 321, 324, 325, 326, 329,
564
#if YYDEBUG || YYERROR_VERBOSE
565
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
566
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
567
static const char *const yytname[] =
569
"$end", "error", "$undefined", "T_DRIVER_NAME", "T_BOARD_NAME",
570
"T_CALIBRATIONS", "T_SUBDEVICE", "T_CHANNELS", "T_RANGES", "T_AREFS",
571
"T_CALDACS", "T_CHANNEL", "T_VALUE", "T_NUMBER", "T_STRING", "T_ASSIGN",
572
"'{'", "'}'", "','", "'['", "']'", "$accept", "input", "hash",
573
"hash_element", "calibrations_array", "calibration_setting",
574
"calibration_setting_element", "channels_array", "channel",
575
"ranges_array", "range", "arefs_array", "aref", "caldacs_array",
576
"caldac", "caldac_element", 0
581
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
583
static const unsigned short yytoknum[] =
585
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
586
265, 266, 267, 268, 269, 270, 123, 125, 44, 91,
591
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
592
static const unsigned char yyr1[] =
594
0, 21, 22, 22, 23, 23, 23, 24, 24, 24,
595
25, 25, 25, 26, 26, 26, 27, 27, 27, 27,
596
27, 28, 28, 28, 29, 30, 30, 30, 31, 32,
597
32, 32, 33, 34, 34, 34, 35, 35, 35, 36,
601
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
602
static const unsigned char yyr2[] =
604
0, 2, 3, 1, 0, 1, 3, 3, 3, 5,
605
0, 3, 5, 0, 1, 3, 3, 5, 5, 5,
606
5, 0, 1, 3, 1, 0, 1, 3, 1, 0,
607
1, 3, 1, 0, 3, 5, 0, 1, 3, 3,
611
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
612
STATE-NUM when YYTABLE doesn't specify something else to do. Zero
613
means the default is an error. */
614
static const unsigned char yydefact[] =
616
0, 3, 4, 0, 0, 0, 0, 0, 5, 1,
617
0, 0, 0, 2, 4, 7, 8, 10, 6, 13,
618
0, 0, 0, 0, 0, 0, 0, 14, 9, 0,
619
0, 0, 0, 0, 11, 13, 16, 21, 25, 29,
620
33, 10, 15, 24, 0, 22, 28, 0, 26, 32,
621
0, 30, 36, 0, 12, 17, 21, 18, 25, 19,
622
29, 0, 0, 0, 0, 37, 20, 23, 27, 31,
623
0, 0, 0, 34, 36, 39, 40, 41, 33, 38,
627
/* YYDEFGOTO[NTERM-NUM]. */
628
static const yysigned_char yydefgoto[] =
630
-1, 3, 7, 8, 20, 26, 27, 44, 45, 47,
631
48, 50, 51, 53, 64, 65
634
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
636
#define YYPACT_NINF -24
637
static const yysigned_char yypact[] =
639
-1, -24, 0, 13, -13, 1, 3, -3, 4, -24,
640
5, 6, -2, -24, 0, -24, -24, 7, -24, 2,
641
8, 9, 10, 11, 12, 14, 15, 16, -24, 17,
642
18, 19, 20, 21, 23, 2, -24, 22, 29, 30,
643
28, 7, -24, -24, 25, 31, -24, 26, 32, -24,
644
27, 33, -5, 34, -24, -24, 22, -24, 29, -24,
645
30, 37, 38, 40, 39, 41, -24, -24, -24, -24,
646
35, 44, 45, 42, -5, -24, -24, -24, 28, -24,
650
/* YYPGOTO[NTERM-NUM]. */
651
static const yysigned_char yypgoto[] =
653
-24, -24, 47, -24, -20, -4, -24, -23, -24, -22,
654
-24, 24, -24, -16, -11, -24
657
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
658
positive, shift that token. If negative, reduce the rule which
659
number is the opposite. If zero, do what YYDEFACT says.
660
If YYTABLE_NINF, syntax error. */
661
#define YYTABLE_NINF -1
662
static const unsigned char yytable[] =
664
1, 61, 10, 4, 5, 6, 62, 63, 21, 22,
665
23, 24, 25, 9, 13, 2, 11, 17, 12, 15,
666
16, 54, 14, 19, 29, 30, 31, 32, 28, 33,
667
36, 42, 34, 67, 35, 43, 68, 37, 38, 39,
668
40, 41, 46, 49, 52, 55, 57, 59, 75, 56,
669
58, 60, 70, 71, 66, 72, 73, 76, 77, 74,
670
78, 18, 80, 79, 0, 0, 0, 0, 0, 0,
671
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
675
static const yysigned_char yycheck[] =
677
1, 6, 15, 3, 4, 5, 11, 12, 6, 7,
678
8, 9, 10, 0, 17, 16, 15, 19, 15, 14,
679
14, 41, 18, 16, 15, 15, 15, 15, 20, 15,
680
13, 35, 17, 56, 18, 13, 58, 19, 19, 19,
681
19, 18, 13, 13, 16, 20, 20, 20, 13, 18,
682
18, 18, 15, 15, 20, 15, 17, 13, 13, 18,
683
18, 14, 78, 74, -1, -1, -1, -1, -1, -1,
684
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
688
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
689
symbol of state STATE-NUM. */
690
static const unsigned char yystos[] =
692
0, 1, 16, 22, 3, 4, 5, 23, 24, 0,
693
15, 15, 15, 17, 18, 14, 14, 19, 23, 16,
694
25, 6, 7, 8, 9, 10, 26, 27, 20, 15,
695
15, 15, 15, 15, 17, 18, 13, 19, 19, 19,
696
19, 18, 26, 13, 28, 29, 13, 30, 31, 13,
697
32, 33, 16, 34, 25, 20, 18, 20, 18, 20,
698
18, 6, 11, 12, 35, 36, 20, 28, 30, 32,
699
15, 15, 15, 17, 18, 13, 13, 13, 18, 35,
703
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
704
# define YYSIZE_T __SIZE_TYPE__
706
#if ! defined (YYSIZE_T) && defined (size_t)
707
# define YYSIZE_T size_t
709
#if ! defined (YYSIZE_T)
710
# if defined (__STDC__) || defined (__cplusplus)
711
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
712
# define YYSIZE_T size_t
715
#if ! defined (YYSIZE_T)
716
# define YYSIZE_T unsigned int
719
#define yyerrok (yyerrstatus = 0)
720
#define yyclearin (yychar = YYEMPTY)
724
#define YYACCEPT goto yyacceptlab
725
#define YYABORT goto yyabortlab
729
*++yylerrsp = yyloc; \
735
/* Like YYERROR except do call yyerror. This remains here temporarily
736
to ease the transition to the new meaning of YYERROR, for GCC.
737
Once GCC version 2 has supplanted version 1, this can go. */
739
#define YYFAIL goto yyerrlab
741
#define YYRECOVERING() (!!yyerrstatus)
743
#define YYBACKUP(Token, Value) \
745
if (yychar == YYEMPTY && yylen == 1) \
749
yytoken = YYTRANSLATE (yychar); \
755
yyerror ("syntax error: cannot back up");\
761
#define YYERRCODE 256
763
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
766
#ifndef YYLLOC_DEFAULT
767
# define YYLLOC_DEFAULT(Current, Rhs, N) \
768
Current.first_line = Rhs[1].first_line; \
769
Current.first_column = Rhs[1].first_column; \
770
Current.last_line = Rhs[N].last_line; \
771
Current.last_column = Rhs[N].last_column;
774
/* YYLEX -- calling `yylex' with the right arguments. */
777
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
779
# define YYLEX yylex (&yylval, &yylloc)
782
/* Enable debugging if requested. */
786
# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
787
# define YYFPRINTF fprintf
790
# define YYDPRINTF(Args) \
796
# define YYDSYMPRINT(Args) \
802
# define YYDSYMPRINTF(Title, Token, Value, Location) \
806
YYFPRINTF (stderr, "%s ", Title); \
807
yysymprint (stderr, \
808
Token, Value, Location); \
809
YYFPRINTF (stderr, "\n"); \
813
/*------------------------------------------------------------------.
814
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
816
`------------------------------------------------------------------*/
818
#if defined (__STDC__) || defined (__cplusplus)
820
yy_stack_print (short *bottom, short *top)
823
yy_stack_print (bottom, top)
828
YYFPRINTF (stderr, "Stack now");
829
for (/* Nothing. */; bottom <= top; ++bottom)
830
YYFPRINTF (stderr, " %d", *bottom);
831
YYFPRINTF (stderr, "\n");
834
# define YY_STACK_PRINT(Bottom, Top) \
837
yy_stack_print ((Bottom), (Top)); \
841
/*------------------------------------------------.
842
| Report that the YYRULE is going to be reduced. |
843
`------------------------------------------------*/
845
#if defined (__STDC__) || defined (__cplusplus)
847
yy_reduce_print (int yyrule)
850
yy_reduce_print (yyrule)
855
unsigned int yylineno = yyrline[yyrule];
856
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
857
yyrule - 1, yylineno);
858
/* Print the symbols being reduced, and their result. */
859
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
860
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
861
YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
864
# define YY_REDUCE_PRINT(Rule) \
867
yy_reduce_print (Rule); \
870
/* Nonzero means print parse trace. It is left uninitialized so that
871
multiple parsers can coexist. */
874
# define YYDPRINTF(Args)
875
# define YYDSYMPRINT(Args)
876
# define YYDSYMPRINTF(Title, Token, Value, Location)
877
# define YY_STACK_PRINT(Bottom, Top)
878
# define YY_REDUCE_PRINT(Rule)
879
#endif /* !YYDEBUG */
882
/* YYINITDEPTH -- initial size of the parser's stacks. */
884
# define YYINITDEPTH 200
887
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
888
if the built-in stack extension method is used).
890
Do not make this value too large; the results are undefined if
891
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
892
evaluated with infinite-precision integer arithmetic. */
899
# define YYMAXDEPTH 10000
907
# if defined (__GLIBC__) && defined (_STRING_H)
908
# define yystrlen strlen
910
/* Return the length of YYSTR. */
912
# if defined (__STDC__) || defined (__cplusplus)
913
yystrlen (const char *yystr)
919
register const char *yys = yystr;
921
while (*yys++ != '\0')
924
return yys - yystr - 1;
930
# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
931
# define yystpcpy stpcpy
933
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
936
# if defined (__STDC__) || defined (__cplusplus)
937
yystpcpy (char *yydest, const char *yysrc)
939
yystpcpy (yydest, yysrc)
944
register char *yyd = yydest;
945
register const char *yys = yysrc;
947
while ((*yyd++ = *yys++) != '\0')
955
#endif /* !YYERROR_VERBOSE */
960
/*--------------------------------.
961
| Print this symbol on YYOUTPUT. |
962
`--------------------------------*/
964
#if defined (__STDC__) || defined (__cplusplus)
966
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
969
yysymprint (yyoutput, yytype, yyvaluep, yylocationp)
973
YYLTYPE *yylocationp;
976
/* Pacify ``unused variable'' warnings. */
980
if (yytype < YYNTOKENS)
982
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
984
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
988
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
995
YYFPRINTF (yyoutput, ")");
998
#endif /* ! YYDEBUG */
999
/*-----------------------------------------------.
1000
| Release the memory associated to this symbol. |
1001
`-----------------------------------------------*/
1003
#if defined (__STDC__) || defined (__cplusplus)
1005
yydestruct (int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1008
yydestruct (yytype, yyvaluep, yylocationp)
1011
YYLTYPE *yylocationp;
1014
/* Pacify ``unused variable'' warnings. */
1027
/* Prevent warnings from -Wmissing-prototypes. */
1029
#ifdef YYPARSE_PARAM
1030
# if defined (__STDC__) || defined (__cplusplus)
1031
int yyparse (void *YYPARSE_PARAM);
1035
#else /* ! YYPARSE_PARAM */
1036
#if defined (__STDC__) || defined (__cplusplus)
1041
#endif /* ! YYPARSE_PARAM */
1052
#ifdef YYPARSE_PARAM
1053
# if defined (__STDC__) || defined (__cplusplus)
1054
int yyparse (void *YYPARSE_PARAM)
1056
int yyparse (YYPARSE_PARAM)
1057
void *YYPARSE_PARAM;
1059
#else /* ! YYPARSE_PARAM */
1060
#if defined (__STDC__) || defined (__cplusplus)
1070
/* The lookahead symbol. */
1073
/* The semantic value of the lookahead symbol. */
1076
/* Number of syntax errors so far. */
1078
/* Location data for the lookahead symbol. */
1081
register int yystate;
1084
/* Number of tokens to shift before error messages enabled. */
1086
/* Lookahead token as an internal (translated) token number. */
1089
/* Three stacks and their tools:
1090
`yyss': related to states,
1091
`yyvs': related to semantic values,
1092
`yyls': related to locations.
1094
Refer to the stacks thru separate pointers, to allow yyoverflow
1095
to reallocate them elsewhere. */
1097
/* The state stack. */
1098
short yyssa[YYINITDEPTH];
1099
short *yyss = yyssa;
1100
register short *yyssp;
1102
/* The semantic value stack. */
1103
YYSTYPE yyvsa[YYINITDEPTH];
1104
YYSTYPE *yyvs = yyvsa;
1105
register YYSTYPE *yyvsp;
1107
/* The location stack. */
1108
YYLTYPE yylsa[YYINITDEPTH];
1109
YYLTYPE *yyls = yylsa;
1113
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1115
YYSIZE_T yystacksize = YYINITDEPTH;
1117
/* The variables used to return semantic value and location from the
1122
/* When reducing, the number of symbols on the RHS of the reduced
1126
YYDPRINTF ((stderr, "Starting parse\n"));
1131
yychar = YYEMPTY; /* Cause a token to be read. */
1133
/* Initialize stack pointers.
1134
Waste one element of value and location stack
1135
so that they stay on the same level as the state stack.
1136
The wasted elements are never initialized. */
1143
/*------------------------------------------------------------.
1144
| yynewstate -- Push a new state, which is found in yystate. |
1145
`------------------------------------------------------------*/
1147
/* In all cases, when you get here, the value and location stacks
1148
have just been pushed. so pushing a state here evens the stacks.
1155
if (yyss + yystacksize - 1 <= yyssp)
1157
/* Get the current used size of the three stacks, in elements. */
1158
YYSIZE_T yysize = yyssp - yyss + 1;
1162
/* Give user a chance to reallocate the stack. Use copies of
1163
these so that the &'s don't force the real ones into
1165
YYSTYPE *yyvs1 = yyvs;
1166
short *yyss1 = yyss;
1167
YYLTYPE *yyls1 = yyls;
1169
/* Each stack pointer address is followed by the size of the
1170
data in use in that stack, in bytes. This used to be a
1171
conditional around just the two extra args, but that might
1172
be undefined if yyoverflow is a macro. */
1173
yyoverflow ("parser stack overflow",
1174
&yyss1, yysize * sizeof (*yyssp),
1175
&yyvs1, yysize * sizeof (*yyvsp),
1176
&yyls1, yysize * sizeof (*yylsp),
1182
#else /* no yyoverflow */
1183
# ifndef YYSTACK_RELOCATE
1186
/* Extend the stack our own way. */
1187
if (YYMAXDEPTH <= yystacksize)
1190
if (YYMAXDEPTH < yystacksize)
1191
yystacksize = YYMAXDEPTH;
1194
short *yyss1 = yyss;
1195
union yyalloc *yyptr =
1196
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1199
YYSTACK_RELOCATE (yyss);
1200
YYSTACK_RELOCATE (yyvs);
1201
YYSTACK_RELOCATE (yyls);
1202
# undef YYSTACK_RELOCATE
1204
YYSTACK_FREE (yyss1);
1207
#endif /* no yyoverflow */
1209
yyssp = yyss + yysize - 1;
1210
yyvsp = yyvs + yysize - 1;
1211
yylsp = yyls + yysize - 1;
1213
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1214
(unsigned long int) yystacksize));
1216
if (yyss + yystacksize - 1 <= yyssp)
1220
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1229
/* Do appropriate processing given the current state. */
1230
/* Read a lookahead token if we need one and don't already have one. */
1233
/* First try to decide what to do without reference to lookahead token. */
1235
yyn = yypact[yystate];
1236
if (yyn == YYPACT_NINF)
1239
/* Not known => get a lookahead token if don't already have one. */
1241
/* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1242
if (yychar == YYEMPTY)
1244
YYDPRINTF ((stderr, "Reading a token: "));
1248
if (yychar <= YYEOF)
1250
yychar = yytoken = YYEOF;
1251
YYDPRINTF ((stderr, "Now at end of input.\n"));
1255
yytoken = YYTRANSLATE (yychar);
1256
YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1259
/* If the proper action on seeing token YYTOKEN is to reduce or to
1260
detect an error, take that action. */
1262
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1267
if (yyn == 0 || yyn == YYTABLE_NINF)
1276
/* Shift the lookahead token. */
1277
YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1279
/* Discard the token being shifted unless it is eof. */
1280
if (yychar != YYEOF)
1286
/* Count tokens shifted since error; after three, turn off error
1295
/*-----------------------------------------------------------.
1296
| yydefault -- do the default action for the current state. |
1297
`-----------------------------------------------------------*/
1299
yyn = yydefact[yystate];
1305
/*-----------------------------.
1306
| yyreduce -- Do a reduction. |
1307
`-----------------------------*/
1309
/* yyn is the number of a rule to reduce with. */
1312
/* If YYLEN is nonzero, implement the default value of the action:
1315
Otherwise, the following line sets YYVAL to garbage.
1316
This behavior is undocumented and Bison
1317
users should not rely upon it. Assigning to YYVAL
1318
unconditionally makes the parser a bit smaller, and it avoids a
1319
GCC warning that YYVAL may be used uninitialized. */
1320
yyval = yyvsp[1-yylen];
1322
/* Default location. */
1323
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1324
YY_REDUCE_PRINT (yyn);
1328
#line 248 "calib_yacc.y"
1330
fprintf(stderr, "input error on line %i\n", yylsp[0].first_line );
1336
#line 260 "calib_yacc.y"
1338
if( priv(parse_arg)->parsed_file->driver_name != NULL ) YYABORT;
1339
priv(parse_arg)->parsed_file->driver_name = strdup( yyvsp[0].sval );
1344
#line 265 "calib_yacc.y"
1346
if( priv(parse_arg)->parsed_file->board_name != NULL ) YYABORT;
1347
priv(parse_arg)->parsed_file->board_name = strdup( yyvsp[0].sval );
1352
#line 277 "calib_yacc.y"
1353
{ priv(parse_arg)->cal_index++; }
1357
#line 278 "calib_yacc.y"
1358
{ priv(parse_arg)->cal_index++; }
1362
#line 283 "calib_yacc.y"
1364
comedi_calibration_setting_t *setting;
1365
setting = current_setting( parse_arg );
1366
if( setting == NULL ) YYABORT;
1367
setting->subdevice = yyvsp[0].ival;
1372
#line 300 "calib_yacc.y"
1373
{ add_channel( parse_arg, yyvsp[0].ival ); }
1377
#line 308 "calib_yacc.y"
1378
{ add_range( parse_arg, yyvsp[0].ival ); }
1382
#line 316 "calib_yacc.y"
1383
{ add_aref( parse_arg, yyvsp[0].ival ); }
1387
#line 324 "calib_yacc.y"
1388
{ add_caldac( parse_arg, priv(parse_arg)->caldac ); }
1392
#line 325 "calib_yacc.y"
1393
{ add_caldac( parse_arg, priv(parse_arg)->caldac ); }
1397
#line 329 "calib_yacc.y"
1398
{ priv(parse_arg)->caldac.subdevice = yyvsp[0].ival; }
1402
#line 330 "calib_yacc.y"
1403
{ priv(parse_arg)->caldac.channel = yyvsp[0].ival; }
1407
#line 331 "calib_yacc.y"
1408
{ priv(parse_arg)->caldac.value = yyvsp[0].ival; }
1414
/* Line 999 of yacc.c. */
1415
#line 1416 "calib_yacc.c"
1421
YY_STACK_PRINT (yyss, yyssp);
1426
/* Now `shift' the result of the reduction. Determine what state
1427
that goes to, based on the state we popped back to and the rule
1428
number reduced by. */
1432
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1433
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1434
yystate = yytable[yystate];
1436
yystate = yydefgoto[yyn - YYNTOKENS];
1441
/*------------------------------------.
1442
| yyerrlab -- here on detecting error |
1443
`------------------------------------*/
1445
/* If not already recovering from an error, report this error. */
1450
yyn = yypact[yystate];
1452
if (YYPACT_NINF < yyn && yyn < YYLAST)
1454
YYSIZE_T yysize = 0;
1455
int yytype = YYTRANSLATE (yychar);
1460
/* Start YYX at -YYN if negative to avoid negative indexes in
1462
for (yyx = yyn < 0 ? -yyn : 0;
1463
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1464
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1465
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1466
yysize += yystrlen ("syntax error, unexpected ") + 1;
1467
yysize += yystrlen (yytname[yytype]);
1468
yymsg = (char *) YYSTACK_ALLOC (yysize);
1471
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1472
yyp = yystpcpy (yyp, yytname[yytype]);
1477
for (yyx = yyn < 0 ? -yyn : 0;
1478
yyx < (int) (sizeof (yytname) / sizeof (char *));
1480
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1482
const char *yyq = ! yycount ? ", expecting " : " or ";
1483
yyp = yystpcpy (yyp, yyq);
1484
yyp = yystpcpy (yyp, yytname[yyx]);
1489
YYSTACK_FREE (yymsg);
1492
yyerror ("syntax error; also virtual memory exhausted");
1495
#endif /* YYERROR_VERBOSE */
1496
yyerror ("syntax error");
1501
if (yyerrstatus == 3)
1503
/* If just tried and failed to reuse lookahead token after an
1504
error, discard it. */
1506
/* Return failure if at end of input. */
1507
if (yychar == YYEOF)
1509
/* Pop the error token. */
1511
/* Pop the rest of the stack. */
1512
while (yyss < yyssp)
1514
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1515
yydestruct (yystos[*yyssp], yyvsp, yylsp);
1521
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1522
yydestruct (yytoken, &yylval, &yylloc);
1524
*++yylerrsp = yylloc;
1527
/* Else will try to reuse lookahead token after shifting the error
1532
/*----------------------------------------------------.
1533
| yyerrlab1 -- error raised explicitly by an action. |
1534
`----------------------------------------------------*/
1536
yyerrstatus = 3; /* Each real token shifted decrements this. */
1540
yyn = yypact[yystate];
1541
if (yyn != YYPACT_NINF)
1544
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1552
/* Pop the current state because it cannot handle the error token. */
1556
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1557
yydestruct (yystos[yystate], yyvsp, yylsp);
1561
YY_STACK_PRINT (yyss, yyssp);
1567
YYDPRINTF ((stderr, "Shifting error token, "));
1570
YYLLOC_DEFAULT (yyloc, yylsp, (yylerrsp - yylsp));
1577
/*-------------------------------------.
1578
| yyacceptlab -- YYACCEPT comes here. |
1579
`-------------------------------------*/
1584
/*-----------------------------------.
1585
| yyabortlab -- YYABORT comes here. |
1586
`-----------------------------------*/
1592
/*----------------------------------------------.
1593
| yyoverflowlab -- parser overflow comes here. |
1594
`----------------------------------------------*/
1596
yyerror ("parser stack overflow");
1604
YYSTACK_FREE (yyss);
1610
#line 334 "calib_yacc.y"
1613
void calib_yyerror(char *s)
1615
fprintf(stderr, "%s\n", s);