File: ergo_input_processor.c

package info (click to toggle)
ergo 3.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 17,396 kB
  • sloc: cpp: 94,740; ansic: 17,015; sh: 7,559; makefile: 1,402; yacc: 127; lex: 110; awk: 23
file content (794 lines) | stat: -rw-r--r-- 24,851 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
/* original parser id follows */
/* yysccsid[] = "@(#)yaccpar	1.9 (Berkeley) 02/21/93" */
/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */

#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYPATCH 20140715

#define YYEMPTY        (-1)
#define yyclearin      (yychar = YYEMPTY)
#define yyerrok        (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#define YYENOMEM       (-2)
#define YYEOF          0
#define YYPREFIX "yy"

#define YYPURE 0

#line 2 "ergo_input_processor.y"

  /** @file ergo_input_processor.c Parses the input.
      Uses bison code generator to generate the parses.
  */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "ergo_scripted.h"
#define YYERROR_VERBOSE
int yylex(void);
int yyerror(const char *s);
static const char *last_token = NULL;

#line 18 "ergo_input_processor.y"
#ifdef YYSTYPE
#undef  YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#endif
#ifndef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
typedef union {
  double num;     /* for returning numbers */
  char str[256];  /* for returning strings */
  struct variable *var; /* for returning lvalues */
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
#line 49 "ergo_input_processor.c"

/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
#  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
#  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif

/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif

/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif

extern int YYPARSE_DECL();

#define NUMBER 257
#define DOT 258
#define SYMBOL 259
#define EQUAL 260
#define STRING 261
#define EOFTAG 262
#define GETEXC 263
#define GETPOL 264
#define K_ALL 265
#define HELP 266
#define MOLTAG 267
#define GHOSTTAG 268
#define MOLDAL 269
#define QUIT 270
#define RUNTAG 271
#define SYSTEM 272
#define GHOST 273
#define ANGSTROM 274
#define PRECISION 275
#define RANGE 276
#define WARRANTY 277
#define LIST_DFT_FUNCS 278
#define IS_CHT_USED 279
#define SET_NTHREADS 280
#define PLUS 281
#define MINUS 282
#define TIMES 283
#define DIVIDE 284
#define POWER 285
#define LEFT_PARENTHESIS 286
#define RIGHT_PARENTHESIS 287
#define EOL 288
#define NEG 289
#define YYERRCODE 256
typedef short YYINT;
static const YYINT yylhs[] = {                           -1,
    0,    0,    0,    3,    3,    3,    3,    4,    4,    2,
    2,    5,    5,    5,    5,    5,    5,    5,    5,    5,
    5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
    5,    5,    5,    6,    6,    7,    1,    1,    1,    1,
    1,    1,    1,    1,
};
static const YYINT yylen[] = {                            2,
    0,    1,    3,    0,    1,    1,    1,    3,    3,    1,
    3,    3,    4,    3,    4,    1,    2,    1,    1,    1,
    2,    3,    2,    4,    4,    2,    1,    3,    4,    4,
    1,    6,    7,    1,    2,    5,    1,    3,    3,    3,
    3,    2,    3,    3,
};
static const YYINT yydefred[] = {                         0,
    7,   10,    0,    0,    0,    0,    0,    0,   31,    0,
    0,   20,    0,   27,   18,   19,    0,    0,    0,    0,
    5,    6,    0,    0,    0,    0,    0,    0,    0,   21,
    0,   23,   26,    0,    0,    0,    0,    0,    0,   28,
    0,    0,    0,    0,   34,   12,    0,    0,   14,   22,
    0,    0,   37,    0,    0,    0,    0,   11,    9,    0,
    3,   29,   30,   13,    0,   35,   15,    0,    0,   25,
    0,    0,    0,    0,    0,    0,    0,   24,    0,    0,
    0,   44,    0,    0,    0,    0,    0,    0,   32,    0,
   36,   33,
};
static const YYINT yydgoto[] = {                         18,
   57,   19,   20,   21,   22,   46,   47,
};
static const YYINT yysindex[] = {                      -210,
    0,    0, -256, -248, -255, -264, -253, -198,    0, -219,
 -217,    0, -257,    0,    0,    0, -241,    0, -224, -238,
    0,    0, -206, -165, -203, -214, -251, -207, -251,    0,
 -178,    0,    0, -196, -168, -239, -162, -234, -210,    0,
 -159, -158, -251, -156,    0,    0, -251, -251,    0,    0,
 -155, -157,    0, -183, -254, -254, -205,    0,    0, -190,
    0,    0,    0,    0, -152,    0,    0, -151, -150,    0,
 -177, -197, -254, -254, -254, -254, -254,    0, -148, -149,
 -147,    0, -212, -212, -177, -177, -177, -175,    0, -146,
    0,    0,
};
static const YYINT yyrindex[] = {                         6,
    0,    0,    0,    0,    7,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,  111,
    0,    0,    0,    0,   14,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    6,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,   15,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    1,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,   29,   33,    9,   17,   25,    0,    0,    0,
    0,    0,
};
static const YYINT yygindex[] = {                        75,
  -36,  112,    0,    0,    0,  -17,    0,
};
#define YYTABLESIZE 321
static const YYINT yytable[] = {                         34,
   42,   60,   53,    2,   23,    1,   16,   44,   40,   26,
   45,   49,   24,   17,    8,   35,   41,   53,   71,   72,
   28,   54,   53,   27,   43,   64,   59,   55,   38,   66,
   67,   56,   39,   37,   29,   38,   83,   84,   85,   86,
   87,   32,   55,   33,   36,    1,   56,   55,    2,   39,
   40,   56,    3,    4,   37,    5,    6,    7,    8,    9,
   10,   11,   30,   51,   12,   13,   14,   15,   16,   17,
   75,   76,   77,   43,   31,   73,   74,   75,   76,   77,
   48,   78,   50,   73,   74,   75,   76,   77,   52,   82,
   73,   74,   75,   76,   77,   41,   58,   62,   63,   42,
   65,   68,   69,   70,   79,   80,   81,   77,   88,   90,
    2,   89,   91,   61,   92,    0,   25,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    0,   42,   42,   42,   42,    0,    0,   42,   42,   40,
   40,   40,   40,    4,   16,   40,   40,   41,   41,   41,
   41,   17,    8,   41,   41,   43,   43,   43,   43,   38,
   38,   43,   43,   39,   39,   38,   38,    0,    0,   39,
   39,
};
static const YYINT yycheck[] = {                        257,
    0,   38,  257,  259,  261,    0,    0,  259,    0,  274,
  262,   29,  261,    0,    0,  273,    0,  257,   55,   56,
  274,  261,  257,  288,    0,   43,  261,  282,    0,   47,
   48,  286,    0,  258,  288,  260,   73,   74,   75,   76,
   77,  261,  282,  261,  286,  256,  286,  282,  259,  288,
  257,  286,  263,  264,  258,  266,  267,  268,  269,  270,
  271,  272,  261,  260,  275,  276,  277,  278,  279,  280,
  283,  284,  285,  288,  273,  281,  282,  283,  284,  285,
  288,  287,  261,  281,  282,  283,  284,  285,  257,  287,
  281,  282,  283,  284,  285,  261,  259,  257,  257,  265,
  257,  257,  260,  287,  257,  257,  257,  285,  257,  257,
    0,  261,  288,   39,  261,   -1,    5,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
   -1,  281,  282,  283,  284,   -1,   -1,  287,  288,  281,
  282,  283,  284,  288,  288,  287,  288,  281,  282,  283,
  284,  288,  288,  287,  288,  281,  282,  283,  284,  281,
  282,  287,  288,  281,  282,  287,  288,   -1,   -1,  287,
  288,
};
#define YYFINAL 18
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 289
#define YYUNDFTOKEN 299
#define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
#if YYDEBUG
static const char *const yyname[] = {

"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","DOT","SYMBOL","EQUAL",
"STRING","EOFTAG","GETEXC","GETPOL","K_ALL","HELP","MOLTAG","GHOSTTAG","MOLDAL",
"QUIT","RUNTAG","SYSTEM","GHOST","ANGSTROM","PRECISION","RANGE","WARRANTY",
"LIST_DFT_FUNCS","IS_CHT_USED","SET_NTHREADS","PLUS","MINUS","TIMES","DIVIDE",
"POWER","LEFT_PARENTHESIS","RIGHT_PARENTHESIS","EOL","NEG",0,0,0,0,0,0,0,0,0,
"illegal-symbol",
};
static const char *const yyrule[] = {
"$accept : Input",
"Input :",
"Input : Line",
"Input : Line EOL Input",
"Line :",
"Line : Assignment",
"Line : Command",
"Line : error",
"Assignment : Lvalue EQUAL Expression",
"Assignment : Lvalue EQUAL STRING",
"Lvalue : SYMBOL",
"Lvalue : Lvalue DOT SYMBOL",
"Command : MOLTAG EOL Molinput",
"Command : MOLTAG ANGSTROM EOL Molinput",
"Command : GHOSTTAG EOL Molinput",
"Command : GHOSTTAG ANGSTROM EOL Molinput",
"Command : HELP",
"Command : HELP Lvalue",
"Command : LIST_DFT_FUNCS",
"Command : IS_CHT_USED",
"Command : PRECISION",
"Command : MOLDAL STRING",
"Command : MOLDAL GHOST STRING",
"Command : RUNTAG STRING",
"Command : SET_NTHREADS LEFT_PARENTHESIS Expression RIGHT_PARENTHESIS",
"Command : SET_NTHREADS LEFT_PARENTHESIS STRING RIGHT_PARENTHESIS",
"Command : SYSTEM STRING",
"Command : WARRANTY",
"Command : GETEXC STRING NUMBER",
"Command : GETPOL STRING STRING NUMBER",
"Command : GETPOL STRING K_ALL NUMBER",
"Command : QUIT",
"Command : RANGE NUMBER EQUAL NUMBER NUMBER STRING",
"Command : RANGE GHOST NUMBER EQUAL NUMBER NUMBER STRING",
"Molinput : EOFTAG",
"Molinput : Molline Molinput",
"Molline : SYMBOL NUMBER NUMBER NUMBER EOL",
"Expression : NUMBER",
"Expression : Expression PLUS Expression",
"Expression : Expression MINUS Expression",
"Expression : Expression TIMES Expression",
"Expression : Expression DIVIDE Expression",
"Expression : MINUS Expression",
"Expression : Expression POWER Expression",
"Expression : LEFT_PARENTHESIS Expression RIGHT_PARENTHESIS",

};
#endif

int      yydebug;
int      yynerrs;

int      yyerrflag;
int      yychar;
YYSTYPE  yyval;
YYSTYPE  yylval;

/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH  YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 10000
#define YYMAXDEPTH  10000
#endif
#endif

#define YYINITSTACKSIZE 200

typedef struct {
    unsigned stacksize;
    YYINT    *s_base;
    YYINT    *s_mark;
    YYINT    *s_last;
    YYSTYPE  *l_base;
    YYSTYPE  *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 132 "ergo_input_processor.y"

YYSTYPE yylval;
int ergo_scanner_lineno = 1;
int ergo_scanner_reading_stdin = 0;

int yyerror(const char *s) {
  if (last_token) {
    printf("line %d: %s at '%s'\n",ergo_scanner_lineno, s, last_token);
    last_token = NULL;
  } else {
    printf("line %d: %s\n",ergo_scanner_lineno, s);
  }
  return !ergo_scanner_reading_stdin;
}

#ifdef SCANNER_TEST
int main(void) {
  yyparse();
}
#endif
#line 371 "ergo_input_processor.c"

#if YYDEBUG
#include <stdio.h>		/* needed for printf */
#endif

#include <stdlib.h>	/* needed for malloc, etc */
#include <string.h>	/* needed for memset */

/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
    int i;
    unsigned newsize;
    YYINT *newss;
    YYSTYPE *newvs;

    if ((newsize = data->stacksize) == 0)
        newsize = YYINITSTACKSIZE;
    else if (newsize >= YYMAXDEPTH)
        return YYENOMEM;
    else if ((newsize *= 2) > YYMAXDEPTH)
        newsize = YYMAXDEPTH;

    i = (int) (data->s_mark - data->s_base);
    newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
    if (newss == 0)
        return YYENOMEM;

    data->s_base = newss;
    data->s_mark = newss + i;

    newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
    if (newvs == 0)
        return YYENOMEM;

    data->l_base = newvs;
    data->l_mark = newvs + i;

    data->stacksize = newsize;
    data->s_last = data->s_base + newsize - 1;
    return 0;
}

#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
    free(data->s_base);
    free(data->l_base);
    memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif

#define YYABORT  goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR  goto yyerrlab

int
YYPARSE_DECL()
{
    int yym, yyn, yystate;
#if YYDEBUG
    const char *yys;

    if ((yys = getenv("YYDEBUG")) != 0)
    {
        yyn = *yys;
        if (yyn >= '0' && yyn <= '9')
            yydebug = yyn - '0';
    }
#endif

    yynerrs = 0;
    yyerrflag = 0;
    yychar = YYEMPTY;
    yystate = 0;

#if YYPURE
    memset(&yystack, 0, sizeof(yystack));
#endif

    if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
    yystack.s_mark = yystack.s_base;
    yystack.l_mark = yystack.l_base;
    yystate = 0;
    *yystack.s_mark = 0;

yyloop:
    if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
    if (yychar < 0)
    {
        if ((yychar = YYLEX) < 0) yychar = YYEOF;
#if YYDEBUG
        if (yydebug)
        {
            yys = yyname[YYTRANSLATE(yychar)];
            printf("%sdebug: state %d, reading %d (%s)\n",
                    YYPREFIX, yystate, yychar, yys);
        }
#endif
    }
    if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: state %d, shifting to state %d\n",
                    YYPREFIX, yystate, yytable[yyn]);
#endif
        if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
        {
            goto yyoverflow;
        }
        yystate = yytable[yyn];
        *++yystack.s_mark = yytable[yyn];
        *++yystack.l_mark = yylval;
        yychar = YYEMPTY;
        if (yyerrflag > 0)  --yyerrflag;
        goto yyloop;
    }
    if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
    {
        yyn = yytable[yyn];
        goto yyreduce;
    }
    if (yyerrflag) goto yyinrecovery;

    YYERROR_CALL("syntax error");

    goto yyerrlab;

yyerrlab:
    ++yynerrs;

yyinrecovery:
    if (yyerrflag < 3)
    {
        yyerrflag = 3;
        for (;;)
        {
            if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
                    yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: state %d, error recovery shifting\
 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
                if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
                {
                    goto yyoverflow;
                }
                yystate = yytable[yyn];
                *++yystack.s_mark = yytable[yyn];
                *++yystack.l_mark = yylval;
                goto yyloop;
            }
            else
            {
#if YYDEBUG
                if (yydebug)
                    printf("%sdebug: error recovery discarding state %d\n",
                            YYPREFIX, *yystack.s_mark);
#endif
                if (yystack.s_mark <= yystack.s_base) goto yyabort;
                --yystack.s_mark;
                --yystack.l_mark;
            }
        }
    }
    else
    {
        if (yychar == YYEOF) goto yyabort;
#if YYDEBUG
        if (yydebug)
        {
            yys = yyname[YYTRANSLATE(yychar)];
            printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
                    YYPREFIX, yystate, yychar, yys);
        }
#endif
        yychar = YYEMPTY;
        goto yyloop;
    }

yyreduce:
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: state %d, reducing by rule %d (%s)\n",
                YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
    yym = yylen[yyn];
    if (yym)
        yyval = yystack.l_mark[1-yym];
    else
        memset(&yyval, 0, sizeof yyval);
    switch (yyn)
    {
case 7:
#line 54 "ergo_input_processor.y"
	{ if(!ergo_scanner_reading_stdin) { yyerror("Aborted."); YYABORT; } }
break;
case 8:
#line 58 "ergo_input_processor.y"
	{ es_assign_num(yystack.l_mark[-2].var, yystack.l_mark[0].num);}
break;
case 9:
#line 59 "ergo_input_processor.y"
	{ es_assign_str(yystack.l_mark[-2].var, yystack.l_mark[0].str);}
break;
case 10:
#line 63 "ergo_input_processor.y"
	{ yyval.var=es_find_var(NULL, yystack.l_mark[0].str); 
                              if(!yyval.var) { last_token = yystack.l_mark[0].str;
                                        yyerror("Unknown variable");YYERROR; }}
break;
case 11:
#line 66 "ergo_input_processor.y"
	{ yyval.var=es_find_var(yystack.l_mark[-2].var,   yystack.l_mark[0].str);
                              if(!yyval.var) { last_token = yystack.l_mark[0].str;
                                        yyerror("Unknown variable");YYERROR;}}
break;
case 12:
#line 72 "ergo_input_processor.y"
	{ es_mol_commit(); }
break;
case 13:
#line 73 "ergo_input_processor.y"
	{ es_mol_commit(); }
break;
case 14:
#line 74 "ergo_input_processor.y"
	{ es_mol_commit(); }
break;
case 15:
#line 75 "ergo_input_processor.y"
	{ es_mol_commit(); }
break;
case 16:
#line 76 "ergo_input_processor.y"
	{ es_print_help(); }
break;
case 17:
#line 77 "ergo_input_processor.y"
	{ es_print_help_var(yystack.l_mark[0].var); }
break;
case 18:
#line 78 "ergo_input_processor.y"
	{ es_print_list_dft_funcs(); }
break;
case 19:
#line 79 "ergo_input_processor.y"
	{ es_print_is_cht_used(); }
break;
case 20:
#line 80 "ergo_input_processor.y"
	{ es_print_precision(); }
break;
case 21:
#line 81 "ergo_input_processor.y"
	{ if(es_mol_read_molecule(yystack.l_mark[0].str,MOL_MAIN)) { 
                              yyerror("Reading MOLECULE failed"); YYERROR;} }
break;
case 22:
#line 83 "ergo_input_processor.y"
	{ if(es_mol_read_molecule(yystack.l_mark[0].str, MOL_GHOST)) { 
                              yyerror("Reading GHOST MOLECULE failed"); YYERROR;} }
break;
case 23:
#line 85 "ergo_input_processor.y"
	{ if(es_run(yystack.l_mark[0].str, 0)) {
                              yyerror("RUN failed"); YYERROR;} }
break;
case 24:
#line 87 "ergo_input_processor.y"
	{
          if(es_set_nthreads(yystack.l_mark[-1].num)) { yyerror("setNThreads failed"); YYERROR;} }
break;
case 25:
#line 89 "ergo_input_processor.y"
	{
          if(es_set_nthreads_string(yystack.l_mark[-1].str)) { yyerror("setNThreads failed"); YYERROR;} }
break;
case 26:
#line 91 "ergo_input_processor.y"
	{ puts(yystack.l_mark[0].str); 
                   if(system(yystack.l_mark[0].str) != 0) {yyerror("system() failed"); YYERROR;} }
break;
case 27:
#line 93 "ergo_input_processor.y"
	{ es_warranty(); }
break;
case 28:
#line 94 "ergo_input_processor.y"
	{ if(es_getexc(yystack.l_mark[-1].str, yystack.l_mark[0].num)) {
                              yyerror("get_excited_state failed"); YYERROR;} }
break;
case 29:
#line 96 "ergo_input_processor.y"
	{ if(es_get_polarisability(yystack.l_mark[-2].str, yystack.l_mark[-1].str, yystack.l_mark[0].num)) {
                              yyerror("get_polarisability failed"); YYERROR;} }
break;
case 30:
#line 98 "ergo_input_processor.y"
	{ if(es_get_polarisability(yystack.l_mark[-2].str, NULL,yystack.l_mark[0].num)) {
                              yyerror("get_polarisability failed"); YYERROR;} }
break;
case 31:
#line 100 "ergo_input_processor.y"
	{ YYACCEPT; }
break;
case 32:
#line 101 "ergo_input_processor.y"
	{
                         if(!es_assign_range(MOL_MAIN,yystack.l_mark[-4].num, yystack.l_mark[-2].num, yystack.l_mark[-1].num, yystack.l_mark[0].str)) {
                            yyerror("Invalid main basis set range");YYERROR;}
                         }
break;
case 33:
#line 105 "ergo_input_processor.y"
	{
                         if(!es_assign_range(MOL_GHOST,yystack.l_mark[-4].num, yystack.l_mark[-2].num, yystack.l_mark[-1].num, yystack.l_mark[0].str)) {
                            yyerror("Invalid ghost basis set range");YYERROR;}
                         }
break;
case 36:
#line 117 "ergo_input_processor.y"
	{ es_add_atom(yystack.l_mark[-4].str, yystack.l_mark[-3].num, yystack.l_mark[-2].num, yystack.l_mark[-1].num); }
break;
case 37:
#line 121 "ergo_input_processor.y"
	{ yyval.num=yystack.l_mark[0].num;  }
break;
case 38:
#line 122 "ergo_input_processor.y"
	{ yyval.num=yystack.l_mark[-2].num+yystack.l_mark[0].num; }
break;
case 39:
#line 123 "ergo_input_processor.y"
	{ yyval.num=yystack.l_mark[-2].num-yystack.l_mark[0].num; }
break;
case 40:
#line 124 "ergo_input_processor.y"
	{ yyval.num=yystack.l_mark[-2].num*yystack.l_mark[0].num; }
break;
case 41:
#line 125 "ergo_input_processor.y"
	{ yyval.num=yystack.l_mark[-2].num/yystack.l_mark[0].num; }
break;
case 42:
#line 126 "ergo_input_processor.y"
	{ yyval.num=-yystack.l_mark[0].num; }
break;
case 43:
#line 127 "ergo_input_processor.y"
	{ yyval.num=pow(yystack.l_mark[-2].num,yystack.l_mark[0].num); }
break;
case 44:
#line 128 "ergo_input_processor.y"
	{ yyval.num=yystack.l_mark[-1].num; }
break;
#line 736 "ergo_input_processor.c"
    }
    yystack.s_mark -= yym;
    yystate = *yystack.s_mark;
    yystack.l_mark -= yym;
    yym = yylhs[yyn];
    if (yystate == 0 && yym == 0)
    {
#if YYDEBUG
        if (yydebug)
            printf("%sdebug: after reduction, shifting from state 0 to\
 state %d\n", YYPREFIX, YYFINAL);
#endif
        yystate = YYFINAL;
        *++yystack.s_mark = YYFINAL;
        *++yystack.l_mark = yyval;
        if (yychar < 0)
        {
            if ((yychar = YYLEX) < 0) yychar = YYEOF;
#if YYDEBUG
            if (yydebug)
            {
                yys = yyname[YYTRANSLATE(yychar)];
                printf("%sdebug: state %d, reading %d (%s)\n",
                        YYPREFIX, YYFINAL, yychar, yys);
            }
#endif
        }
        if (yychar == YYEOF) goto yyaccept;
        goto yyloop;
    }
    if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
            yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
        yystate = yytable[yyn];
    else
        yystate = yydgoto[yym];
#if YYDEBUG
    if (yydebug)
        printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
    if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
    {
        goto yyoverflow;
    }
    *++yystack.s_mark = (YYINT) yystate;
    *++yystack.l_mark = yyval;
    goto yyloop;

yyoverflow:
    YYERROR_CALL("yacc stack overflow");

yyabort:
    yyfreestack(&yystack);
    return (1);

yyaccept:
    yyfreestack(&yystack);
    return (0);
}