This is Unofficial EPICS BASE Doxygen Site
yylex.c File Reference
#include <ctype.h>
#include "flexdef.h"
#include "parse.h"
+ Include dependency graph for yylex.c:

Go to the source code of this file.

Macros

#define isascii(c)   ((c) <= 0177)
 

Functions

int yylex (void)
 

Macro Definition Documentation

#define isascii (   c)    ((c) <= 0177)

Definition at line 43 of file yylex.c.

Function Documentation

int yylex ( void  )

Definition at line 56 of file yylex.c.

57 {
58  int toktype;
59  static int beglin = false;
60 
61  if ( eofseen )
62  toktype = EOF;
63  else
64  toktype = flexscan();
65 
66  if ( toktype == EOF || toktype == 0 )
67  {
68  eofseen = 1;
69 
70  if ( sectnum == 1 )
71  {
72  synerr( "premature EOF" );
73  sectnum = 2;
74  toktype = SECTEND;
75  }
76 
77  else if ( sectnum == 2 )
78  {
79  sectnum = 3;
80  toktype = 0;
81  }
82 
83  else
84  toktype = 0;
85  }
86 
87  if ( trace )
88  {
89  if ( beglin )
90  {
91  fprintf( stderr, "%d\t", num_rules + 1 );
92  beglin = 0;
93  }
94 
95  switch ( toktype )
96  {
97  case '<':
98  case '>':
99  case '^':
100  case '$':
101  case '"':
102  case '[':
103  case ']':
104  case '{':
105  case '}':
106  case '|':
107  case '(':
108  case ')':
109  case '-':
110  case '/':
111  case '\\':
112  case '?':
113  case '.':
114  case '*':
115  case '+':
116  case ',':
117  (void) putc( toktype, stderr );
118  break;
119 
120  case '\n':
121  (void) putc( '\n', stderr );
122 
123  if ( sectnum == 2 )
124  beglin = 1;
125 
126  break;
127 
128  case SCDECL:
129  fputs( "%s", stderr );
130  break;
131 
132  case XSCDECL:
133  fputs( "%x", stderr );
134  break;
135 
136  case WHITESPACE:
137  (void) putc( ' ', stderr );
138  break;
139 
140  case SECTEND:
141  fputs( "%%\n", stderr );
142 
143  /* we set beglin to be true so we'll start
144  * writing out numbers as we echo rules. flexscan() has
145  * already assigned sectnum
146  */
147 
148  if ( sectnum == 2 )
149  beglin = 1;
150 
151  break;
152 
153  case NAME:
154  fprintf( stderr, "'%s'", nmstr );
155  break;
156 
157  case CHAR:
158  switch ( yylval )
159  {
160  case '<':
161  case '>':
162  case '^':
163  case '$':
164  case '"':
165  case '[':
166  case ']':
167  case '{':
168  case '}':
169  case '|':
170  case '(':
171  case ')':
172  case '-':
173  case '/':
174  case '\\':
175  case '?':
176  case '.':
177  case '*':
178  case '+':
179  case ',':
180  fprintf( stderr, "\\%c", yylval );
181  break;
182 
183  default:
184  if ( ! isascii( yylval ) || ! isprint( yylval ) )
185  fprintf( stderr, "\\%.3o", yylval );
186  else
187  (void) putc( yylval, stderr );
188  break;
189  }
190 
191  break;
192 
193  case NUMBER:
194  fprintf( stderr, "%d", yylval );
195  break;
196 
197  case PREVCCL:
198  fprintf( stderr, "[%d]", yylval );
199  break;
200 
201  case EOF_OP:
202  fprintf( stderr, "<<EOF>>" );
203  break;
204 
205  case 0:
206  fprintf( stderr, "End Marker" );
207  break;
208 
209  default:
210  fprintf( stderr, "*Something Weird* - tok: %d val: %d\n",
211  toktype, yylval );
212  break;
213  }
214  }
215 
216  return ( toktype );
217 }
char nmstr[MAXLINE]
Definition: flex.c:99
int num_rules
Definition: flex.c:76
void synerr(char[])
int flexscan()
int trace
Definition: flex.c:66
#define stderr
Definition: epicsStdio.h:32
#define isascii(c)
Definition: yylex.c:43
int eofseen
Definition: flex.c:66
int sectnum
Definition: flex.c:100