ncform (6640B)
1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 23 /* Copyright (c) 1989 AT&T */ 24 /* All Rights Reserved */ 25 26 /* from OpenSolaris "ncform 6.14 05/06/10 SMI" */ 27 28 /* 29 * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany 30 * 31 * Sccsid @(#)ncform 1.4 (gritter) 11/18/05 32 */ 33 34 int yylineno =1; 35 # define YYU(x) x 36 # define NLSTATE yyprevious=YYNEWLINE 37 struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; 38 char yysbuf[YYLMAX]; 39 char *yysptr = yysbuf; 40 int *yyfnd; 41 extern struct yysvf *yyestate; 42 int yyprevious = YYNEWLINE; 43 #if defined(__cplusplus) || defined(__STDC__) 44 int yylook(void) 45 #else 46 yylook() 47 #endif 48 { 49 register struct yysvf *yystate, **lsp; 50 register struct yywork *yyt; 51 struct yysvf *yyz; 52 int yych, yyfirst; 53 struct yywork *yyr; 54 # ifdef LEXDEBUG 55 int debug; 56 # endif 57 char *yylastch; 58 /* start off machines */ 59 # ifdef LEXDEBUG 60 debug = 0; 61 # endif 62 yyfirst=1; 63 if (!yymorfg) 64 yylastch = yytext; 65 else { 66 yymorfg=0; 67 yylastch = yytext+yyleng; 68 } 69 for(;;){ 70 lsp = yylstate; 71 yyestate = yystate = yybgin; 72 if (yyprevious==YYNEWLINE) yystate++; 73 for (;;){ 74 # ifdef LEXDEBUG 75 if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1); 76 # endif 77 yyt = yystate->yystoff; 78 if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ 79 yyz = yystate->yyother; 80 if(yyz == 0)break; 81 if(yyz->yystoff == yycrank)break; 82 } 83 #ifndef __cplusplus 84 *yylastch++ = yych = input(); 85 #else 86 *yylastch++ = yych = lex_input(); 87 #endif 88 #ifdef YYISARRAY 89 if(yylastch > &yytext[YYLMAX]) { 90 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 91 exit(1); 92 } 93 #else 94 if (yylastch >= &yytext[ yytextsz ]) { 95 int x = yylastch - yytext; 96 97 yytextsz += YYTEXTSZINC; 98 if (yytext == yy_tbuf) { 99 yytext = (char *) malloc(yytextsz); 100 memcpy(yytext, yy_tbuf, sizeof (yy_tbuf)); 101 } 102 else 103 yytext = (char *) realloc(yytext, yytextsz); 104 if (!yytext) { 105 fprintf(yyout, 106 "Cannot realloc yytext\n"); 107 exit(1); 108 } 109 yylastch = yytext + x; 110 } 111 #endif 112 yyfirst=0; 113 tryagain: 114 # ifdef LEXDEBUG 115 if(debug){ 116 fprintf(yyout,"char "); 117 allprint(yych); 118 putchar('\n'); 119 } 120 # endif 121 yyr = yyt; 122 if ( yyt > yycrank){ 123 yyt = yyr + yych; 124 if (yyt <= yytop && yyt->verify+yysvec == yystate){ 125 if(yyt->advance+yysvec == YYLERR) /* error transitions */ 126 {unput(*--yylastch);break;} 127 *lsp++ = yystate = yyt->advance+yysvec; 128 if(lsp > &yylstate[YYLMAX]) { 129 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 130 exit(1); 131 } 132 goto contin; 133 } 134 } 135 # ifdef YYOPTIM 136 else if(yyt < yycrank) { /* r < yycrank */ 137 yyt = yyr = yycrank+(yycrank-yyt); 138 # ifdef LEXDEBUG 139 if(debug)fprintf(yyout,"compressed state\n"); 140 # endif 141 yyt = yyt + yych; 142 if(yyt <= yytop && yyt->verify+yysvec == yystate){ 143 if(yyt->advance+yysvec == YYLERR) /* error transitions */ 144 {unput(*--yylastch);break;} 145 *lsp++ = yystate = yyt->advance+yysvec; 146 if(lsp > &yylstate[YYLMAX]) { 147 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 148 exit(1); 149 } 150 goto contin; 151 } 152 yyt = yyr + YYU(yymatch[yych]); 153 # ifdef LEXDEBUG 154 if(debug){ 155 fprintf(yyout,"try fall back character "); 156 allprint(YYU(yymatch[yych])); 157 putchar('\n'); 158 } 159 # endif 160 if(yyt <= yytop && yyt->verify+yysvec == yystate){ 161 if(yyt->advance+yysvec == YYLERR) /* error transition */ 162 {unput(*--yylastch);break;} 163 *lsp++ = yystate = yyt->advance+yysvec; 164 if(lsp > &yylstate[YYLMAX]) { 165 fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); 166 exit(1); 167 } 168 goto contin; 169 } 170 } 171 if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ 172 # ifdef LEXDEBUG 173 if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); 174 # endif 175 goto tryagain; 176 } 177 # endif 178 else 179 {unput(*--yylastch);break;} 180 contin: 181 # ifdef LEXDEBUG 182 if(debug){ 183 fprintf(yyout,"state %d char ",yystate-yysvec-1); 184 allprint(yych); 185 putchar('\n'); 186 } 187 # endif 188 ; 189 } 190 # ifdef LEXDEBUG 191 if(debug){ 192 fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); 193 allprint(yych); 194 putchar('\n'); 195 } 196 # endif 197 while (lsp-- > yylstate){ 198 *yylastch-- = 0; 199 if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ 200 yyolsp = lsp; 201 if(yyextra[*yyfnd]){ /* must backup */ 202 while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ 203 lsp--; 204 unput(*yylastch--); 205 } 206 } 207 yyprevious = YYU(*yylastch); 208 yylsp = lsp; 209 yyleng = yylastch-yytext+1; 210 yytext[yyleng] = 0; 211 # ifdef LEXDEBUG 212 if(debug){ 213 fprintf(yyout,"\nmatch "); 214 sprint(yytext); 215 fprintf(yyout," action %d\n",*yyfnd); 216 } 217 # endif 218 return(*yyfnd++); 219 } 220 unput(*yylastch); 221 } 222 if (yytext[0] == 0 /* && feof(yyin) */) 223 { 224 yysptr=yysbuf; 225 return(0); 226 } 227 #ifndef __cplusplus 228 yyprevious = yytext[0] = input(); 229 if (yyprevious>0) 230 output(yyprevious); 231 #else 232 yyprevious = yytext[0] = lex_input(); 233 if (yyprevious>0) 234 lex_output(yyprevious); 235 #endif 236 yylastch=yytext; 237 # ifdef LEXDEBUG 238 if(debug)putchar('\n'); 239 # endif 240 } 241 } 242 #if defined(__cplusplus) || defined(__STDC__) 243 int yyback(int *p, int m) 244 #else 245 yyback(p, m) 246 int *p; 247 #endif 248 { 249 if (p==0) return(0); 250 while (*p) { 251 if (*p++ == m) 252 return(1); 253 } 254 return(0); 255 } 256 /* the following are only used in the lex library */ 257 #if defined(__cplusplus) || defined(__STDC__) 258 int yyinput(void) 259 #else 260 yyinput() 261 #endif 262 { 263 #ifndef __cplusplus 264 return(input()); 265 #else 266 return(lex_input()); 267 #endif 268 } 269 #if defined(__cplusplus) || defined(__STDC__) 270 void yyoutput(int c) 271 #else 272 yyoutput(c) 273 int c; 274 #endif 275 { 276 #ifndef __cplusplus 277 output(c); 278 #else 279 lex_output(c); 280 #endif 281 } 282 #if defined(__cplusplus) || defined(__STDC__) 283 void yyunput(int c) 284 #else 285 yyunput(c) 286 int c; 287 #endif 288 { 289 unput(c); 290 }