This is Unofficial EPICS BASE Doxygen Site
output.c File Reference
#include "defs.h"
+ Include dependency graph for output.c:

Go to the source code of this file.

Functions

void output (void)
 
int default_goto (int symbol)
 
int matching_vector (int vector)
 
int pack_vector (int vector)
 

Function Documentation

int default_goto ( int  symbol)

Definition at line 358 of file output.c.

359 {
360  int i;
361  int m;
362  int n;
363  int default_state;
364  int max;
365 
366  m = goto_map[symbol];
367  n = goto_map[symbol + 1];
368 
369  if (m == n) return (0);
370 
371  for (i = 0; i < nstates; i++)
372  state_count[i] = 0;
373 
374  for (i = m; i < n; i++)
375  state_count[to_state[i]]++;
376 
377  max = 0;
378  default_state = 0;
379  for (i = 0; i < nstates; i++)
380  {
381  if (state_count[i] > max)
382  {
383  max = state_count[i];
384  default_state = i;
385  }
386  }
387 
388  return (default_state);
389 }
#define max(x, y)
Definition: flexdef.h:81
int i
Definition: scan.c:967
int nstates
Definition: lr0.c:16
short * goto_map
Definition: lalr.c:27
short * to_state
Definition: lalr.c:29
int matching_vector ( int  vector)

Definition at line 535 of file output.c.

536 {
537  int i;
538  int j;
539  int k;
540  int t;
541  int w;
542  int match;
543  int prev;
544 
545  i = order[vector];
546  if (i >= 2*nstates)
547  return (-1);
548 
549  t = tally[i];
550  w = width[i];
551 
552  for (prev = vector - 1; prev >= 0; prev--)
553  {
554  j = order[prev];
555  if (width[j] != w || tally[j] != t)
556  return (-1);
557 
558  match = 1;
559  for (k = 0; match && k < t; k++)
560  {
561  if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k])
562  match = 0;
563  }
564 
565  if (match)
566  return (j);
567  }
568 
569  return (-1);
570 }
int i
Definition: scan.c:967
int nstates
Definition: lr0.c:16
void output ( void  )

Definition at line 51 of file output.c.

52 {
53  free_itemsets();
54  free_shifts();
55  free_reductions();
56  output_prefix();
57  output_stored_text();
58  output_defines();
59  output_rule_data();
60  output_yydefred();
61  output_actions();
62  free_parser();
63  output_debug();
64  output_stype();
67  output_trailing_text();
69  output_semantic_actions();
71 }
void free_parser(void)
Definition: mkpar.c:363
char * body[]
Definition: skeleton.c:81
void write_section(char *section[])
Definition: skeleton.c:284
char * tables[]
Definition: skeleton.c:32
char * trailer[]
Definition: skeleton.c:221
char * header[]
Definition: skeleton.c:51
char rflag
Definition: antelope.c:24
int pack_vector ( int  vector)

Definition at line 575 of file output.c.

576 {
577  int i, j, k, l;
578  int t;
579  int loc;
580  int ok;
581  short *from;
582  short *to;
583  int newmax;
584 
585  i = order[vector];
586  t = tally[i];
587  assert(t);
588 
589  from = froms[i];
590  to = tos[i];
591 
592  j = lowzero - from[0];
593  for (k = 1; k < t; ++k)
594  if (lowzero - from[k] > j)
595  j = lowzero - from[k];
596  for (;; ++j)
597  {
598  if (j == 0)
599  continue;
600  ok = 1;
601  for (k = 0; ok && k < t; k++)
602  {
603  loc = j + from[k];
604  if (loc >= maxtable)
605  {
606  if (loc >= MAXTABLE)
607  fatal("maximum table size exceeded");
608 
609  newmax = maxtable;
610  do { newmax += 200; } while (newmax <= loc);
611  table = (short *) REALLOC(table, newmax*sizeof(short));
612  if (table == 0) no_space();
613  check = (short *) REALLOC(check, newmax*sizeof(short));
614  if (check == 0) no_space();
615  for (l = maxtable; l < newmax; ++l)
616  {
617  table[l] = 0;
618  check[l] = -1;
619  }
620  maxtable = newmax;
621  }
622 
623  if (check[loc] != -1)
624  ok = 0;
625  }
626  for (k = 0; ok && k < vector; k++)
627  {
628  if (pos[k] == j)
629  ok = 0;
630  }
631  if (ok)
632  {
633  for (k = 0; k < t; k++)
634  {
635  loc = j + from[k];
636  table[loc] = to[k];
637  check[loc] = from[k];
638  if (loc > high) high = loc;
639  }
640 
641  while (check[lowzero] != -1)
642  ++lowzero;
643 
644  return (j);
645  }
646  }
647 }
void fatal(char *msg) NORETURN
Definition: error.c:15
#define MAXTABLE
Definition: defs.h:32
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
int i
Definition: scan.c:967
void no_space(void) NORETURN
Definition: error.c:23
#define REALLOC(p, n)
Definition: defs.h:114