/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1989 AT&T */ /* All Rights Reserved */ #include #include #include #include #include #include #pragma weak yyout extern FILE *yyout; #ifndef JLSLEX #define CHR char #endif #ifdef WOPTION #define CHR wchar_t #define sprint sprint_w #endif #ifdef EOPTION #define CHR wchar_t #endif void allprint(CHR c) { switch (c) { case '\n': (void) fprintf(yyout, "\\n"); break; case '\t': (void) fprintf(yyout, "\\t"); break; case '\b': (void) fprintf(yyout, "\\b"); break; case ' ': (void) fprintf(yyout, "\\_"); break; default: if (!iswprint(c)) (void) fprintf(yyout, "\\x%-2x", c); else (void) putwc(c, yyout); break; } } void sprint(CHR *s) { while (*s) allprint(*s++); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #include "ldefs.h" static void rhd1(void); static void chd1(void); static void chd2(void); static void ctail(void); static void rtail(void); void phead1(void) { ratfor ? rhd1() : chd1(); } static void chd1(void) { if (*v_stmp == 'y') (void) fprintf(fout, "#ident\t\"lex: %s %s\"\n", (const char *)SGU_PKG, (const char *)SGU_REL); if (handleeuc) { (void) fprintf(fout, "#ifndef EUC\n"); (void) fprintf(fout, "#define EUC\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "#include \n"); (void) fprintf(fout, "#include \n"); (void) fprintf(fout, "#include \n"); (void) fprintf(fout, "#include \n"); if (widecio) { /* -w option */ (void) fprintf(fout, "#define YYTEXT yytext\n"); (void) fprintf(fout, "#define YYLENG yyleng\n"); (void) fprintf(fout, "#ifndef __cplusplus\n"); (void) fprintf(fout, "#define YYINPUT input\n"); (void) fprintf(fout, "#define YYOUTPUT output\n"); (void) fprintf(fout, "#else\n"); (void) fprintf(fout, "#define YYINPUT lex_input\n"); (void) fprintf(fout, "#define YYOUTPUT lex_output\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "#define YYUNPUT unput\n"); } else { /* -e option */ (void) fprintf(fout, "#include \n"); (void) fprintf(fout, "#include \n"); (void) fprintf(fout, "#define YYLEX_E 1\n"); (void) fprintf(fout, "#define YYTEXT yywtext\n"); (void) fprintf(fout, "#define YYLENG yywleng\n"); (void) fprintf(fout, "#define YYINPUT yywinput\n"); (void) fprintf(fout, "#define YYOUTPUT yywoutput\n"); (void) fprintf(fout, "#define YYUNPUT yywunput\n"); } } else { /* ASCII compatibility mode. */ (void) fprintf(fout, "#include \n"); (void) fprintf(fout, "#include \n"); (void) fprintf(fout, "#include \n"); } if (ZCH > NCH) (void) fprintf(fout, "# define U(x) ((x)&0377)\n"); else (void) fprintf(fout, "# define U(x) x\n"); (void) fprintf(fout, "# define NLSTATE yyprevious=YYNEWLINE\n"); (void) fprintf(fout, "# define BEGIN yybgin = yysvec + 1 +\n"); (void) fprintf(fout, "# define INITIAL 0\n"); (void) fprintf(fout, "# define YYLERR yysvec\n"); (void) fprintf(fout, "# define YYSTATE (yyestate-yysvec-1)\n"); if (optim) (void) fprintf(fout, "# define YYOPTIM 1\n"); #ifdef DEBUG (void) fprintf(fout, "# define LEXDEBUG 1\n"); #endif (void) fprintf(fout, "# ifndef YYLMAX \n"); (void) fprintf(fout, "# define YYLMAX BUFSIZ\n"); (void) fprintf(fout, "# endif \n"); (void) fprintf(fout, "#ifndef __cplusplus\n"); if (widecio) (void) fprintf(fout, "# define output(c) (void)putwc(c,yyout)\n"); else (void) fprintf(fout, "# define output(c) (void)putc(c,yyout)\n"); (void) fprintf(fout, "#else\n"); if (widecio) (void) fprintf(fout, "# define lex_output(c) (void)putwc(c,yyout)\n"); else (void) fprintf(fout, "# define lex_output(c) (void)putc(c,yyout)\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "\n#if defined(__cplusplus) || defined(__STDC__)\n"); (void) fprintf(fout, "\n#if defined(__cplusplus)\n"); (void) fprintf(fout, "extern \"C\" {\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "\tint yyback(int *, int);\n"); /* ? */ (void) fprintf(fout, "\tint yyinput(void);\n"); /* ? */ (void) fprintf(fout, "\tint yylook(void);\n"); /* ? */ (void) fprintf(fout, "\tvoid yyoutput(int);\n"); /* ? */ (void) fprintf(fout, "\tint yyracc(int);\n"); /* ? */ (void) fprintf(fout, "\tint yyreject(void);\n"); /* ? */ (void) fprintf(fout, "\tvoid yyunput(int);\n"); /* ? */ (void) fprintf(fout, "\tint yylex(void);\n"); (void) fprintf(fout, "#ifdef YYLEX_E\n"); (void) fprintf(fout, "\tvoid yywoutput(wchar_t);\n"); (void) fprintf(fout, "\twchar_t yywinput(void);\n"); (void) fprintf(fout, "\tvoid yywunput(wchar_t);\n"); (void) fprintf(fout, "#endif\n"); /* XCU4: type of yyless is int */ (void) fprintf(fout, "#ifndef yyless\n"); (void) fprintf(fout, "\tint yyless(int);\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "#ifndef yywrap\n"); (void) fprintf(fout, "\tint yywrap(void);\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "#ifdef LEXDEBUG\n"); (void) fprintf(fout, "\tvoid allprint(char);\n"); (void) fprintf(fout, "\tvoid sprint(char *);\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "#if defined(__cplusplus)\n"); (void) fprintf(fout, "}\n"); (void) fprintf(fout, "#endif\n\n"); (void) fprintf(fout, "#ifdef __cplusplus\n"); (void) fprintf(fout, "extern \"C\" {\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "\tvoid exit(int);\n"); (void) fprintf(fout, "#ifdef __cplusplus\n"); (void) fprintf(fout, "}\n"); (void) fprintf(fout, "#endif\n\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "# define unput(c)" " {yytchar= (c);if(yytchar=='\\n')yylineno--;*yysptr++=yytchar;}\n"); (void) fprintf(fout, "# define yymore() (yymorfg=1)\n"); if (widecio) { (void) fprintf(fout, "#ifndef __cplusplus\n"); (void) fprintf(fout, "%s%d%s\n", "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", ctable['\n'], "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); (void) fprintf(fout, "#else\n"); (void) fprintf(fout, "%s%d%s\n", "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getwc(yyin))==", ctable['\n'], "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "# define ECHO (void)fprintf(yyout, \"%%ws\",yytext)\n"); (void) fprintf(fout, "# define REJECT { nstr = yyreject_w(); goto yyfussy;}\n"); (void) fprintf(fout, "#define yyless yyless_w\n"); (void) fprintf(fout, "int yyleng;\n"); /* * XCU4: * If %array, yytext[] contains the token. * If %pointer, yytext is a pointer to yy_tbuf[]. */ if (isArray) { (void) fprintf(fout, "#define YYISARRAY\n"); (void) fprintf(fout, "wchar_t yytext[YYLMAX];\n"); } else { (void) fprintf(fout, "wchar_t yy_tbuf[YYLMAX];\n"); (void) fprintf(fout, "wchar_t * yytext = yy_tbuf;\n"); (void) fprintf(fout, "int yytextsz = YYLMAX;\n"); (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); (void) fprintf(fout, "#define YYTEXTSZINC 100\n"); (void) fprintf(fout, "#endif\n"); } } else { (void) fprintf(fout, "#ifndef __cplusplus\n"); (void) fprintf(fout, "%s%d%s\n", "# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", ctable['\n'], "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); (void) fprintf(fout, "#else\n"); (void) fprintf(fout, "%s%d%s\n", "# define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==", ctable['\n'], "?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "#define ECHO fprintf(yyout, \"%%s\",yytext)\n"); if (handleeuc) { (void) fprintf(fout, "# define REJECT { nstr = yyreject_e(); goto yyfussy;}\n"); (void) fprintf(fout, "int yyleng;\n"); (void) fprintf(fout, "size_t yywleng;\n"); /* * XCU4: * If %array, yytext[] contains the token. * If %pointer, yytext is a pointer to yy_tbuf[]. */ if (isArray) { (void) fprintf(fout, "#define YYISARRAY\n"); (void) fprintf(fout, "unsigned char yytext[YYLMAX*MB_LEN_MAX];\n"); (void) fprintf(fout, "wchar_t yywtext[YYLMAX];\n"); } else { (void) fprintf(fout, "wchar_t yy_twbuf[YYLMAX];\n"); (void) fprintf(fout, "wchar_t yy_tbuf[YYLMAX*MB_LEN_MAX];\n"); (void) fprintf(fout, "unsigned char * yytext =" "(unsigned char *)yy_tbuf;\n"); (void) fprintf(fout, "wchar_t * yywtext = yy_twbuf;\n"); (void) fprintf(fout, "int yytextsz = YYLMAX;\n"); (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); (void) fprintf(fout, "#define YYTEXTSZINC 100\n"); (void) fprintf(fout, "#endif\n"); } } else { (void) fprintf(fout, "# define REJECT { nstr = yyreject(); goto yyfussy;}\n"); (void) fprintf(fout, "int yyleng;\n"); /* * XCU4: * If %array, yytext[] contains the token. * If %pointer, yytext is a pointer to yy_tbuf[]. */ if (isArray) { (void) fprintf(fout, "#define YYISARRAY\n"); (void) fprintf(fout, "char yytext[YYLMAX];\n"); } else { (void) fprintf(fout, "char yy_tbuf[YYLMAX];\n"); (void) fprintf(fout, "char * yytext = yy_tbuf;\n"); (void) fprintf(fout, "int yytextsz = YYLMAX;\n"); (void) fprintf(fout, "#ifndef YYTEXTSZINC\n"); (void) fprintf(fout, "#define YYTEXTSZINC 100\n"); (void) fprintf(fout, "#endif\n"); } } } (void) fprintf(fout, "int yymorfg;\n"); if (handleeuc) (void) fprintf(fout, "extern wchar_t *yysptr, yysbuf[];\n"); else (void) fprintf(fout, "extern char *yysptr, yysbuf[];\n"); (void) fprintf(fout, "int yytchar;\n"); (void) fprintf(fout, "FILE *yyin = {stdin}, *yyout = {stdout};\n"); (void) fprintf(fout, "extern int yylineno;\n"); (void) fprintf(fout, "struct yysvf { \n"); (void) fprintf(fout, "\tstruct yywork *yystoff;\n"); (void) fprintf(fout, "\tstruct yysvf *yyother;\n"); (void) fprintf(fout, "\tint *yystops;};\n"); (void) fprintf(fout, "struct yysvf *yyestate;\n"); (void) fprintf(fout, "extern struct yysvf yysvec[], *yybgin;\n"); } static void rhd1(void) { (void) fprintf(fout, "integer function yylex(dummy)\n"); (void) fprintf(fout, "define YYLMAX 200\n"); (void) fprintf(fout, "define ECHO call yyecho(yytext,yyleng)\n"); (void) fprintf(fout, "define REJECT nstr = yyrjct(yytext,yyleng);goto 30998\n"); (void) fprintf(fout, "integer nstr,yylook,yywrap\n"); (void) fprintf(fout, "integer yyleng, yytext(YYLMAX)\n"); (void) fprintf(fout, "common /yyxel/ yyleng, yytext\n"); (void) fprintf(fout, "common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta\n"); (void) fprintf(fout, "integer yyfnd, yymorf, yyprev, yybgin, yylsp, yylsta(YYLMAX)\n"); (void) fprintf(fout, "for(;;){\n"); (void) fprintf(fout, "\t30999 nstr = yylook(dummy)\n"); (void) fprintf(fout, "\tgoto 30998\n"); (void) fprintf(fout, "\t30000 k = yywrap(dummy)\n"); (void) fprintf(fout, "\tif(k .ne. 0){\n"); (void) fprintf(fout, "\tyylex=0; return; }\n"); (void) fprintf(fout, "\t\telse goto 30998\n"); } void phead2(void) { if (!ratfor) chd2(); } static void chd2(void) { (void) fprintf(fout, "#ifdef __cplusplus\n"); (void) fprintf(fout, "/* to avoid CC and lint complaining yyfussy not being used ...*/\n"); (void) fprintf(fout, "static int __lex_hack = 0;\n"); (void) fprintf(fout, "if (__lex_hack) goto yyfussy;\n"); (void) fprintf(fout, "#endif\n"); (void) fprintf(fout, "while((nstr = yylook()) >= 0)\n"); (void) fprintf(fout, "yyfussy: switch(nstr){\n"); (void) fprintf(fout, "case 0:\n"); (void) fprintf(fout, "if(yywrap()) return(0); break;\n"); } void ptail(void) { if (!pflag) ratfor ? rtail() : ctail(); pflag = 1; } static void ctail(void) { (void) fprintf(fout, "case -1:\nbreak;\n"); /* for reject */ (void) fprintf(fout, "default:\n"); (void) fprintf(fout, "(void)fprintf(yyout,\"bad switch yylook %%d\",nstr);\n"); (void) fprintf(fout, "} return(0); }\n"); (void) fprintf(fout, "/* end of yylex */\n"); } static void rtail(void) { int i; (void) fprintf(fout, "\n30998 if(nstr .lt. 0 .or. nstr .gt. %d)goto 30999\n", casecount); (void) fprintf(fout, "nstr = nstr + 1\n"); (void) fprintf(fout, "goto(\n"); for (i = 0; i < casecount; i++) (void) fprintf(fout, "%d,\n", 30000+i); (void) fprintf(fout, "30999),nstr\n"); (void) fprintf(fout, "30997 continue\n"); (void) fprintf(fout, "}\nend\n"); } void statistics(void) { (void) fprintf(errorf, "%d/%d nodes(%%e), %d/%d positions(%%p), %d/%d (%%n), %ld transitions,\n", tptr, treesize, (int)(nxtpos-positions), maxpos, stnum + 1, nstates, rcount); (void) fprintf(errorf, "%d/%d packed char classes(%%k), ", (int)(pcptr-pchar), pchlen); if (optim) (void) fprintf(errorf, " %d/%d packed transitions(%%a), ", nptr, ntrans); (void) fprintf(errorf, " %d/%d output slots(%%o)", yytop, outsize); (void) putc('\n', errorf); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #ifndef _LDEFS_H #define _LDEFS_H #include #include #include #include #include "sgs.h" #define CHR wchar_t #define BYTE char #define Boolean char #define LONG_WCHAR_T 1 #define PP 1 #ifdef u370 #define CWIDTH 8 #define CMASK 0377 #define ASCII 1 #else #ifdef unix #define CWIDTH 7 #define CMASK 0177 #define ASCII 1 #endif #ifdef gcos #define CWIDTH 9 #define CMASK 0777 #define ASCII 1 #endif #ifdef ibm #define CWIDTH 8 #define CMASK 0377 #define EBCDIC 1 #endif #endif #define NCH 256 #define TOKENSIZE 10000 #define DEFSIZE 1000 #define DEFCHAR 2000 #define BUF_SIZ 2000 #define STARTCHAR 2560 #define STARTSIZE 256 #define CCLSIZE 20000 #ifdef SMALL #define TREESIZE 600 #define NTRANS 1500 #define NSTATES 300 #define MAXPOS 1500 #define MAXPOSSTATE 500 #define NOUTPUT 1500 #endif #ifndef SMALL #define TREESIZE 1000 #define NSTATES 500 #define MAXPOS 2500 #define MAXPOSSTATE 4*1000 #define NTRANS 2000 #define NOUTPUT 4*3000 #endif #define NACTIONS 4*1000 #define ALITTLEEXTRA 300 #define RCCL 0x4000 #define RNCCL 0x4001 #define RSTR 0x4002 #define RSCON 0x4003 /* XCU4: add RXSCON */ #define RXSCON 0x4011 #define RNEWE 0x4004 #define FINAL 0x4005 #define RNULLS 0x4006 #define RCAT 0x4007 #define STAR 0x4008 #define PLUS 0x4009 #define QUEST 0x400a #define DIV 0x400b #define BAR 0x400c #define CARAT 0x400d #define S1FINAL 0x400e #define S2FINAL 0x400f #define DOT 0x4010 #define ISOPERATOR(n) ((n & 0xc080) == 0x4000) /* * New to JLE; this is not really a node tag. * This is used in a string pointed to by * the leaf of an RCCL or RNCCL node as a * special prefix code that substitutes * the infix '-' range operator. For * example, a lex character class "[_0-9a-zA-Z]" * would be translated to the intermidiate * form: * RCCL * | * | * v * "_09a-zA-Z" */ #define RANGE 0x40ff #define MAXNCG 1000 extern int ncgidtbl; extern int ncg; /* ncg == ncgidtbl * 2 */ typedef unsigned long lchar; extern lchar yycgidtbl[]; extern int yycgid(wchar_t); extern Boolean handleeuc; /* TRUE iff -w or -e option is specified. */ extern Boolean widecio; /* TRUE iff -w option is specified. */ #define DEFSECTION 1 #define RULESECTION 2 #define ENDSECTION 5 #define PC 1 #define PS 1 #ifdef DEBUG #define LINESIZE 110 extern int yydebug; extern int debug; /* 1 = on */ extern int charc; #endif #ifndef DEBUG #define freturn(s) s #endif extern int optind; extern int no_input; extern int sargc; extern char **sargv; extern char *v_stmp; extern char *release_string; extern CHR buf[]; extern int ratfor; /* 1 = ratfor, 0 = C */ extern int fatal; extern int n_error; extern int copy_line; extern int yyline; /* line number of file */ extern int sect; extern int eof; extern int lgatflg; extern int divflg; extern int funcflag; extern int pflag; extern int casecount; extern int chset; /* 1 = CHR set modified */ extern FILE *fin, *fout, *fother, *errorf; extern int fptr; extern int prev; /* previous input character */ extern int pres; /* present input character */ extern int peek; /* next input character */ extern int *name; extern int *left; extern int *right; extern int *parent; extern Boolean *nullstr; extern int tptr; extern CHR pushc[TOKENSIZE]; extern CHR *pushptr; extern CHR slist[STARTSIZE]; extern CHR *slptr; extern CHR **def, **subs, *dchar; extern CHR **sname, *schar; /* XCU4: %x exclusive start */ extern int *exclusive; extern CHR *ccl; extern CHR *ccptr; extern CHR *dp, *sp; extern int dptr, sptr; extern CHR *bptr; /* store input position */ extern CHR *tmpstat; extern int count; extern int **foll; extern int *nxtpos; extern int *positions; extern int *gotof; extern int *nexts; extern CHR *nchar; extern int **state; extern int *sfall; /* fallback state num */ extern Boolean *cpackflg; /* true if state has been character packed */ extern int *atable, aptr; extern int nptr; extern Boolean symbol[MAXNCG]; extern CHR cindex[MAXNCG]; extern int xstate; extern int stnum; extern int ctable[]; extern int ZCH; extern int ccount; extern CHR match[MAXNCG]; extern BYTE extra[]; extern CHR *pcptr, *pchar; extern int pchlen; extern int nstates, maxpos; extern int yytop; extern int report; extern int ntrans, treesize, outsize; extern long rcount; extern int optim; extern int *verify, *advance, *stoff; extern int scon; extern CHR *psave; extern CHR *getl(); extern BYTE *myalloc(); void phead1(void); void phead2(void); void ptail(void); void statistics(void); void error_tail(void) __NORETURN; void error(char *, ...); void warning(char *, ...); void lgate(void); void scopy(CHR *s, CHR *t); void cclinter(int sw); void cpycom(CHR *p); void munput(int t, CHR *p); void cfoll(int v); void cgoto(void); void mkmatch(void); void layout(void); void remch(wchar_t c); void sortcgidtbl(void); void repbycgid(void); int gch(void); int slength(CHR *s); int yyparse(void); int scomp(CHR *x, CHR *y); int space(int ch); int siconv(CHR *t); int digit(int c); int ctrans(CHR **ss); int cpyact(void); int lookup(CHR *s, CHR **t); int usescape(int c); int alpha(int c); int mn2(int a, int d, int c); int mn1(int a, int d); int mn0(int a); int dupl(int n); extern int isArray; /* XCU4: for %array %pointer */ #endif /* _LDEFS_H */ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* Copyright (c) 1989 AT&T */ /* All Rights Reserved */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * Copyright (c) 2018, Joyent, Inc. */ #include #include #pragma weak yylex extern int yylex(void); int main(int argc __unused, char **argv __unused) { (void) yylex(); exit(0); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2024 MNX Cloud, Inc. * Copyright (c) 2014 Gary Mills * Copyright (c) 2013, joyent, Inc. All rights reserved. * * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ /* Copyright 1976, Bell Telephone Laboratories, Inc. */ #include #include "once.h" #include "sgs.h" #include #include static wchar_t L_INITIAL[] = {'I', 'N', 'I', 'T', 'I', 'A', 'L', 0}; static void get1core(void); static void free1core(void); static void get2core(void); static void free2core(void); static void get3core(void); #ifdef DEBUG static void free3core(void); #endif /* * construct path to file and open it. */ static FILE * lex_open_driver(const char *fname, const char *dir) { FILE *fp; char path[PATH_MAX]; if (dir == NULL) dir = NBASE; (void) snprintf(path, PATH_MAX, "%s/%s", dir, fname); fp = fopen(path, "r"); if (fp == NULL) error("Lex driver missing, file %s", path); return (fp); } int main(int argc, char **argv) { int i; int c; char *apath = NULL; char *ypath; Boolean eoption = 0, woption = 0; sargv = argv; sargc = argc; (void) setlocale(LC_ALL, ""); #ifdef DEBUG while ((c = getopt(argc, argv, "dyctvnewVQ:Y:")) != EOF) { #else while ((c = getopt(argc, argv, "ctvnewVQ:Y:")) != EOF) { #endif switch (c) { #ifdef DEBUG case 'd': debug++; break; case 'y': yydebug = TRUE; break; #endif case 'V': (void) fprintf(stderr, "lex: %s %s\n", (const char *)SGU_PKG, (const char *)SGU_REL); break; case 'Q': v_stmp = optarg; if (*v_stmp != 'y' && *v_stmp != 'n') error( "lex: -Q should be followed by [y/n]"); break; case 'Y': apath = optarg; break; case 'c': ratfor = FALSE; break; case 't': fout = stdout; break; case 'v': report = 1; break; case 'n': report = 0; break; case 'w': case 'W': woption = 1; handleeuc = 1; widecio = 1; break; case 'e': case 'E': eoption = 1; handleeuc = 1; widecio = 0; break; default: (void) fprintf(stderr, "Usage: lex [-ewctvnV] [-Y directory] " "[-Q(y/n)] [file]\n"); exit(1); } } if (woption && eoption) { error( "You may not specify both -w and -e simultaneously."); } no_input = argc - optind; if (no_input) { /* XCU4: recognize "-" file operand for stdin */ if (strcmp(argv[optind], "-") == 0) fin = stdin; else { fin = fopen(argv[optind], "r"); if (fin == NULL) error( "Can't open input file -- %s", argv[optind]); } } else fin = stdin; /* may be gotten: def, subs, sname, schar, ccl, dchar */ (void) gch(); /* may be gotten: name, left, right, nullstr, parent */ get1core(); scopy(L_INITIAL, sp); sname[0] = sp; sp += slength(L_INITIAL) + 1; sname[1] = 0; /* XCU4: %x exclusive start */ exclusive[0] = 0; if (!handleeuc) { /* * Set ZCH and ncg to their default values * as they may be needed to handle %t directive. */ ZCH = ncg = NCH; /* ncg behaves as constant in this mode. */ } /* may be disposed of: def, subs, dchar */ if (yyparse()) exit(1); /* error return code */ if (handleeuc) { ncg = ncgidtbl * 2; ZCH = ncg; if (ncg >= MAXNCG) error( "Too complex rules -- requires too many char groups."); sortcgidtbl(); } repbycgid(); /* Call this even in ASCII compat. mode. */ /* * maybe get: * tmpstat, foll, positions, gotof, nexts, * nchar, state, atable, sfall, cpackflg */ free1core(); get2core(); ptail(); mkmatch(); #ifdef DEBUG if (debug) pccl(); #endif sect = ENDSECTION; if (tptr > 0) cfoll(tptr-1); #ifdef DEBUG if (debug) pfoll(); #endif cgoto(); #ifdef DEBUG if (debug) { (void) printf("Print %d states:\n", stnum + 1); for (i = 0; i <= stnum; i++) stprt(i); } #endif /* * may be disposed of: * positions, tmpstat, foll, state, name, * left, right, parent, ccl, schar, sname * maybe get: verify, advance, stoff */ free2core(); get3core(); layout(); /* * may be disposed of: * verify, advance, stoff, nexts, nchar, * gotof, atable, ccpackflg, sfall */ #ifdef DEBUG free3core(); #endif if (handleeuc) { if (ratfor) error("Ratfor is not supported by -w or -e option."); ypath = EUCNAME; } else ypath = ratfor ? RATNAME : CNAME; fother = lex_open_driver(ypath, apath); while ((i = getc(fother)) != EOF) (void) putc((char)i, fout); (void) fclose(fother); (void) fclose(fout); if (report == 1) statistics(); (void) fclose(stdout); (void) fclose(stderr); return (0); /* success return code */ } static void get1core(void) { /*LINTED: E_BAD_PTR_CAST_ALIGN*/ ccptr = ccl = (CHR *)myalloc(CCLSIZE, sizeof (*ccl)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ pcptr = pchar = (CHR *)myalloc(pchlen, sizeof (*pchar)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ def = (CHR **)myalloc(DEFSIZE, sizeof (*def)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ subs = (CHR **)myalloc(DEFSIZE, sizeof (*subs)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ dp = dchar = (CHR *)myalloc(DEFCHAR, sizeof (*dchar)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ sname = (CHR **)myalloc(STARTSIZE, sizeof (*sname)); /* XCU4: exclusive start array */ /*LINTED: E_BAD_PTR_CAST_ALIGN*/ exclusive = (int *)myalloc(STARTSIZE, sizeof (*exclusive)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ sp = schar = (CHR *)myalloc(STARTCHAR, sizeof (*schar)); if (ccl == 0 || def == 0 || pchar == 0 || subs == 0 || dchar == 0 || sname == 0 || exclusive == 0 || schar == 0) error("Too little core to begin"); } static void free1core(void) { free(def); free(subs); free(dchar); } static void get2core(void) { int i; /*LINTED: E_BAD_PTR_CAST_ALIGN*/ gotof = (int *)myalloc(nstates, sizeof (*gotof)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ nexts = (int *)myalloc(ntrans, sizeof (*nexts)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ nchar = (CHR *)myalloc(ntrans, sizeof (*nchar)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ state = (int **)myalloc(nstates, sizeof (*state)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ atable = (int *)myalloc(nstates, sizeof (*atable)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ sfall = (int *)myalloc(nstates, sizeof (*sfall)); cpackflg = (Boolean *)myalloc(nstates, sizeof (*cpackflg)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ tmpstat = (CHR *)myalloc(tptr+1, sizeof (*tmpstat)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ foll = (int **)myalloc(tptr+1, sizeof (*foll)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ nxtpos = positions = (int *)myalloc(maxpos, sizeof (*positions)); if (tmpstat == 0 || foll == 0 || positions == 0 || gotof == 0 || nexts == 0 || nchar == 0 || state == 0 || atable == 0 || sfall == 0 || cpackflg == 0) error("Too little core for state generation"); for (i = 0; i <= tptr; i++) foll[i] = 0; } static void free2core(void) { free(positions); free(tmpstat); free(foll); free(name); free(left); free(right); free(parent); free(nullstr); free(state); free(sname); /* XCU4: exclusive start array */ free(exclusive); free(schar); free(ccl); } static void get3core(void) { /*LINTED: E_BAD_PTR_CAST_ALIGN*/ verify = (int *)myalloc(outsize, sizeof (*verify)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ advance = (int *)myalloc(outsize, sizeof (*advance)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ stoff = (int *)myalloc(stnum+2, sizeof (*stoff)); if (verify == 0 || advance == 0 || stoff == 0) error("Too little core for final packing"); } #ifdef DEBUG static void free3core(void) { free(advance); free(verify); free(stoff); free(gotof); free(nexts); free(nchar); free(atable); free(sfall); free(cpackflg); } #endif BYTE * myalloc(int a, int b) { BYTE *i; i = calloc(a, b); if (i == 0) warning("calloc returns a 0"); return (i); } void yyerror(char *s) { (void) fprintf(stderr, "\"%s\":line %d: Error: %s\n", sargv[optind], yyline, s); } # # Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # interface definition for lex library # # # MAPFILE HEADER START # # WARNING: STOP NOW. DO NOT MODIFY THIS FILE. # Object versioning must comply with the rules detailed in # # usr/src/lib/README.mapfiles # # You should not be making modifications here until you've read the most current # copy of that file. If you need help, contact a gatekeeper for guidance. # # MAPFILE HEADER END # $mapfile_version 2 SYMBOL_VERSION SUNW_1.1 { global: allprint; allprint_w; main; sprint; sprint_w; yyless; yyless_e; yyless_w; yyracc; yyreject; yyreject_e; yyreject_w; yywrap; local: *; }; /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2005 Sun Microsystems, Inc. * All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1989 AT&T */ /* All Rights Reserved */ int yylineno =1; int yygid; #define LONG_WCHAR_T 1 # define YYU(x) x # define NLSTATE yyprevious=YYNEWLINE wchar_t yysbuf[YYLMAX]; wchar_t *yysptr = yysbuf; struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp; int *yyfnd; extern struct yysvf *yyestate; int yyprevious = YYNEWLINE; int yylook(void) { struct yysvf *yystate, **lsp; struct yywork *yyt; struct yysvf *yyz; int yych, yyfirst; struct yywork *yyr; # ifdef LEXDEBUG int debug; # endif wchar_t *yylastch; /* start off machines */ # ifdef LEXDEBUG debug = 0; # endif yyfirst=1; if (!yymorfg) yylastch = YYTEXT; else { yymorfg=0; yylastch = YYTEXT+YYLENG; } for(;;){ lsp = yylstate; yyestate = yystate = yybgin; if (yyprevious==YYNEWLINE) yystate++; for (;;){ # ifdef LEXDEBUG if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1); # endif yyt = yystate->yystoff; if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ yyz = yystate->yyother; if(yyz == 0)break; if(yyz->yystoff == yycrank)break; } *yylastch++ = yych = YYINPUT(); #ifdef YYISARRAY if(yylastch > &YYTEXT[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } #else if (yylastch >= &YYTEXT[ yytextsz ]) { int x = yylastch - YYTEXT; yytextsz += YYTEXTSZINC; #ifdef YYLEX_E /* -e */ if (YYTEXT == yy_twbuf) { YYTEXT = (wchar_t *) malloc(yytextsz * sizeof (wchar_t)); memcpy(YYTEXT, yy_twbuf, sizeof (yy_twbuf)); yytext = (wchar_t *) malloc(yytextsz * sizeof (wchar_t)); memcpy(yytext, yy_tbuf, sizeof (yy_tbuf)); #else if (YYTEXT == yy_tbuf) { YYTEXT = (wchar_t *) malloc(yytextsz * sizeof (wchar_t)); memcpy(YYTEXT, yy_tbuf, sizeof (yy_tbuf)); #endif } else { YYTEXT = (wchar_t *) realloc(YYTEXT, yytextsz); #ifdef YYLEX_E /* -e */ yytext = (wchar_t *) realloc(yytext, yytextsz * sizeof (wchar_t)); #endif } if (!YYTEXT) { fprintf(yyout, "Cannot realloc YYTEXT\n"); exit(1); } yylastch = YYTEXT + x; } #endif yygid = yycgid(yych); yyfirst=0; tryagain: # ifdef LEXDEBUG if(debug){ fprintf(yyout,"wchar_t "); allprint(yych); fprintf(yyout," gid %d\n", yygid); } # endif yyr = yyt; if ( (uintptr_t)yyt > (uintptr_t)yycrank){ yyt = yyr + yygid; if (yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {YYUNPUT(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } goto contin; } } # ifdef YYOPTIM else if((uintptr_t)yyt < (uintptr_t)yycrank) { /* r < yycrank */ yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG if(debug)fprintf(yyout,"compressed state\n"); # endif yyt = yyt + yygid; if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {YYUNPUT(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } goto contin; } yyt = yyr + YYU(yymatch[yygid]); # ifdef LEXDEBUG if(debug){ fprintf(yyout,"try fall back character "); allprint_w(YYU(yymatch[yygid])); fprintf(yyout," gid %d\n", yygid); } # endif if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transition */ {YYUNPUT(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } goto contin; } } if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ # ifdef LEXDEBUG if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); # endif goto tryagain; } # endif else {YYUNPUT(*--yylastch);break;} contin: # ifdef LEXDEBUG if(debug){ fprintf(yyout,"state %d wchar_t ",yystate-yysvec-1); allprint_w(yych); fprintf(yyout," gid %d\n", yygid); } # endif ; } # ifdef LEXDEBUG if(debug){ fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); allprint_w(yych); fprintf(yyout," gid %d\n", yygid); } # endif while (lsp-- > yylstate){ *yylastch-- = 0; if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ yyolsp = lsp; if(yyextra[*yyfnd]){ /* must backup */ while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ lsp--; YYUNPUT(*yylastch--); } } yyprevious = YYU(*yylastch); yylsp = lsp; YYLENG = yylastch-YYTEXT+1; YYTEXT[YYLENG] = 0; # ifdef LEXDEBUG if(debug){ fprintf(yyout,"\nmatch "); sprint_w(YYTEXT); fprintf(yyout," action %d\n",*yyfnd); } # endif #ifdef YYLEX_E /* -e */ yyleng=wcstombs((char *)yytext, YYTEXT, sizeof(yytext)-1); #ifdef LEXDEBUG if(yyleng>=sizeof(yytext)-1) fprintf(yyout, "yytext[] too short\n"); #endif #endif return(*yyfnd++); } YYUNPUT(*yylastch); } if (YYTEXT[0] == 0 /* && feof(yyin) */) { yysptr=yysbuf; return(0); } yyprevious = YYTEXT[0] = YYINPUT(); if (yyprevious>0) YYOUTPUT(yyprevious); yylastch=YYTEXT; # ifdef LEXDEBUG if(debug)putchar('\n'); # endif } } int yyback(int *p, int m) { if (p==0) return(0); while (*p) { if (*p++ == m) return(1); } return(0); } #ifdef YYLEX_E /* -e */ wchar_t yywinput(void) { unsigned char eucbuf[MB_LEN_MAX]; wchar_t wc; unsigned char *p=eucbuf; int n; #ifndef __cplusplus *p++=input(); n=euclen(eucbuf); while(--n>0) *p++=input(); #else *p++=lex_input(); n=euclen(eucbuf); while(--n>0) *p++=lex_input(); #endif *p=0; mbtowc( &wc, (char *)eucbuf, MB_LEN_MAX ); return wc; } void yywoutput(wchar_t wc) { unsigned char eucbuf[MB_LEN_MAX]; int n; unsigned char *p=eucbuf; n=wctomb( (char *)eucbuf, wc ); #ifndef __cplusplus while(n-->0) output(*p++); #else while(n-->0) lex_output(*p++); #endif } void yywunput(wchar_t wc) { unsigned char eucbuf[MB_LEN_MAX]; int n; unsigned char *p; n=wctomb( (char *)eucbuf, wc ); p=eucbuf+n; while(n-->0) unput(*--p); } #endif #ifdef LONG_WCHAR_T #define yylinearize(lc) lc #else/*!LONG_WCHAR_T*/ unsigned long yylinearize(wc) wchar_t wc; { unsigned long prefix; switch(wc&0x8080){ case 0x0000: prefix=0x00000000; break; case 0x0080: prefix=0x20000000; break; case 0x8000: prefix=0x40000000; break; case 0x8080: prefix=0x60000000; break; } return prefix|wc; } #endif/*!LONG_WCHAR_T*/ int yycgid(wchar_t c) { int first = 0; int last = YYNCGIDTBL - 1; unsigned long lc=yylinearize(c); if( yycgidtbl[YYNCGIDTBL-1] < lc ) return YYNCGIDTBL*2-1; while (last >= 0) { int i = (first+last)/2; if (lc == yycgidtbl[i]) return (2*i); else if ( yycgidtbl[i]yystoff; if(yyt == yycrank && !yyfirst){ /* may not be any transitions */ yyz = yystate->yyother; if(yyz == 0)break; if(yyz->yystoff == yycrank)break; } #ifndef __cplusplus *yylastch++ = yych = input(); #else *yylastch++ = yych = lex_input(); #endif #ifdef YYISARRAY if(yylastch > &yytext[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } #else if (yylastch >= &yytext[ yytextsz ]) { int x = yylastch - yytext; yytextsz += YYTEXTSZINC; if (yytext == yy_tbuf) { yytext = (char *) malloc(yytextsz); memcpy(yytext, yy_tbuf, sizeof (yy_tbuf)); } else yytext = (char *) realloc(yytext, yytextsz); if (!yytext) { fprintf(yyout, "Cannot realloc yytext\n"); exit(1); } yylastch = yytext + x; } #endif yyfirst=0; tryagain: # ifdef LEXDEBUG if(debug){ fprintf(yyout,"char "); allprint(yych); putchar('\n'); } # endif yyr = yyt; if ( (uintptr_t)yyt > (uintptr_t)yycrank){ yyt = yyr + yych; if (yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } goto contin; } } # ifdef YYOPTIM else if((uintptr_t)yyt < (uintptr_t)yycrank) { /* r < yycrank */ yyt = yyr = yycrank+(yycrank-yyt); # ifdef LEXDEBUG if(debug)fprintf(yyout,"compressed state\n"); # endif yyt = yyt + yych; if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transitions */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } goto contin; } yyt = yyr + YYU(yymatch[yych]); # ifdef LEXDEBUG if(debug){ fprintf(yyout,"try fall back character "); allprint(YYU(yymatch[yych])); putchar('\n'); } # endif if(yyt <= yytop && yyt->verify+yysvec == yystate){ if(yyt->advance+yysvec == YYLERR) /* error transition */ {unput(*--yylastch);break;} *lsp++ = yystate = yyt->advance+yysvec; if(lsp > &yylstate[YYLMAX]) { fprintf(yyout,"Input string too long, limit %d\n",YYLMAX); exit(1); } goto contin; } } if ((yystate = yystate->yyother) && (yyt= yystate->yystoff) != yycrank){ # ifdef LEXDEBUG if(debug)fprintf(yyout,"fall back to state %d\n",yystate-yysvec-1); # endif goto tryagain; } # endif else {unput(*--yylastch);break;} contin: # ifdef LEXDEBUG if(debug){ fprintf(yyout,"state %d char ",yystate-yysvec-1); allprint(yych); putchar('\n'); } # endif ; } # ifdef LEXDEBUG if(debug){ fprintf(yyout,"stopped at %d with ",*(lsp-1)-yysvec-1); allprint(yych); putchar('\n'); } # endif while (lsp-- > yylstate){ *yylastch-- = 0; if (*lsp != 0 && (yyfnd= (*lsp)->yystops) && *yyfnd > 0){ yyolsp = lsp; if(yyextra[*yyfnd]){ /* must backup */ while(yyback((*lsp)->yystops,-*yyfnd) != 1 && lsp > yylstate){ lsp--; unput(*yylastch--); } } yyprevious = YYU(*yylastch); yylsp = lsp; yyleng = yylastch-yytext+1; yytext[yyleng] = 0; # ifdef LEXDEBUG if(debug){ fprintf(yyout,"\nmatch "); sprint(yytext); fprintf(yyout," action %d\n",*yyfnd); } # endif return(*yyfnd++); } unput(*yylastch); } if (yytext[0] == 0 /* && feof(yyin) */) { yysptr=yysbuf; return(0); } #ifndef __cplusplus yyprevious = yytext[0] = input(); if (yyprevious>0) output(yyprevious); #else yyprevious = yytext[0] = lex_input(); if (yyprevious>0) lex_output(yyprevious); #endif yylastch=yytext; # ifdef LEXDEBUG if(debug)putchar('\n'); # endif } } int yyback(int *p, int m) { if (p==0) return(0); while (*p) { if (*p++ == m) return(1); } return(0); } /* the following are only used in the lex library */ int yyinput(void) { #ifndef __cplusplus return(input()); #else return(lex_input()); #endif } void yyoutput(int c) { #ifndef __cplusplus output(c); #else lex_output(c); #endif } void yyunput(int c) { unput(c); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright (c) 1993 by Sun Microsystems, Inc. */ block data integer cshift, csize, yynlin common /yyllib/ cshift, csize, yynlin data yynlin/YYNEWLINE/ end block data common /yyldat/ yyfnd, ymorf, yyprev, yybgin, yytop integer yyfnd, yymorf, yyprev, yybgin, yytop data yybgin/1/ data yyprev/YYNEWLINE/ data yytop/YYTOPVAL/ end integer function yylook(dummy) common /Lverif/ verif common /Ladvan/ advan common /Lstoff/ stoff common /Lsfall/ sfall common /Latable/ atable common /Lextra/ extra common /Lvstop/ vstop integer verif(Sverif), advan(Sadvan),stoff(Sstoff),match(Smatch) integer sfall(Ssfall),atable(Satable),extra(Sextra), vstop(Svstop) integer state, lsp, r integer ch, n common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yytop, yylsp, yylsta(YYLMAX) common /yyxel/ yyleng, yytext integer yyfnd, yymorf, yylsta, yylsp, yytext, yyprev, yyleng, yytop integer lexshf, yytext(YYLMAX), yyback, yybgin integer z, t if (yymorf .eq. 0) yyleng = 0 else yymorf=0 1776 lsp = 1 state = yybgin if (yyprev .eq. YYNEWLINE) state = state + 1 for (;;){ r = stoff(state) if (r .eq. 0){ z = sfall(state) if (z .eq. 0) break if(stoff(z) == 0) break } ch = input(dummy) ich = lexshf(ch) yyleng = yyleng+1 yytext(yyleng) = ch 1984 if(r .gt. 0){ t = r + ich if (t<= yytop){ if (verif(t) .eq. state){ if(advan(t) == YYERROR){ call unput(yytext(yyleng)) yyleng = yyleng - 1 break } state = advan(t) yylsta(lsp) = state lsp = lsp +1 goto 2001 } } } if(r < 0){ t = r + ich if (t <= yytop .and. verif(t) .eq. state){ if(advan(t) == YYERROR){ call unput(yytext(yyleng)) yyleng = yyleng - 1 break } state = advan(t) yylsta(lsp) = state lsp = lsp +1 goto 2001 } t = r + match(ich) if(t <= yytop && state == verif(t)){ if(advan(t) == YYERROR){ call unput(yytext(yyleng)) yyleng = yyleng - 1 break } state = advan(t) yylsta(lsp) = state lsp = lsp + 1 goto 2001 } } else { if (state > 0) state = sfall(state) if (state .gt. 0) r = stoff(state) if (state .gt. 0 .and. r .ne. 0) goto 1984 call unput(yytext(yyleng)) yyleng = yyleng -1 break } 2001 continue } while (lsp .gt. 1){ lsp = lsp -1 ilsp = yylsta(lsp) yyfnd = atable(ilsp) if (yyfnd .gt. 0) if (vstop(yyfnd) .gt. 0){ r = vstop(yyfnd) if (extra(r) .ne. 0){ for(;;){ ilsp = yylsta(lsp) if (yyback(atable(ilsp), -r) .eq. 1) break lsp= lsp -1 call unput(yytext(yyleng)) yyleng = yyleng -1 } } yyprev = lexshf(yytext(yyleng)) yylsp = lsp yyfnd = yyfnd + 1 yylook = r yytext(yyleng+1) = 0 return } call unput(yytext(yyleng)) } if (yytext(1) .eq. 0){ yylook=0 return } yyprev = input(dummy) call output(yyprev) yyprev = lexshf(yyprev) yyleng = 0 goto 1776 end integer function yyback (isub, n) common /Lvstop/ vstop integer vstop(Svstop) if (isub .ne. 0) while (vstop(isub) .ne. 0){ if (vstop(isub) .eq. m){ yyback = 1 return } isub = isub + 1 } yyback = 0 return end /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #ifndef _ONCE_H #define _ONCE_H #include "ldefs.h" /* once.c */ /* because of external definitions, this code should occur only once */ int ctable[2*NCH] = { 0, 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 }; int ZCH = NCH; FILE *fout = NULL, *errorf = {stderr}; int sect = DEFSECTION; int prev = '\n'; /* previous input character */ int pres = '\n'; /* present input character */ int peek = '\n'; /* next input character */ CHR *pushptr = pushc; CHR *slptr = slist; #define NBASE "/usr/share/lib/ccs" #define CNAME "ncform" #define RATNAME "nrform" #define EUCNAME "nceucform" int ccount = 1; int casecount = 1; int aptr = 1; int nstates = NSTATES, maxpos = MAXPOS; int treesize = TREESIZE, ntrans = NTRANS; int yytop; int outsize = NOUTPUT; int sptr = 1; int optim = TRUE; int report = 2; int debug; /* 1 = on */ int charc; char *v_stmp = "n"; int no_input; int copy_line; int n_error = 0; int fatal = 1; int sargc; char **sargv; CHR buf[BUF_SIZ]; int ratfor; /* 1 = ratfor, 0 = C */ int yyline; /* line number of file */ int eof; int lgatflg; int divflg; int funcflag; int pflag; int chset; /* 1 = char set modified */ FILE *fin, *fother; int fptr; int *name; int *left; int *right; int *parent; Boolean *nullstr; int tptr; CHR pushc[TOKENSIZE]; CHR slist[STARTSIZE]; CHR **def, **subs, *dchar; /* XCU4: %x exclusive start */ int *exclusive; CHR **sname, *schar; CHR *ccl; CHR *ccptr; CHR *dp, *sp; int dptr; CHR *bptr; /* store input position */ CHR *tmpstat; int count; int **foll; int *nxtpos; int *positions; int *gotof; int *nexts; CHR *nchar; int **state; int *sfall; /* fallback state num */ Boolean *cpackflg; /* true if state has been character packed */ int *atable; int nptr; Boolean symbol[MAXNCG]; CHR cindex[MAXNCG]; int xstate; int stnum; CHR match[MAXNCG]; BYTE extra[NACTIONS]; CHR *pchar, *pcptr; int pchlen = TOKENSIZE; long rcount; int *verify, *advance, *stoff; int scon; CHR *psave; Boolean handleeuc = FALSE; Boolean widecio = FALSE; int isArray = 1; /* XCU4: for %array %pointer */ #endif /* _ONCE_H */ %{ /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ %} /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ %{ #include "ldefs.h" #define YYSTYPE union _yystype_ union _yystype_ { int i; CHR *cp; }; int peekon = 0; /* need this to check if "^" came in a definition section */ int i; int j,k; int g; CHR *p; static wchar_t L_PctUpT[]= {'%', 'T', 0}; static wchar_t L_PctLoT[]= {'%', 't', 0}; static wchar_t L_PctCbr[]= {'%', '}', 0}; int yyerror(const char *); %} /* parser.y */ /* XCU4: add XSCON: %x exclusive start token */ /* XCU4: add ARRAY: %a yytext is char array */ /* XCU4: add POINTER: %p yytext is a pointer to char */ %token CHAR CCL NCCL STR DELIM SCON ITER NEWE NULLS XSCON ARRAY POINTER %nonassoc ARRAY POINTER %left XSCON SCON NEWE %left '/' /* * XCU4: lower the precedence of $ and ^ to less than the or operator * per Spec. 1170 */ %left '$' '^' %left '|' %left CHAR CCL NCCL '(' '.' STR NULLS %left ITER %left CAT %left '*' '+' '?' %% acc : lexinput { # ifdef DEBUG if(debug) sect2dump(); # endif } ; lexinput: defns delim prods end | defns delim end { if(!funcflag)phead2(); funcflag = TRUE; } | error { # ifdef DEBUG if(debug) { sect1dump(); sect2dump(); } # endif fatal = 0; n_error++; error("Illegal definition"); fatal = 1; } ; end: delim | ; defns: defns STR STR { scopy($2.cp,dp); def[dptr] = dp; dp += slength($2.cp) + 1; scopy($3.cp,dp); subs[dptr++] = dp; if(dptr >= DEFSIZE) error("Too many definitions"); dp += slength($3.cp) + 1; if(dp >= dchar+DEFCHAR) error("Definitions too long"); subs[dptr]=def[dptr]=0; /* for lookup - require ending null */ } | ; delim: DELIM { # ifdef DEBUG if(sect == DEFSECTION && debug) sect1dump(); # endif sect++; } ; prods: prods pr { $$.i = mn2(RNEWE,$1.i,$2.i); } | pr { $$.i = $1.i;} ; pr: r NEWE { if(divflg == TRUE) i = mn1(S1FINAL,casecount); else i = mn1(FINAL,casecount); $$.i = mn2(RCAT,$1.i,i); divflg = FALSE; if((++casecount)>NACTIONS) error("Too many (>%d) pattern-action rules.", NACTIONS); } | error NEWE { # ifdef DEBUG if(debug) sect2dump(); # endif fatal = 0; yyline--; n_error++; error("Illegal rule"); fatal = 1; yyline++; } r: CHAR { $$.i = mn0($1.i); } | STR { p = (CHR *)$1.cp; i = mn0((unsigned)(*p++)); while(*p) i = mn2(RSTR,i,(unsigned)(*p++)); $$.i = i; } | '.' { $$.i = mn0(DOT); } | CCL { $$.i = mn1(RCCL,$1.i); } | NCCL { $$.i = mn1(RNCCL,$1.i); } | r '*' { $$.i = mn1(STAR,$1.i); } | r '+' { $$.i = mn1(PLUS,$1.i); } | r '?' { $$.i = mn1(QUEST,$1.i); } | r '|' r { $$.i = mn2(BAR,$1.i,$3.i); } | r r %prec CAT { $$.i = mn2(RCAT,$1.i,$2.i); } | r '/' r { if(!divflg){ j = mn1(S2FINAL,-casecount); i = mn2(RCAT,$1.i,j); $$.i = mn2(DIV,i,$3.i); } else { $$.i = mn2(RCAT,$1.i,$3.i); error("illegal extra slash"); } divflg = TRUE; } | r ITER ',' ITER '}' { if($2.i > $4.i){ i = $2.i; $2.i = $4.i; $4.i = i; } if($4.i <= 0) error("iteration range must be positive"); else { j = $1.i; for(k = 2; k<=$2.i;k++) j = mn2(RCAT,j,dupl($1.i)); for(i = $2.i+1; i<=$4.i; i++){ g = dupl($1.i); for(k=2;k<=i;k++) g = mn2(RCAT,g,dupl($1.i)); j = mn2(BAR,j,g); } $$.i = j; } } | r ITER '}' { if($2.i < 0)error("can't have negative iteration"); else if($2.i == 0) $$.i = mn0(RNULLS); else { j = $1.i; for(k=2;k<=$2.i;k++) j = mn2(RCAT,j,dupl($1.i)); $$.i = j; } } | r ITER ',' '}' { /* from n to infinity */ if($2.i < 0)error("can't have negative iteration"); else if($2.i == 0) $$.i = mn1(STAR,$1.i); else if($2.i == 1)$$.i = mn1(PLUS,$1.i); else { /* >= 2 iterations minimum */ j = $1.i; for(k=2;k<$2.i;k++) j = mn2(RCAT,j,dupl($1.i)); k = mn1(PLUS,dupl($1.i)); $$.i = mn2(RCAT,j,k); } } | SCON r { $$.i = mn2(RSCON,$2.i,(uintptr_t)$1.cp); } /* XCU4: add XSCON */ | XSCON r { $$.i = mn2(RXSCON,$2.i,(uintptr_t)$1.cp); } | '^' r { $$.i = mn1(CARAT,$2.i); } | r '$' { i = mn0('\n'); if(!divflg){ j = mn1(S2FINAL,-casecount); k = mn2(RCAT,$1.i,j); $$.i = mn2(DIV,k,i); } else $$.i = mn2(RCAT,$1.i,i); divflg = TRUE; } | '(' r ')' { $$.i = $2.i; } | NULLS { $$.i = mn0(RNULLS); } /* XCU4: add ARRAY and POINTER */ | ARRAY { isArray = 1; }; | POINTER { isArray = 0; }; ; %% int yylex(void) { CHR *p; int i; CHR *xp; int lex_startcond_lookupval; CHR *t, c; int n, j = 0, k, x; CHR ch; static int sectbegin; static CHR token[TOKENSIZE]; static int iter; int ccs; /* Current CodeSet. */ CHR *ccp; int exclusive_flag; /* XCU4: exclusive start flag */ # ifdef DEBUG yylval.i = 0; # endif if(sect == DEFSECTION) { /* definitions section */ while(!eof) { if(prev == '\n'){ /* next char is at beginning of line */ (void)getl(p=buf); switch(*p){ case '%': switch(c= *(p+1)){ case '%': /*LINTED: E_BAD_PTR_CAST_ALIGN*/ if(scomp(p, (CHR *)"%%")) { p++; while(*(++p)) if(!space(*p)) { warning("invalid string following %%%% be ignored"); break; } } lgate(); if(!ratfor)(void) fprintf(fout,"# "); (void) fprintf(fout,"define YYNEWLINE %d\n",ctable['\n']); if(!ratfor)(void) fprintf(fout,"int yylex(){\nint nstr; extern int yyprevious;\n"); sectbegin = TRUE; i = treesize*(sizeof(*name)+sizeof(*left)+ sizeof(*right)+sizeof(*nullstr)+sizeof(*parent))+ALITTLEEXTRA; c = (int)myalloc(i,1); if(c == 0) error("Too little core for parse tree"); p = (CHR *)c; free(p); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ name = (int *)myalloc(treesize,sizeof(*name)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ left = (int *)myalloc(treesize,sizeof(*left)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ right = (int *)myalloc(treesize,sizeof(*right)); nullstr = myalloc(treesize,sizeof(*nullstr)); /*LINTED: E_BAD_PTR_CAST_ALIGN*/ parent = (int *)myalloc(treesize,sizeof(*parent)); if(name == 0 || left == 0 || right == 0 || parent == 0 || nullstr == 0) error("Too little core for parse tree"); return(freturn(DELIM)); case 'p': case 'P': /* %p or %pointer */ if ((*(p+2) == 'o') || (*(p+2) == 'O')) { if(lgatflg) error("Too late for %%pointer"); while(*p && !iswspace(*p)) p++; isArray = 0; continue; } /* has overridden number of positions */ p += 2; maxpos = siconv(p); if (maxpos<=0)error("illegal position number"); # ifdef DEBUG if (debug) (void) printf("positions (%%p) now %d\n",maxpos); # endif if(report == 2)report = 1; continue; case 'n': case 'N': /* has overridden number of states */ p += 2; nstates = siconv(p); if(nstates<=0)error("illegal state number"); # ifdef DEBUG if(debug)(void) printf( " no. states (%%n) now %d\n",nstates); # endif if(report == 2)report = 1; continue; case 'e': case 'E': /* has overridden number of tree nodes */ p += 2; treesize = siconv(p); if(treesize<=0)error("illegal number of parse tree nodes"); # ifdef DEBUG if (debug) (void) printf("treesize (%%e) now %d\n",treesize); # endif if(report == 2)report = 1; continue; case 'o': case 'O': p += 2; outsize = siconv(p); if(outsize<=0)error("illegal size of output array"); if (report ==2) report=1; continue; case 'a': case 'A': /* %a or %array */ if ((*(p+2) == 'r') || (*(p+2) == 'R')) { if(lgatflg) error("Too late for %%array"); while(*p && !iswspace(*p)) p++; isArray = 1; continue; } /* has overridden number of transitions */ p += 2; ntrans = siconv(p); if(ntrans<=0)error("illegal translation number"); # ifdef DEBUG if (debug)(void) printf("N. trans (%%a) now %d\n",ntrans); # endif if(report == 2)report = 1; continue; case 'k': case 'K': /* overriden packed char classes */ p += 2; free(pchar); pchlen = siconv(p); if(pchlen<=0)error("illegal number of packed character class"); # ifdef DEBUG if (debug) (void) printf( "Size classes (%%k) now %d\n",pchlen); # endif /*LINTED: E_BAD_PTR_CAST_ALIGN*/ pchar=pcptr=(CHR *)myalloc(pchlen, sizeof(*pchar)); if (report==2) report=1; continue; case 't': case 'T': /* character set specifier */ if(handleeuc) error("\ Character table (%t) is supported only in ASCII compatibility mode.\n"); ZCH = watoi(p+2); if (ZCH < NCH) ZCH = NCH; if (ZCH > 2*NCH) error("ch table needs redeclaration"); chset = TRUE; for(i = 0; i ZCH){ error("Character value %d out of range",n); continue; } while(digit(*p)) p++; if(!iswspace(*p)) error("bad translation format"); while(iswspace(*p)) p++; t = p; while(*t){ c = ctrans(&t); if(ctable[(unsigned)c]){ if (iswprint(c)) warning("Character '%wc' used twice",c); else error("Chararter %o used twice",c); } else ctable[(unsigned)c] = n; t++; } p = buf; } { char chused[2*NCH]; int kr; for(i=0; i= STARTSIZE) error("Too many start conditions"); sp += slength(sp) + 1; if(sp >= schar+STARTCHAR) error("Start conditions too long"); } continue; default: error("Invalid request %s",p); continue; } /* end of switch after seeing '%' */ break; case ' ': case '\t': /* must be code */ lgate(); if( p[1]=='/' && p[2]=='*' ) cpycom(p); else (void) fprintf(fout, "%ws\n", p); continue; case '/': /* look for comments */ lgate(); if((*(p+1))=='*') cpycom(p); /* FALLTHRU */ default: /* definition */ while(*p && !iswspace(*p)) p++; if(*p == 0) continue; prev = *p; *p = 0; bptr = p+1; yylval.cp = (CHR *)buf; if(digit(buf[0])) warning("Substitution strings may not begin with digits"); return(freturn(STR)); } } else { /* still sect 1, but prev != '\n' */ p = bptr; while(*p && iswspace(*p)) p++; if(*p == 0) warning("No translation given - null string assumed"); scopy(p,token); yylval.cp = (CHR *)token; prev = '\n'; return(freturn(STR)); } } error("unexpected EOF before %%%%"); /* end of section one processing */ } else if(sect == RULESECTION){ /* rules and actions */ lgate(); while(!eof){ static int first_test=TRUE, first_value; static int reverse=FALSE; switch(c=gch()){ case '\0': if(n_error)error_tail(); return(freturn(0)); case '\n': if(prev == '\n') continue; x = NEWE; break; case ' ': case '\t': if(prev == '\n') copy_line = TRUE; if(sectbegin == TRUE){ (void)cpyact(); copy_line = FALSE; /*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/ while((c=gch()) && c != '\n'); continue; } if(!funcflag)phead2(); funcflag = TRUE; if(ratfor)(void) fprintf(fout,"%d\n",30000+casecount); else (void) fprintf(fout,"case %d:\n",casecount); if(cpyact()){ if(ratfor)(void) fprintf(fout,"goto 30997\n"); else (void) fprintf(fout,"break;\n"); } /*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/ while((c=gch()) && c != '\n') { if (c=='/') { if((c=gch())=='*') { c=gch(); while(c !=EOF) { while (c=='*') if ((c=gch()) == '/') goto w_loop; c = gch(); } error("EOF inside comment"); } else warning("undefined string"); } else if (c=='}') error("illegal extra \"}\""); w_loop: ; } /* while ((c=gch())== ' ' || c == '\t') ; */ /* if (!space(c)) error("undefined action string"); */ if(peek == ' ' || peek == '\t' || sectbegin == TRUE){ fatal = 0; n_error++; error("executable statements should occur right after %%%%"); fatal = 1; continue; } x = NEWE; break; case '%': if(prev != '\n') goto character; if(peek == '{'){ /* included code */ (void)getl(buf); while(!eof&& getl(buf) && scomp(L_PctCbr,buf)!=0) if(buf[0]=='/' && buf[1]=='*') cpycom(buf); else (void) fprintf(fout, "%ws\n", buf); continue; } if(peek == '%'){ c = gch(); c = gch(); x = DELIM; break; } goto character; case '|': if(peek == ' ' || peek == '\t' || peek == '\n'){ if(ratfor)(void) fprintf(fout,"%d\n",30000+casecount++); else (void) fprintf(fout,"case %d:\n",casecount++); continue; } x = '|'; break; case '$': if(peek == '\n' || peek == ' ' || peek == '\t' || peek == '|' || peek == '/'){ x = c; break; } goto character; case '^': if(peekon && (prev == '}')){ x = c; break; } if(prev != '\n' && scon != TRUE) goto character; /* valid only at line begin */ x = c; break; case '?': case '+': case '*': if(prev == '\n' ) { fatal = 0; n_error++; error("illegal operator -- %c",c); fatal = 1; } /* FALLTHRU */ case '.': case '(': case ')': case ',': case '/': x = c; break; case '}': iter = FALSE; x = c; break; case '{': /* either iteration or definition */ if(digit(c=gch())){ /* iteration */ iter = TRUE; if(prev=='{') first_test = TRUE; ieval: i = 0; while(digit(c)){ token[i++] = c; c = gch(); } token[i] = 0; yylval.i = siconv(token); if(first_test) { first_test = FALSE; first_value = yylval.i; } else if(first_value>yylval.i)warning("the values between braces are reversed"); ch = c; munput('c',&ch); x = ITER; break; } else { /* definition */ i = 0; while(c && c!='}'){ token[i++] = c; if(i >= TOKENSIZE) error("definition too long"); c = gch(); } token[i] = 0; i = lookup(token,def); if(i < 0) error("definition %ws not found",token); else munput('s',(CHR *)(subs[i])); if (peek == '^') peekon = 1; continue; } case '<': /* start condition ? */ if(prev != '\n') /* not at line begin, not start */ goto character; t = slptr; do { i = 0; if(!isascii(c = gch())) error("Non-ASCII characters in start condition."); while(c != ',' && c && c != '>'){ token[i++] = c; if(i >= TOKENSIZE) error("string name too long"); if(!isascii(c = gch())) error("None-ASCII characters in start condition."); } token[i] = 0; if(i == 0) goto character; i = lookup(token,sname); lex_startcond_lookupval = i; if(i < 0) { fatal = 0; n_error++; error("undefined start condition %ws",token); fatal = 1; continue; } *slptr++ = i+1; } while(c && c != '>'); *slptr++ = 0; /* check if previous value re-usable */ for (xp=slist; xp slist+STARTSIZE) /* note not packed */ error("Too many start conditions used"); yylval.cp = (CHR *)t; /* XCU4: add XSCON */ if (exclusive[lex_startcond_lookupval]) x = XSCON; else x = SCON; break; case '"': i = 0; /*LINTED: E_EQUALITY_NOT_ASSIGNMENT*/ while((c=gch()) && c != '"' && c != '\n'){ if(c == '\\') c = usescape(c=gch()); remch(c); token[i++] = c; if(i >= TOKENSIZE){ warning("String too long"); i = TOKENSIZE-1; break; } } if(c == '\n') { yyline--; warning("Non-terminated string"); yyline++; } token[i] = 0; if(i == 0)x = NULLS; else if(i == 1){ yylval.i = (unsigned)token[0]; x = CHAR; } else { yylval.cp = (CHR *)token; x = STR; } break; case '[': reverse = FALSE; x = CCL; if((c = gch()) == '^'){ x = NCCL; reverse = TRUE; c = gch(); } i = 0; while(c != ']' && c){ static int light=TRUE, ESCAPE=FALSE; if(c == '-' && prev == '^' && reverse){ symbol[(unsigned)c] = 1; c = gch(); continue; } if(c == '\\') { c = usescape(c=gch()); ESCAPE = TRUE; } if(c=='-' && !ESCAPE && prev!='[' && peek!=']'){ /* range specified */ if (light) { c = gch(); if(c == '\\') c=usescape(c=gch()); remch(c); k = c; ccs=wcsetno(k); if(wcsetno(j)!=ccs) error("\ Character range specified between different codesets."); if((unsigned)j > (unsigned)k) { n = j; j = k; k = n; } if(!handleeuc) if(!(('A'<=j && k<='Z') || ('a'<=j && k<='z') || ('0'<=j && k<='9'))) warning("Non-portable Character Class"); token[i++] = RANGE; token[i++] = j; token[i++] = k; light = FALSE; } else { error("unmatched hyphen"); if(symbol[(unsigned)c])warning("\"%c\" redefined inside brackets",c); else symbol[(unsigned)c] = 1; } ESCAPE = FALSE; } else { j = c; remch(c); token[i++] = c; /* Remember whatever.*/ light = TRUE; ESCAPE = FALSE; } c = gch(); } /* try to pack ccl's */ token[i] = 0; ccp = ccl; while (ccp < ccptr && scomp(token, ccp) != 0) ccp++; if (ccp < ccptr) { /* found in ccl */ yylval.cp = ccp; } else { /* not in ccl, add it */ scopy(token,ccptr); yylval.cp = ccptr; ccptr += slength(token) + 1; if(ccptr >= ccl+CCLSIZE) error("Too many large character classes"); } break; case '\\': c = usescape(c=gch()); /* FALLTHROUGH */ default: character: if(iter){ /* second part of an iteration */ iter = FALSE; if('0' <= c && c <= '9') goto ieval; } remch(c); if(alpha(peek)){ i = 0; yylval.cp = (CHR *)token; token[i++] = c; while(alpha(peek)) { remch(token[i++] = gch()); if(i >= TOKENSIZE) { warning("string too long"); i = TOKENSIZE - 1; break; } } if(peek == '?' || peek == '*' || peek == '+') munput('c',&token[--i]); token[i] = 0; if(i == 1){ yylval.i = (unsigned)(token[0]); x = CHAR; } else x = STR; } else { yylval.i = (unsigned)c; x = CHAR; } } scon = FALSE; peekon = 0; if((x == SCON) || (x == XSCON)) scon = TRUE; sectbegin = FALSE; return(freturn(x)); /* NOTREACHED */ } } /* section three */ lgate(); ptail(); # ifdef DEBUG if(debug) (void) fprintf(fout,"\n/*this comes from section three - debug */\n"); # endif if(getl(buf) && !eof) { if (sargv[optind] == NULL) (void) fprintf(fout, "\n# line %d\n", yyline-1); else (void) fprintf(fout, "\n# line %d \"%s\"\n", yyline-1, sargv[optind]); (void) fprintf(fout, "%ws\n", buf); while(getl(buf) && !eof) (void) fprintf(fout, "%ws\n", buf); } return(freturn(0)); } /* end of yylex */ # ifdef DEBUG freturn(i) int i; { if(yydebug) { (void) printf("now return "); if((unsigned)i < NCH) allprint(i); else (void) printf("%d",i); (void) printf(" yylval = "); switch(i){ case STR: case CCL: case NCCL: strpt(yylval.cp); break; case CHAR: allprint(yylval.i); break; default: (void) printf("%d",yylval.i); break; } (void) putchar('\n'); } return(i); } # endif /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* Copyright (c) 1989 AT&T */ /* All Rights Reserved */ #include #ifdef EUC #include #include #include #endif #ifndef JLSLEX #pragma weak yyinput #pragma weak yyleng #pragma weak yytext #pragma weak yyunput #define CHR char #define YYTEXT yytext #define YYLENG yyleng #define YYINPUT yyinput #define YYUNPUT yyunput #define YYOUTPUT yyoutput #define YYREJECT yyreject #endif #ifdef WOPTION #pragma weak yyinput #pragma weak yyleng #pragma weak yytext #pragma weak yyunput #define CHR wchar_t #define YYTEXT yytext #define YYLENG yyleng #define YYINPUT yyinput #define YYUNPUT yyunput #define YYOUTPUT yyoutput #define YYREJECT yyreject_w #endif #ifdef EOPTION #pragma weak yyleng #pragma weak yytext #pragma weak yywinput #pragma weak yywleng #pragma weak yywtext #pragma weak yywunput #define CHR wchar_t #define YYTEXT yywtext #define YYLENG yywleng #define YYINPUT yywinput #define YYUNPUT yywunput #define YYOUTPUT yywoutput #define YYREJECT yyreject_e extern unsigned char yytext[]; extern int yyleng; #endif #pragma weak yyback extern int yyback(int *, int); extern int YYINPUT(void); extern void YYUNPUT(int); #ifdef EUC static int yyracc(int); #else extern int yyracc(int); #endif #ifdef EOPTION extern size_t wcstombs(char *, const wchar_t *, size_t); #endif #pragma weak yyout extern FILE *yyout, *yyin; #pragma weak yyfnd #pragma weak yyprevious extern int yyprevious, *yyfnd; #pragma weak yyextra extern char yyextra[]; extern int YYLENG; extern CHR YYTEXT[]; #pragma weak yylsp #pragma weak yylstate #pragma weak yyolsp extern struct {int *yyaa, *yybb; int *yystops; } *yylstate[], **yylsp, **yyolsp; int YYREJECT(void) { for (; yylsp < yyolsp; yylsp++) YYTEXT[YYLENG++] = YYINPUT(); if (*yyfnd > 0) return (yyracc(*yyfnd++)); while (yylsp-- > yylstate) { YYUNPUT(YYTEXT[YYLENG-1]); YYTEXT[--YYLENG] = 0; if (*yylsp != 0 && (yyfnd = (*yylsp)->yystops) && *yyfnd > 0) return (yyracc(*yyfnd++)); } #ifdef EOPTION yyleng = wcstombs((char *)yytext, YYTEXT, YYLENG*MB_LEN_MAX); #endif if (YYTEXT[0] == 0) return (0); YYLENG = 0; #ifdef EOPTION yyleng = 0; #endif return (-1); } int yyracc(int m) { yyolsp = yylsp; if (yyextra[m]) { while (yyback((*yylsp)->yystops, -m) != 1 && yylsp > yylstate) { yylsp--; YYUNPUT(YYTEXT[--YYLENG]); } } yyprevious = YYTEXT[YYLENG-1]; YYTEXT[YYLENG] = 0; #ifdef EOPTION yyleng = wcstombs((char *)yytext, YYTEXT, YYLENG*MB_LEN_MAX); #endif return (m); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #include #include #include "ldefs.h" #include /* * return next line of input, throw away trailing '\n' * and also throw away trailing blanks (spaces and tabs) * returns 0 if eof is had immediately */ CHR * getl(CHR *p) { int c; CHR *s, *t, *u; int blank = 0; t = s = p; while (((c = gch()) != 0) && c != '\n') { if (t >= &p[BUF_SIZ]) error("definitions too long"); if (c == ' ' || c == '\t') { if (!blank) { blank = 1; u = t; } } else blank = 0; *t++ = c; } if (blank) *u = 0; else *t = 0; if (c == 0 && s == t) return ((CHR *) 0); prev = '\n'; pres = '\n'; return (s); } int space(int ch) { switch (ch) { case ' ': case '\t': case '\n': return (1); } return (0); } int digit(int c) { return (c >= '0' && c <= '9'); } void error(char *s, ...) { va_list ap; /* if(!eof) */ if (!yyline) { (void) fprintf(errorf, "Command line: "); } else { (void) fprintf(errorf, !no_input ? "" : "\"%s\":", sargv[optind]); (void) fprintf(errorf, "line %d: ", yyline); } (void) fprintf(errorf, "Error: "); va_start(ap, s); (void) vfprintf(errorf, s, ap); va_end(ap); (void) putc('\n', errorf); if (fatal) error_tail(); } void error_tail(void) { #ifdef DEBUG if (debug && sect != ENDSECTION) { sect1dump(); sect2dump(); } #endif if (report == 1) statistics(); exit(1); /* NOTREACHED */ } void warning(char *s, ...) { va_list ap; if (!eof) { if (!yyline) { (void) fprintf(errorf, "Command line: "); } else { (void) fprintf(errorf, !no_input ? "" : "\"%s\":", sargv[optind]); (void) fprintf(errorf, "line %d: ", yyline); } } (void) fprintf(errorf, "Warning: "); va_start(ap, s); (void) vfprintf(errorf, s, ap); va_end(ap); (void) putc('\n', errorf); (void) fflush(errorf); if (fout) (void) fflush(fout); (void) fflush(stdout); } /* * This function is apparently unused, but lint flags the fact * that it does not have the same signature as the libc function * of the same name. So, take it out of view for lint. */ #if !defined(__lint) int index(int a, CHR *s) { int k; for (k = 0; s[k]; k++) if (s[k] == a) return (k); return (-1); } #endif int alpha(int c) { return (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')); } int printable(int c) { return (c > 040 && c < 0177); } void lgate(void) { char fname[20]; if (lgatflg) return; lgatflg = 1; if (fout == NULL) { (void) sprintf(fname, "lex.yy.%c", ratfor ? 'r' : 'c'); fout = fopen(fname, "w"); } if (fout == NULL) error("Can't open %s", fname); if (ratfor) (void) fprintf(fout, "#\n"); phead1(); } /* * scopy(ptr to str, ptr to str) - copy first arg str to second * returns ptr to second arg */ void scopy(CHR *s, CHR *t) { CHR *i; i = t; while ((*i++ = *s++) != 0) ; } /* * convert string t, return integer value */ int siconv(CHR *t) { int i, sw; CHR *s; s = t; while (space(*s)) s++; if (!digit(*s) && *s != '-') error("missing translation value"); sw = 0; if (*s == '-') { sw = 1; s++; } if (!digit(*s)) error("incomplete translation format"); i = 0; while ('0' <= *s && *s <= '9') i = i * 10 + (*(s++)-'0'); return (sw ? -i : i); } /* * slength(ptr to str) - return integer length of string arg * excludes '\0' terminator */ int slength(CHR *s) { int n; CHR *t; t = s; for (n = 0; *t++; n++) ; return (n); } /* * scomp(x,y) - return -1 if x < y, * 0 if x == y, * return 1 if x > y, all lexicographically */ int scomp(CHR *x, CHR *y) { CHR *a, *d; a = (CHR *) x; d = (CHR *) y; while (*a || *d) { if (*a > *d) return (1); if (*a < *d) return (-1); a++; d++; } return (0); } int ctrans(CHR **ss) { int c, k; if ((c = **ss) != '\\') return (c); switch (c = *++*ss) { case 'a': c = '\a'; warning("\\a is ANSI C \"alert\" character"); break; case 'v': c = '\v'; break; case 'n': c = '\n'; break; case 't': c = '\t'; break; case 'r': c = '\r'; break; case 'b': c = '\b'; break; case 'f': c = 014; break; /* form feed for ascii */ case '\\': c = '\\'; break; case 'x': { int dd; warning("\\x is ANSI C hex escape"); if (digit((dd = *++*ss)) || ('a' <= dd && dd <= 'f') || ('A' <= dd && dd <= 'F')) { c = 0; while (digit(dd) || ('A' <= dd && dd <= 'F') || ('a' <= dd && dd <= 'f')) { if (digit(dd)) c = c*16 + dd - '0'; else if (dd >= 'a') c = c*16 + 10 + dd - 'a'; else c = c*16 + 10 + dd - 'A'; dd = *++*ss; } } else c = 'x'; break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': c -= '0'; while ((k = *(*ss+1)) >= '0' && k <= '7') { c = c*8 + k - '0'; (*ss)++; } break; } return (c); } void cclinter(int sw) { /* sw = 1 ==> ccl */ int i, j, k; int m; if (!sw) { /* is NCCL */ for (i = 1; i < ncg; i++) symbol[i] ^= 1; /* reverse value */ } for (i = 1; i < ncg; i++) if (symbol[i]) break; if (i >= ncg) return; i = cindex[i]; /* see if ccl is already in our table */ j = 0; if (i) { for (j = 1; j < ncg; j++) { if ((symbol[j] && cindex[j] != i) || (!symbol[j] && cindex[j] == i)) break; } } if (j >= ncg) return; /* already in */ m = 0; k = 0; for (i = 1; i < ncg; i++) { if (symbol[i]) { if (!cindex[i]) { cindex[i] = ccount; symbol[i] = 0; m = 1; } else k = 1; } } /* m == 1 implies last value of ccount has been used */ if (m) ccount++; if (k == 0) return; /* is now in as ccount wholly */ /* intersection must be computed */ for (i = 1; i < ncg; i++) { if (symbol[i]) { m = 0; j = cindex[i]; /* will be non-zero */ for (k = 1; k < ncg; k++) { if (cindex[k] == j) { if (symbol[k]) symbol[k] = 0; else { cindex[k] = ccount; m = 1; } } } if (m) ccount++; } } } int usescape(int c) { char d; switch (c) { case 'a': c = '\a'; warning("\\a is ANSI C \"alert\" character"); break; case 'v': c = '\v'; break; case 'n': c = '\n'; break; case 'r': c = '\r'; break; case 't': c = '\t'; break; case 'b': c = '\b'; break; case 'f': c = 014; break; /* form feed for ascii */ case 'x': { int dd; if (digit((dd = gch())) || ('A' <= dd && dd <= 'F') || ('a' <= dd && dd <= 'f')) { c = 0; while (digit(dd) || ('A' <= dd && dd <= 'F') || ('a' <= dd && dd <= 'f')) { if (digit(dd)) c = c*16 + dd - '0'; else if (dd >= 'a') c = c*16 + 10 + dd - 'a'; else c = c*16 + 10 + dd - 'A'; if (!digit(peek) && !('A' <= peek && peek <= 'F') && !('a' <= peek && peek <= 'f')) break; dd = gch(); } } else c = 'x'; break; } case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': c -= '0'; while ('0' <= (d = gch()) && d <= '7') { c = c * 8 + (d-'0'); if (!('0' <= peek && peek <= '7')) break; } break; } if (handleeuc && !isascii(c)) { char tmpchar = c & 0x00ff; (void) mbtowc((wchar_t *)&c, &tmpchar, sizeof (tmpchar)); } return (c); } int lookup(CHR *s, CHR **t) { int i; i = 0; while (*t) { if (scomp(s, *t) == 0) return (i); i++; t++; } return (-1); } void cpycom(CHR *p) { static CHR *t; static int c; t = p; if (sargv[optind] == NULL) (void) fprintf(fout, "\n# line %d\n", yyline); else (void) fprintf(fout, "\n# line %d \"%s\"\n", yyline, sargv[optind]); (void) putc(*t++, fout); (void) putc(*t++, fout); while (*t) { while (*t == '*') { (void) putc(*t++, fout); if (*t == '/') goto backcall; } /* * FIX BUG #1058428, not parsing comments correctly * that span more than one line */ if (*t != 0) (void) putc(*t++, fout); } (void) putc('\n', fout); while ((c = gch()) != 0) { while (c == '*') { (void) putc((char)c, fout); if ((c = gch()) == '/') { while ((c = gch()) == ' ' || c == '\t') ; if (!space(c)) error("unacceptable statement"); prev = '\n'; goto backcall; } } (void) putc((char)c, fout); } error("unexpected EOF inside comment"); backcall: (void) putc('/', fout); (void) putc('\n', fout); } /* * copy C action to the next ; or closing */ int cpyact(void) { int brac, c, mth; static int sw, savline; brac = 0; sw = TRUE; savline = yyline; if (sargv[optind] == NULL) (void) fprintf(fout, "\n# line %d\n", yyline); else (void) fprintf(fout, "\n# line %d \"%s\"\n", yyline, sargv[optind]); while (!eof) { c = gch(); swt: switch (c) { case '|': if (brac == 0 && sw == TRUE) { if (peek == '|') (void) gch(); /* eat up an extra '|' */ return (0); } break; case ';': if (brac == 0) { (void) putwc(c, fout); (void) putc('\n', fout); return (1); } break; case '{': brac++; savline = yyline; break; case '}': brac--; if (brac == 0) { (void) putwc(c, fout); (void) putc('\n', fout); return (1); } break; case '/': (void) putwc(c, fout); c = gch(); if (c != '*') goto swt; (void) putwc(c, fout); savline = yyline; while ((c = gch()) != 0) { while (c == '*') { (void) putwc(c, fout); if ((c = gch()) == '/') { (void) putc('/', fout); while ((c = gch()) == ' ' || c == '\t' || c == '\n') (void) putwc(c, fout); goto swt; } } (void) putc((char)c, fout); } yyline = savline; error("EOF inside comment"); /* NOTREACHED */ break; case '\'': /* character constant */ case '"': /* character string */ mth = c; (void) putwc(c, fout); while ((c = gch()) != 0) { if (c == '\\') { (void) putwc(c, fout); c = gch(); } else if (c == mth) goto loop; (void) putwc(c, fout); if (c == '\n') { yyline--; error( "Non-terminated string or character constant"); } } error("EOF in string or character constant"); /* NOTREACHED */ break; case '\0': yyline = savline; error("Action does not terminate"); /* NOTREACHED */ break; default: break; /* usual character */ } loop: if (c != ' ' && c != '\t' && c != '\n') sw = FALSE; (void) putwc(c, fout); if (peek == '\n' && !brac && copy_line) { (void) putc('\n', fout); return (1); } } error("Premature EOF"); return (0); } int gch(void) { int c; prev = pres; c = pres = peek; peek = pushptr > pushc ? *--pushptr : getwc(fin); while (peek == EOF) { if (no_input) { if (!yyline) error("Cannot read from -- %s", sargv[optind]); if (optind < sargc-1) { yyline = 0; if (fin != stdin) (void) fclose(fin); fin = fopen(sargv[++optind], "r"); if (fin == NULL) error("Cannot open file -- %s", sargv[optind]); peek = getwc(fin); } else break; } else { if (fin != stdin) (void) fclose(fin); if (!yyline) error("Cannot read from -- standard input"); else break; } } if (c == EOF) { eof = TRUE; return (0); } if (c == '\n') yyline++; return (c); } int mn2(int a, int d, int c) { if (tptr >= treesize) { tptr++; error("Parse tree too big %s", (treesize == TREESIZE ? "\nTry using %e num" : "")); } if (d >= treesize) { error("Parse error"); } name[tptr] = a; left[tptr] = d; right[tptr] = c; parent[tptr] = 0; nullstr[tptr] = 0; switch (a) { case RSTR: parent[d] = tptr; break; case BAR: case RNEWE: if (nullstr[d] || nullstr[c]) nullstr[tptr] = TRUE; parent[d] = parent[c] = tptr; break; case RCAT: case DIV: if (nullstr[d] && nullstr[c]) nullstr[tptr] = TRUE; parent[d] = parent[c] = tptr; break; /* XCU4: add RXSCON */ case RXSCON: case RSCON: parent[d] = tptr; nullstr[tptr] = nullstr[d]; break; #ifdef DEBUG default: warning("bad switch mn2 %d %d", a, d); break; #endif } return (tptr++); } int mn1(int a, int d) { if (tptr >= treesize) { tptr++; error("Parse tree too big %s", (treesize == TREESIZE ? "\nTry using %e num" : "")); } name[tptr] = a; left[tptr] = d; parent[tptr] = 0; nullstr[tptr] = 0; switch (a) { case RCCL: case RNCCL: if (slength((CHR *)d) == 0) nullstr[tptr] = TRUE; break; case STAR: case QUEST: nullstr[tptr] = TRUE; parent[d] = tptr; break; case PLUS: case CARAT: nullstr[tptr] = nullstr[d]; parent[d] = tptr; break; case S2FINAL: nullstr[tptr] = TRUE; break; #ifdef DEBUG case FINAL: case S1FINAL: break; default: warning("bad switch mn1 %d %d", a, d); break; #endif } return (tptr++); } int mn0(int a) { if (tptr >= treesize) { tptr++; error("Parse tree too big %s", (treesize == TREESIZE ? "\nTry using %e num" : "")); } name[tptr] = a; parent[tptr] = 0; nullstr[tptr] = 0; if (ISOPERATOR(a)) { switch (a) { case DOT: break; case RNULLS: nullstr[tptr] = TRUE; break; #ifdef DEBUG default: warning("bad switch mn0 %d", a); break; #endif } } return (tptr++); } void munput(int t, CHR *p) { int i, j; if (t == 'c') { *pushptr++ = peek; peek = *p; } else if (t == 's') { *pushptr++ = peek; peek = p[0]; i = slength(p); for (j = i - 1; j >= 1; j--) *pushptr++ = p[j]; } if (pushptr >= pushc + TOKENSIZE) error("Too many characters pushed"); } int dupl(int n) { /* duplicate the subtree whose root is n, return ptr to it */ int i; i = name[n]; if (!ISOPERATOR(i)) return (mn0(i)); switch (i) { case DOT: case RNULLS: return (mn0(i)); case RCCL: case RNCCL: case FINAL: case S1FINAL: case S2FINAL: return (mn1(i, left[n])); case STAR: case QUEST: case PLUS: case CARAT: return (mn1(i, dupl(left[n]))); /* XCU4: add RXSCON */ case RSTR: case RSCON: case RXSCON: return (mn2(i, dupl(left[n]), right[n])); case BAR: case RNEWE: case RCAT: case DIV: return (mn2(i, dupl(left[n]), dupl(right[n]))); } return (0); } #ifdef DEBUG void allprint(CHR c) { switch (c) { case 014: (void) printf("\\f"); charc++; break; case '\n': (void) printf("\\n"); charc++; break; case '\t': (void) printf("\\t"); charc++; break; case '\b': (void) printf("\\b"); charc++; break; case ' ': (void) printf("\\_"); break; default: if (!iswprint(c)) { printf("\\x%-2x", c); /* up to fashion. */ charc += 3; } else (void) putwc(c, stdout); break; } charc++; } void strpt(CHR *s) { charc = 0; while (*s) { allprint(*s++); if (charc > LINESIZE) { charc = 0; (void) printf("\n\t"); } } } void sect1dump(void) { int i; (void) printf("Sect 1:\n"); if (def[0]) { (void) printf("str trans\n"); i = -1; while (def[++i]) (void) printf("%ws\t%ws\n", def[i], subs[i]); } if (sname[0]) { (void) printf("start names\n"); i = -1; while (sname[++i]) (void) printf("%ws\n", sname[i]); } if (chset == TRUE) { (void) printf("char set changed\n"); for (i = 1; i < NCH; i++) { if (i != ctable[i]) { allprint(i); (void) putchar(' '); iswprint(ctable[i]) ? (void) putwc(ctable[i], stdout) : (void) printf("%d", ctable[i]); (void) putchar('\n'); } } } } void sect2dump(void) { (void) printf("Sect 2:\n"); treedump(); } void treedump(void) { int t; CHR *p; (void) printf("treedump %d nodes:\n", tptr); for (t = 0; t < tptr; t++) { (void) printf("%4d ", t); parent[t] ? (void) printf("p=%4d", parent[t]) : (void) printf(" "); (void) printf(" "); if (!ISOPERATOR(name[t])) { allprint(name[t]); } else switch (name[t]) { case RSTR: (void) printf("%d ", left[t]); allprint(right[t]); break; case RCCL: (void) printf("ccl "); strpt(left[t]); break; case RNCCL: (void) printf("nccl "); strpt(left[t]); break; case DIV: (void) printf("/ %d %d", left[t], right[t]); break; case BAR: (void) printf("| %d %d", left[t], right[t]); break; case RCAT: (void) printf("cat %d %d", left[t], right[t]); break; case PLUS: (void) printf("+ %d", left[t]); break; case STAR: (void) printf("* %d", left[t]); break; case CARAT: (void) printf("^ %d", left[t]); break; case QUEST: (void) printf("? %d", left[t]); break; case RNULLS: (void) printf("nullstring"); break; case FINAL: (void) printf("final %d", left[t]); break; case S1FINAL: (void) printf("s1final %d", left[t]); break; case S2FINAL: (void) printf("s2final %d", left[t]); break; case RNEWE: (void) printf("new %d %d", left[t], right[t]); break; /* XCU4: add RXSCON */ case RXSCON: p = (CHR *)right[t]; (void) printf("exstart %s", sname[*p++-1]); while (*p) (void) printf(", %ws", sname[*p++-1]); (void) printf(" %d", left[t]); break; case RSCON: p = (CHR *)right[t]; (void) printf("start %s", sname[*p++-1]); while (*p) (void) printf(", %ws", sname[*p++-1]); (void) printf(" %d", left[t]); break; case DOT: printf("dot"); break; default: (void) printf( "unknown %d %d %d", name[t], left[t], right[t]); break; } if (nullstr[t]) (void) printf("\t(null poss.)"); (void) putchar('\n'); } } #endif /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #include "ldefs.h" static void add(int **array, int n); static void follow(int v); static void first(int v); static void nextstate(int s, int c); static void packtrans(int st, CHR *tch, int *tst, int cnt, int tryit); static void acompute(int s); static void rprint(int *a, char *s, int n); static void shiftr(int *a, int n); static void upone(int *a, int n); static void bprint(char *a, char *s, int n); static int notin(int n); static int member(int d, CHR *t); #ifdef PP static void padd(int **array, int n); #endif void cfoll(int v) { int i, j, k; CHR *p; i = name[v]; if (!ISOPERATOR(i)) i = 1; switch (i) { case 1: case RSTR: case RCCL: case RNCCL: case RNULLS: for (j = 0; j < tptr; j++) tmpstat[j] = FALSE; count = 0; follow(v); #ifdef PP padd(foll, v); /* packing version */ #else add(foll, v); /* no packing version */ #endif if (i == RSTR) cfoll(left[v]); else if (i == RCCL || i == RNCCL) { for (j = 1; j < ncg; j++) symbol[j] = (i == RNCCL); p = (CHR *) left[v]; while (*p) symbol[*p++] = (i == RCCL); p = pcptr; for (j = 1; j < ncg; j++) if (symbol[j]) { for (k = 0; p + k < pcptr; k++) if (cindex[j] == *(p + k)) break; if (p + k >= pcptr) *pcptr++ = cindex[j]; } *pcptr++ = 0; if (pcptr > pchar + pchlen) error( "Too many packed character classes"); left[v] = (int)p; name[v] = RCCL; /* RNCCL eliminated */ #ifdef DEBUG if (debug && *p) { (void) printf("ccl %d: %d", v, *p++); while (*p) (void) printf(", %d", *p++); (void) putchar('\n'); } #endif } break; case CARAT: cfoll(left[v]); break; /* XCU4: add RXSCON */ case RXSCON: case STAR: case PLUS: case QUEST: case RSCON: cfoll(left[v]); break; case BAR: case RCAT: case DIV: case RNEWE: cfoll(left[v]); cfoll(right[v]); break; #ifdef DEBUG case FINAL: case S1FINAL: case S2FINAL: break; default: warning("bad switch cfoll %d", v); #endif } } #ifdef DEBUG void pfoll(void) { int i, k, *p; int j; /* print sets of chars which may follow positions */ (void) printf("pos\tchars\n"); for (i = 0; i < tptr; i++) if (p = foll[i]) { j = *p++; if (j >= 1) { (void) printf("%d:\t%d", i, *p++); for (k = 2; k <= j; k++) (void) printf(", %d", *p++); (void) putchar('\n'); } } } #endif static void add(int **array, int n) { int i, *temp; CHR *ctemp; temp = nxtpos; ctemp = tmpstat; array[n] = nxtpos; /* note no packing is done in positions */ *temp++ = count; for (i = 0; i < tptr; i++) if (ctemp[i] == TRUE) *temp++ = i; nxtpos = temp; if (nxtpos >= positions+maxpos) error( "Too many positions %s", (maxpos == MAXPOS ? "\nTry using %p num" : "")); } static void follow(int v) { int p; if (v >= tptr-1) return; p = parent[v]; if (p == 0) return; switch (name[p]) { /* will not be CHAR RNULLS FINAL S1FINAL S2FINAL RCCL RNCCL */ case RSTR: if (tmpstat[p] == FALSE) { count++; tmpstat[p] = TRUE; } break; case STAR: case PLUS: first(v); follow(p); break; case BAR: case QUEST: case RNEWE: follow(p); break; case RCAT: case DIV: if (v == left[p]) { if (nullstr[right[p]]) follow(p); first(right[p]); } else follow(p); break; /* XCU4: add RXSCON */ case RXSCON: case RSCON: case CARAT: follow(p); break; #ifdef DEBUG default: warning("bad switch follow %d", p); #endif } } /* * Check if I have a RXSCON in my upper node */ static int check_me(int v) { int tmp = parent[v]; while (name[tmp] != RNEWE) { if (name[tmp] == RXSCON) return (1); tmp = parent[tmp]; } return (0); } /* calculate set of positions with v as root which can be active initially */ static void first(int v) { int i; CHR *p; i = name[v]; if (!ISOPERATOR(i)) i = 1; switch (i) { case 1: case RCCL: case RNCCL: case RNULLS: case FINAL: case S1FINAL: case S2FINAL: /* * XCU4: if we are working on an exclusive start state and * the parent of this position is not RXSCON or RSTR this * is not an active position. * * (There is a possibility that RSXCON appreas as the * (parent)* node. Check it by check_me().) */ if ((exclusive[stnum/2]) && ISOPERATOR(name[parent[v]]) && (name[parent[v]] != RXSCON) && (name[parent[v]] != RSTR) && (check_me(v) == 0)) { break; } if (tmpstat[v] == FALSE) { count++; tmpstat[v] = TRUE; } break; case BAR: case RNEWE: first(left[v]); first(right[v]); break; case CARAT: if (stnum % 2 == 1) first(left[v]); break; /* XCU4: add RXSCON */ case RXSCON: case RSCON: i = stnum/2 +1; p = (CHR *) right[v]; while (*p) if (*p++ == i) { first(left[v]); break; } break; case STAR: case QUEST: case PLUS: case RSTR: /* * XCU4: if we are working on an exclusive start state and * the parent of this position is not RXSCON or RSTR this * is not an active position. * * (There is a possibility that RSXCON appreas as the * (parent)* node. Check it by check_me().) */ if ((exclusive[stnum/2]) && ISOPERATOR(name[parent[v]]) && (name[parent[v]] != RXSCON) && (name[parent[v]] != RSTR) && (check_me(v) == 0)) { break; } first(left[v]); break; case RCAT: case DIV: first(left[v]); if (nullstr[left[v]]) first(right[v]); break; #ifdef DEBUG default: warning("bad switch first %d", v); #endif } } void cgoto(void) { int i, j; static int s; int npos, curpos, n; int tryit; CHR tch[MAXNCG]; int tst[MAXNCG]; CHR *q; /* generate initial state, for each start condition */ if (ratfor) { (void) fprintf(fout, "blockdata\n"); (void) fprintf(fout, "common /Lvstop/ vstop\n"); (void) fprintf(fout, "define Svstop %d\n", nstates+1); (void) fprintf(fout, "integer vstop(Svstop)\n"); } else (void) fprintf(fout, "int yyvstop[] = {\n0,\n"); while (stnum < 2 || stnum/2 < sptr) { for (i = 0; i < tptr; i++) tmpstat[i] = 0; count = 0; if (tptr > 0) first(tptr-1); add(state, stnum); #ifdef DEBUG if (debug) { if (stnum > 1) (void) printf("%ws:\n", sname[stnum/2]); pstate(stnum); } #endif stnum++; } stnum--; /* even stnum = might not be at line begin */ /* odd stnum = must be at line begin */ /* even states can occur anywhere, odd states only at line begin */ for (s = 0; s <= stnum; s++) { tryit = FALSE; cpackflg[s] = FALSE; sfall[s] = -1; acompute(s); for (i = 0; i < ncg; i++) symbol[i] = 0; npos = *state[s]; for (i = 1; i <= npos; i++) { curpos = *(state[s]+i); if (!ISOPERATOR(name[curpos])) symbol[name[curpos]] = TRUE; else { switch (name[curpos]) { case RCCL: tryit = TRUE; q = (CHR *)left[curpos]; while (*q) { for (j = 1; j < ncg; j++) if (cindex[j] == *q) symbol[j] = TRUE; q++; } break; case RSTR: symbol[right[curpos]] = TRUE; break; #ifdef DEBUG case RNULLS: case FINAL: case S1FINAL: case S2FINAL: break; default: warning( "bad switch cgoto %d state %d", curpos, s); break; #endif } } } #ifdef DEBUG if (debug) { printf("State %d transitions on char-group {", s); charc = 0; for (i = 1; i < ncg; i++) { if (symbol[i]) { printf("%d,", i); } if (i == ncg-1) printf("}\n"); if (charc > LINESIZE/4) { charc = 0; printf("\n\t"); } } } #endif /* for each char, calculate next state */ n = 0; for (i = 1; i < ncg; i++) { if (symbol[i]) { /* executed for each state, transition pair */ nextstate(s, i); xstate = notin(stnum); if (xstate == -2) warning("bad state %d %o", s, i); else if (xstate == -1) { if (stnum+1 >= nstates) { stnum++; error("Too many states %s", (nstates == NSTATES ? "\nTry using %n num":"")); } add(state, ++stnum); #ifdef DEBUG if (debug) pstate(stnum); #endif tch[n] = i; tst[n++] = stnum; } else { /* xstate >= 0 ==> state exists */ tch[n] = i; tst[n++] = xstate; } } } tch[n] = 0; tst[n] = -1; /* pack transitions into permanent array */ if (n > 0) packtrans(s, tch, tst, n, tryit); else gotof[s] = -1; } (void) (ratfor ? fprintf(fout, "end\n") : fprintf(fout, "0};\n")); } /* * Beware -- 70% of total CPU time is spent in this subroutine - * if you don't believe me - try it yourself ! */ static void nextstate(int s, int c) { int j, *newpos; CHR *temp, *tz; int *pos, i, *f, num, curpos, number; /* state to goto from state s on char c */ num = *state[s]; temp = tmpstat; pos = state[s] + 1; for (i = 0; i < num; i++) { curpos = *pos++; j = name[curpos]; if ((!ISOPERATOR(j) && j == c) || (j == RSTR && c == right[curpos]) || (j == RCCL && member(c, (CHR *) left[curpos]))) { f = foll[curpos]; number = *f; newpos = f+1; for (j = 0; j < number; j++) temp[*newpos++] = 2; } } j = 0; tz = temp + tptr; while (temp < tz) { if (*temp == 2) { j++; *temp++ = 1; } else *temp++ = 0; } count = j; } /* see if tmpstat occurs previously */ static int notin(int n) { int *j, k; CHR *temp; int i; if (count == 0) return (-2); temp = tmpstat; for (i = n; i >= 0; i--) { /* for each state */ j = state[i]; if (count == *j++) { for (k = 0; k < count; k++) if (!temp[*j++]) break; if (k >= count) return (i); } } return (-1); } static void packtrans(int st, CHR *tch, int *tst, int cnt, int tryit) { /* * pack transitions into nchar, nexts * nchar is terminated by '\0', nexts uses cnt, followed by elements * gotof[st] = index into nchr, nexts for state st * sfall[st] = t implies t is fall back state for st * == -1 implies no fall back */ int cmin, cval, tcnt, diff, p, *ast; int i, j, k; CHR *ach; int go[MAXNCG], temp[MAXNCG], index, c; int swork[MAXNCG]; CHR cwork[MAXNCG]; int upper; rcount += (long)cnt; cmin = -1; cval = ncg; ast = tst; ach = tch; /* try to pack transitions using ccl's */ if (!optim) goto nopack; /* skip all compaction */ if (tryit) { /* ccl's used */ for (i = 1; i < ncg; i++) { go[i] = temp[i] = -1; symbol[i] = 1; } for (i = 0; i < cnt; i++) { index = (unsigned char) tch[i]; if ((index >= 0) && (index < NCH)) { go[index] = tst[i]; symbol[index] = 0; } else { (void) fprintf(stderr, "lex`sub2`packtran: tch[%d] out of bounds (%d)\n", i, (int)tch[i]); } } for (i = 0; i < cnt; i++) { c = match[tch[i]]; if (go[c] != tst[i] || c == tch[i]) temp[tch[i]] = tst[i]; } /* fill in error entries */ for (i = 1; i < ncg; i++) if (symbol[i]) temp[i] = -2; /* error trans */ /* count them */ k = 0; for (i = 1; i < ncg; i++) if (temp[i] != -1) k++; if (k < cnt) { /* compress by char */ #ifdef DEBUG if (debug) (void) printf( "use compression %d, %d vs %d\n", st, k, cnt); #endif k = 0; for (i = 1; i < ncg; i++) if (temp[i] != -1) { cwork[k] = i; swork[k++] = (temp[i] == -2 ? -1 : temp[i]); } cwork[k] = 0; #ifdef PC ach = cwork; ast = swork; cnt = k; cpackflg[st] = TRUE; #endif } } /* * get most similar state * reject state with more transitions, * state already represented by a third state, * and state which is compressed by char if ours is not to be */ for (i = 0; i < st; i++) { if (sfall[i] != -1) continue; if (cpackflg[st] == 1) if (!(cpackflg[i] == 1)) continue; p = gotof[i]; if (p == -1) /* no transitions */ continue; tcnt = nexts[p]; if (tcnt > cnt) continue; diff = 0; k = 0; j = 0; upper = p + tcnt; while (ach[j] && p < upper) { while (ach[j] < nchar[p] && ach[j]) { diff++; j++; } if (ach[j] == 0) break; if (ach[j] > nchar[p]) { diff = ncg; break; } /* ach[j] == nchar[p] */ if (ast[j] != nexts[++p] || ast[j] == -1 || (cpackflg[st] && ach[j] != match[ach[j]])) diff++; j++; } while (ach[j]) { diff++; j++; } if (p < upper) diff = ncg; if (diff < cval && diff < tcnt) { cval = diff; cmin = i; if (cval == 0) break; } } /* cmin = state "most like" state st */ #ifdef DEBUG if (debug) (void) printf("select st %d for st %d diff %d\n", cmin, st, cval); #endif #ifdef PS if (cmin != -1) { /* if we can use st cmin */ gotof[st] = nptr; k = 0; sfall[st] = cmin; p = gotof[cmin] + 1; j = 0; while (ach[j]) { /* if cmin has a transition on c, then so will st */ /* st may be "larger" than cmin, however */ while (ach[j] < nchar[p-1] && ach[j]) { k++; nchar[nptr] = ach[j]; nexts[++nptr] = ast[j]; j++; } if (nchar[p-1] == 0) break; if (ach[j] > nchar[p-1]) { warning("bad transition %d %d", st, cmin); goto nopack; } /* ach[j] == nchar[p-1] */ if (ast[j] != nexts[p] || ast[j] == -1 || (cpackflg[st] && ach[j] != match[ach[j]])) { k++; nchar[nptr] = ach[j]; nexts[++nptr] = ast[j]; } p++; j++; } while (ach[j]) { nchar[nptr] = ach[j]; nexts[++nptr] = ast[j++]; k++; } nexts[gotof[st]] = cnt = k; nchar[nptr++] = 0; } else { #endif nopack: /* stick it in */ gotof[st] = nptr; nexts[nptr] = cnt; for (i = 0; i < cnt; i++) { nchar[nptr] = ach[i]; nexts[++nptr] = ast[i]; } nchar[nptr++] = 0; #ifdef PS } #endif if (cnt < 1) { gotof[st] = -1; nptr--; } else if (nptr > ntrans) error( "Too many transitions %s", (ntrans == NTRANS ? "\nTry using %a num" : "")); } #ifdef DEBUG void pstate(int s) { int *p, i, j; (void) printf("State %d:\n", s); p = state[s]; i = *p++; if (i == 0) return; (void) printf("%4d", *p++); for (j = 1; j < i; j++) { (void) printf(", %4d", *p++); if (j%30 == 0) (void) putchar('\n'); } (void) putchar('\n'); } #endif static int member(int d, CHR *t) { int c; CHR *s; c = d; s = t; c = cindex[c]; while (*s) if (*s++ == c) return (1); return (0); } #ifdef DEBUG void stprt(int i) { int p, t; (void) printf("State %d:", i); /* print actions, if any */ t = atable[i]; if (t != -1) (void) printf(" final"); (void) putchar('\n'); if (cpackflg[i] == TRUE) (void) printf("backup char in use\n"); if (sfall[i] != -1) (void) printf("fall back state %d\n", sfall[i]); p = gotof[i]; if (p == -1) return; (void) printf("(%d transitions)\n", nexts[p]); while (nchar[p]) { charc = 0; if (nexts[p+1] >= 0) (void) printf("%d\t", nexts[p+1]); else (void) printf("err\t"); allprint(nchar[p++]); while (nexts[p] == nexts[p+1] && nchar[p]) { if (charc > LINESIZE) { charc = 0; (void) printf("\n\t"); } allprint(nchar[p++]); } (void) putchar('\n'); } (void) putchar('\n'); } #endif /* compute action list = set of poss. actions */ static void acompute(int s) { int *p, i, j; int q, r; int cnt, m; int temp[MAXPOSSTATE], k, neg[MAXPOSSTATE], n; k = 0; n = 0; p = state[s]; cnt = *p++; if (cnt > MAXPOSSTATE) error("Too many positions for one state - acompute"); for (i = 0; i < cnt; i++) { q = *p; if (name[q] == FINAL) temp[k++] = left[q]; else if (name[q] == S1FINAL) { temp[k++] = left[q]; if ((r = left[q]) >= NACTIONS) error( "INTERNAL ERROR:left[%d]==%d>=NACTIONS", q, r); extra[r] = 1; } else if (name[q] == S2FINAL) neg[n++] = left[q]; p++; } atable[s] = -1; if (k < 1 && n < 1) return; #ifdef DEBUG if (debug) (void) printf("final %d actions:", s); #endif /* sort action list */ for (i = 0; i < k; i++) for (j = i+1; j < k; j++) if (temp[j] < temp[i]) { m = temp[j]; temp[j] = temp[i]; temp[i] = m; } /* remove dups */ for (i = 0; i < k-1; i++) if (temp[i] == temp[i+1]) temp[i] = 0; /* copy to permanent quarters */ atable[s] = aptr; #ifdef DEBUG if (!ratfor) (void) fprintf(fout, "/* actions for state %d */", s); #endif (void) putc('\n', fout); for (i = 0; i < k; i++) if (temp[i] != 0) { (void) (ratfor ? fprintf(fout, "data vstop(%d)/%d/\n", aptr, temp[i]) : fprintf(fout, "%d,\n", temp[i])); #ifdef DEBUG if (debug) (void) printf("%d ", temp[i]); #endif aptr++; } for (i = 0; i < n; i++) { /* copy fall back actions - all neg */ ratfor ? (void) fprintf(fout, "data vstop(%d)/%d/\n", aptr, neg[i]) : (void) fprintf(fout, "%d,\n", neg[i]); aptr++; #ifdef DEBUG if (debug) (void) printf("%d ", neg[i]); #endif } #ifdef DEBUG if (debug) (void) putchar('\n'); #endif (void) (ratfor ? fprintf(fout, "data vstop (%d)/0/\n", aptr) : fprintf(fout, "0, \n")); aptr++; } #ifdef DEBUG void pccl(void) { /* print character class sets */ int i, j; (void) printf("char class intersection\n"); for (i = 0; i < ccount; i++) { charc = 0; (void) printf("class %d:\n\t", i); for (j = 1; j < ncg; j++) if (cindex[j] == i) { allprint(j); if (charc > LINESIZE) { (void) printf("\n\t"); charc = 0; } } (void) putchar('\n'); } charc = 0; (void) printf("match:\n"); for (i = 0; i < ncg; i++) { allprint(match[i]); if (charc > LINESIZE) { (void) putchar('\n'); charc = 0; } } (void) putchar('\n'); } #endif void mkmatch(void) { int i; CHR tab[MAXNCG]; for (i = 0; i < ccount; i++) tab[i] = 0; for (i = 1; i < ncg; i++) if (tab[cindex[i]] == 0) tab[cindex[i]] = i; /* tab[i] = principal char for new ccl i */ for (i = 1; i < ncg; i++) match[i] = tab[cindex[i]]; } void layout(void) { /* format and output final program's tables */ int i, j, k; int top, bot, startup, omin; startup = 0; for (i = 0; i < outsize; i++) verify[i] = advance[i] = 0; omin = 0; yytop = 0; for (i = 0; i <= stnum; i++) { /* for each state */ j = gotof[i]; if (j == -1) { stoff[i] = 0; continue; } bot = j; while (nchar[j]) j++; top = j - 1; #if DEBUG if (debug) { (void) printf("State %d: (layout)\n", i); for (j = bot; j <= top; j++) { (void) printf(" %o", nchar[j]); if (j % 10 == 0) (void) putchar('\n'); } (void) putchar('\n'); } #endif while (verify[omin+ZCH]) omin++; startup = omin; #if DEBUG if (debug) (void) printf( "bot,top %d, %d startup begins %d\n", bot, top, startup); #endif if (chset) { do { startup += 1; if (startup > outsize - ZCH) error("output table overflow"); for (j = bot; j <= top; j++) { k = startup+ctable[nchar[j]]; if (verify[k]) break; } } while (j <= top); #if DEBUG if (debug) (void) printf(" startup will be %d\n", startup); #endif /* have found place */ for (j = bot; j <= top; j++) { k = startup + ctable[nchar[j]]; if (ctable[nchar[j]] <= 0) (void) printf( "j %d nchar %d ctable.nch %d\n", j, (int)nchar[j], ctable[nchar[k]]); verify[k] = i + 1; /* state number + 1 */ advance[k] = nexts[j+1]+1; if (yytop < k) yytop = k; } } else { do { startup += 1; if (startup > outsize - ZCH) error("output table overflow"); for (j = bot; j <= top; j++) { k = startup + nchar[j]; if (verify[k]) break; } } while (j <= top); /* have found place */ #if DEBUG if (debug) (void) printf(" startup going to be %d\n", startup); #endif for (j = bot; j <= top; j++) { k = startup + nchar[j]; verify[k] = i+1; /* state number + 1 */ advance[k] = nexts[j+1] + 1; if (yytop < k) yytop = k; } } stoff[i] = startup; } /* stoff[i] = offset into verify, advance for trans for state i */ /* put out yywork */ if (ratfor) { (void) fprintf(fout, "define YYTOPVAL %d\n", yytop); rprint(verify, "verif", yytop+1); rprint(advance, "advan", yytop+1); shiftr(stoff, stnum); rprint(stoff, "stoff", stnum+1); shiftr(sfall, stnum); upone(sfall, stnum+1); rprint(sfall, "fall", stnum+1); bprint(extra, "extra", casecount+1); bprint((char *)match, "match", ncg); shiftr(atable, stnum); rprint(atable, "atable", stnum+1); } (void) fprintf(fout, "# define YYTYPE %s\n", stnum+1 >= NCH ? "int" : "unsigned char"); (void) fprintf(fout, "struct yywork { YYTYPE verify, advance; } yycrank[] = {\n"); for (i = 0; i <= yytop; i += 4) { for (j = 0; j < 4; j++) { k = i+j; if (verify[k]) (void) fprintf(fout, "{ %d,%d },\t", verify[k], advance[k]); else (void) fprintf(fout, "{ 0,0 },\t"); } (void) putc('\n', fout); } (void) fprintf(fout, "{ 0,0 } };\n"); /* put out yysvec */ (void) fprintf(fout, "struct yysvf yysvec[] = {\n"); (void) fprintf(fout, "{ 0,\t0,\t0 },\n"); for (i = 0; i <= stnum; i++) { /* for each state */ if (cpackflg[i]) stoff[i] = -stoff[i]; (void) fprintf(fout, "{ yycrank+%d,\t", stoff[i]); if (sfall[i] != -1) (void) fprintf(fout, "yysvec+%d,\t", sfall[i]+1); /* state + 1 */ else (void) fprintf(fout, "0,\t\t"); if (atable[i] != -1) (void) fprintf(fout, "yyvstop+%d },", atable[i]); else (void) fprintf(fout, "0 },\t"); #ifdef DEBUG (void) fprintf(fout, "\t\t/* state %d */", i); #endif (void) putc('\n', fout); } (void) fprintf(fout, "{ 0,\t0,\t0 } };\n"); /* put out yymatch */ (void) fprintf(fout, "struct yywork *yytop = yycrank+%d;\n", yytop); (void) fprintf(fout, "struct yysvf *yybgin = yysvec+1;\n"); if (optim) { if (handleeuc) { (void) fprintf(fout, "int yymatch[] = {\n"); } else { (void) fprintf(fout, "char yymatch[] = {\n"); } if (chset == 0) { /* no chset, put out in normal order */ for (i = 0; i < ncg; i += 8) { for (j = 0; j < 8; j++) { int fbch; fbch = match[i+j]; (void) fprintf(fout, "%3d, ", fbch); } (void) putc('\n', fout); } } else { int *fbarr; /*LINTED: E_BAD_PTR_CAST_ALIGN*/ fbarr = (int *)myalloc(2*MAXNCG, sizeof (*fbarr)); if (fbarr == 0) error("No space for char table reverse", 0); for (i = 0; i < MAXNCG; i++) fbarr[i] = 0; for (i = 0; i < ncg; i++) fbarr[ctable[i]] = ctable[match[i]]; for (i = 0; i < ncg; i += 8) { for (j = 0; j < 8; j++) (void) fprintf(fout, "0%-3o,", fbarr[i+j]); (void) putc('\n', fout); } free(fbarr); } (void) fprintf(fout, "0};\n"); } /* put out yyextra */ (void) fprintf(fout, "char yyextra[] = {\n"); for (i = 0; i < casecount; i += 8) { for (j = 0; j < 8; j++) (void) fprintf(fout, "%d,", i+j < NACTIONS ? extra[i+j] : 0); (void) putc('\n', fout); } (void) fprintf(fout, "0};\n"); if (handleeuc) { /* Put out yycgidtbl */ (void) fprintf(fout, "#define YYNCGIDTBL %d\n", ncgidtbl); (void) fprintf(fout, "\tunsigned long yycgidtbl[]={"); /* * Use "unsigned long" instead of "lchar" to minimize * the name-space polution for the application program. */ for (i = 0; i < ncgidtbl; ++i) { if (i%8 == 0) (void) fprintf(fout, "\n\t\t"); (void) fprintf(fout, "0x%08x, ", (int)yycgidtbl[i]); } (void) fprintf(fout, "\n\t0};\n"); } } static void rprint(int *a, char *s, int n) { int i; (void) fprintf(fout, "block data\n"); (void) fprintf(fout, "common /L%s/ %s\n", s, s); (void) fprintf(fout, "define S%s %d\n", s, n); (void) fprintf(fout, "integer %s (S%s)\n", s, s); for (i = 1; i <= n; i++) { if (i%8 == 1) (void) fprintf(fout, "data "); (void) fprintf(fout, "%s (%d)/%d/", s, i, a[i]); (void) fprintf(fout, (i%8 && i < n) ? ", " : "\n"); } (void) fprintf(fout, "end\n"); } static void shiftr(int *a, int n) { int i; for (i = n; i >= 0; i--) a[i+1] = a[i]; } static void upone(int *a, int n) { int i; for (i = 0; i <= n; i++) a[i]++; } static void bprint(char *a, char *s, int n) { int i, j, k; (void) fprintf(fout, "block data\n"); (void) fprintf(fout, "common /L%s/ %s\n", s, s); (void) fprintf(fout, "define S%s %d\n", s, n); (void) fprintf(fout, "integer %s (S%s)\n", s, s); for (i = 1; i < n; i += 8) { (void) fprintf(fout, "data %s (%d)/%d/", s, i, a[i]); for (j = 1; j < 8; j++) { k = i+j; if (k < n) (void) fprintf(fout, ", %s (%d)/%d/", s, k, a[k]); } (void) putc('\n', fout); } (void) fprintf(fout, "end\n"); } #ifdef PP static void padd(int **array, int n) { int i, *j, k; array[n] = nxtpos; if (count == 0) { *nxtpos++ = 0; return; } for (i = tptr-1; i >= 0; i--) { j = array[i]; if (j && *j++ == count) { for (k = 0; k < count; k++) if (!tmpstat[*j++]) break; if (k >= count) { array[n] = array[i]; return; } } } add(array, n); } #endif /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License (the "License"). * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * sub3.c ... ALE enhancement. * Since a typical Asian language has a huge character set, it is not * ideal to index an array by a character code itself, which requires * as large as 2**16 entries per array. * To get arround this problem, we identify a set of characters that * causes the same transition on all states and call it character group. * Every character in a same character group has a unique number called * character group id. A function yycgid(c) maps the character c (in process * code) to the id. This mapping is determined by analyzing all regular * expressions in the lex program. * */ #include #include #include #include "ldefs.h" /* * "lchar" stands for linearized character. It is a variant of * process code. AT&T's 16-bit process code has a drawback in which * for three three process code C, D and E where C <= D <= E, * codeset(C)==codeset(E) does not mean codeset(D)==codeset(C). * In other words, four codesets alternates as the magnitude * of character increases. * The lchar representation holds this property: * If three lchar C', D' and E' have the relationship C' < D' < E' and * codeset(C') == codeset(E') then D' is guaranteed to belong to * the same codeset as C' and E'. * lchar is implemented as 32 bit entities and the function linearize() * that maps a wchar_t to lchar is defined below. There is no * reverse function for it though. * The 32-bit process code by AT&T, used only for Taiwanese version at the * time of wrting, has no such problem and we use it as it is. */ lchar yycgidtbl[MAXNCG] = { 0, /* For ease of computation of the id. */ '\n', /* Newline is always special because '.' exclude it. */ 0x000000ff, /* The upper limit of codeset 0. */ 0x20ffffff, /* The upper limit of codeset 2. */ 0x40ffffff /* The upper limit of codeset 3. */ /* 0x60ffffff The upper limit of codeset 1. */ /* Above assumes the number of significant bits of wchar_t is <= 24. */ }; int ncgidtbl = 5; /* # elements in yycgidtbl. */ int ncg; /* Should set to ncgidtbl*2; this is the largest value yycgid() */ /* returns plus 1. */ static void setsymbol(int i); /* * For given 16-bit wchar_t (See NOTE), lchar is computed as illustrated below: * * wc: axxxxxxbyyyyyyy * * returns: 0ab0000000000000axxxxxxxbyyyyyyy * * linearize() doesn't do any if compiled with 32-bit wchar_t, use of * which is flagged with LONG_WCHAR_T macro. * NOTE: * The implementation is highly depends on the process code representation. * This function should be modified when 32-bit process code is used. * There is no need to keep 'a' and 'b' bits in the lower half of lchar. * You can actually omit these and squeeze the xxxxxx part one bit right. * We don't do that here just in sake of speed. */ lchar linearize(wchar_t wc) { #ifdef LONG_WCHAR_T return ((lchar)wc); /* Don't do anything. */ #else lchar prefix; switch (wc&0x8080) { case 0x0000: prefix = 0x00000000; break; case 0x0080: prefix = 0x20000000; break; case 0x8000: prefix = 0x40000000; break; case 0x8080: prefix = 0x60000000; break; } return (prefix|wc); #endif } /* compare liniear characters pointed to by pc1 and pc2 */ int cmplc(const void *arg1, const void *arg2) { lchar *pc1 = (lchar *)arg1; lchar *pc2 = (lchar *)arg2; if (*pc1 > *pc2) return (1); else if (*pc1 == *pc2) return (0); else return (-1); } void remch(wchar_t c) { lchar lc = linearize(c); size_t local_ncgidtbl; /* * User-friendliness consideration: * Make sure no EUC chars are used in reg. exp. */ if (!handleeuc) { if (!isascii(c)) { if (iswprint(c)) warning( "Non-ASCII character '%wc' in pattern; use -w or -e lex option.", c); else warning( "Non-ASCII character of value %#x in pattern; use -w or -e lex option.", c); } /* In any case, we don't need to construct ncgidtbl[]. */ return; } /* * lsearch wants ncgidtbl to be size_t, but it is int. Hence, * the use of local_ncgidtbl to satisfy the calling interface. */ local_ncgidtbl = ncgidtbl; (void) lsearch(&lc, yycgidtbl, &local_ncgidtbl, sizeof (lchar), cmplc); ncgidtbl = (int)local_ncgidtbl; } void sortcgidtbl(void) { if (!handleeuc) return; qsort(yycgidtbl, ncgidtbl, sizeof (lchar), cmplc); } /* * int yycgid(wchar_t c) * Takes c and returns its character group id, determind by the * following algorithm. The program also uses the binary search * algorithm, generalized from Knuth (6.2.1) Algorithm B. * * This function computes the "character group id" based on * a table yycgidtbl of which each lchar entry is pre-sorted * in ascending sequence The number of valid entries is given * by YYNCGIDTBL. There is no duplicate entries in yycgidtbl. * const int YYNCGIDTBL; * lchar yycgidtbl[YYNCGIDTBL]; * * yycgidtbl[0] is guaranteed to have zero. * * For given c, yycgid(c) returns: * 2*i iff yycgidtbl[i] == lc * 2*i+1 iff yycgidtbl[i] < lc < yycgidtbl[i+1] * YYNCGIDTBL*2-1 * iff yycgidtbl[YYNCGIDTBL-1] < lc * where lc=linearize(c). * * Some interesting properties.: * 1. For any c, 0 <= yycgid(c) <= 2*YYNCGIDTBL-1 * 2. yycgid(c) == 0 iff c == 0. * 3. For any wchar_t c and d, if linearize(c) < linearize(d) then * yycgid(c) <= yycgid(d). * 4. For any wchar_t c and d, if yycgid(c) < yycgid(d) then * linearize(c) < linearize(d). */ #define YYNCGIDTBL ncgidtbl int yycgid(wchar_t c) { int first = 0; int last = YYNCGIDTBL - 1; lchar lc; /* * In ASCII compat. mode, each character forms a "group" and the * group-id is itself... */ if (!handleeuc) return (c); lc = linearize(c); /* An exceptional case: yycgidtbl[YYNCGIDTBL-1] < lc */ if (yycgidtbl[YYNCGIDTBL - 1] < lc) return (YYNCGIDTBL*2 - 1); while (last >= 0) { int i = (first+last)/2; if (lc == yycgidtbl[i]) return (2*i); /* lc exactly matches an element. */ else if (yycgidtbl[i] < lc) { if (lc < yycgidtbl[i+1]) { /* lc is in between two elements */ return (2*i+1); } else first = i + 1; } else last = i - 1; } error( "system error in yycgid():binary search failed for c=0x%04x\n", c); return (0); } /* * repbycgid --- replaces each character in the parsing tree by its * character group id. This, however, should be called even in * the ASCII compat. mode to process DOT nodes and to call cclinter() * for the DOT and CCL nodes. */ void repbycgid(void) { int i, c; for (i = 0; i < tptr; ++i) { c = name[i]; if (!ISOPERATOR(c)) { /* If not an operator, it must be a char. */ name[i] = yycgid((wchar_t)c); /* So replace it. */ #ifdef DEBUG if (debug) { printf("name[%d]:'%c'->%d;\n", i, c, name[i]); } #endif } else if (c == RSTR) { c = right[i]; right[i] = yycgid((wchar_t)c); #ifdef DEBUG if (debug) { printf( "name[%d].right:'%c'->%d;\n", i, c, right[i]); } #endif } else if ((c == RCCL) || (c == RNCCL)) { CHR cc, *s; int j; CHR ccltoken[CCLSIZE]; CHR *ccp; int m; /* * This node represetns a character class RE [ccccc] * s points to the string of characters that forms * the class and/or a special prefix notation * XY which corresponds to the RE X-Y, * characters in the range of X and Y. Here, * X <= Y is guranteed. * We transform these characters into a string * of sorted character group ids. * * There is another mechanism of packing tables * that is inherited from the ASCII lex. Call of * cclinter() is required for this packing. * This used to be done as yylex() reads the lex * rules but we have to do this here because the * transition table is made to work on the char-group * ids and the mapping cannot be determined until * the entire file is read. */ #ifdef DEBUG if (debug) { printf("name[%d]:R[N]CCL of \"", i); strpt(left[i]); printf(" -> {"); } #endif /* Prepare symbol[] for cclinter(). */ for (j = 0; j < ncg; ++j) symbol[j] = FALSE; s = (CHR *) left[i]; while ((cc = *s++) != 0) { if (cc == RANGE) { int low, high, i; /* * Special form: XY * This means the range X-Y. * We mark all symbols[] * elements for yycgid(X) thru * yycgid(Y), inclusively. */ low = yycgid(*s++); high = yycgid(*s++); for (i = low; i <= high; ++i) setsymbol(i); } else { setsymbol(yycgid(cc)); } } /* Now make a transformed string of cgids. */ s = ccptr; m = 0; for (j = 0; j < ncg; ++j) if (symbol[j]) { ccltoken[m++] = (CHR)j; #ifdef DEBUG if (debug) printf("%d, ", j); #endif } #ifdef DEBUG if (debug) printf("}\n"); #endif ccltoken[m] = 0; ccp = ccl; while (ccp < ccptr && scomp(ccltoken, ccp) != 0) ccp++; if (ccp < ccptr) { /* character class found in ccl */ left[i] = (int)ccp; } else { /* not in ccl, add it */ left[i] = (int)ccptr; scopy(ccltoken, ccptr); ccptr += slength(ccltoken) + 1; if (ccptr > ccl + CCLSIZE) error( "Too many large character classes"); } cclinter(c == RCCL); } else if (c == DOT) { if (psave == 0) { /* First DOT node. */ int j, nlid; /* * Make symbol[k]=TRUE for all k * except k == yycgid('\n'). */ nlid = yycgid('\n'); psave = ccptr; for (j = 1; j < ncg; ++j) { if (j == nlid) { symbol[j] = FALSE; } else { symbol[j] = TRUE; *ccptr++ = (CHR) j; } } *ccptr++ = 0; if (ccptr > ccl + CCLSIZE) error( "Too many large character classes"); } /* Mimic mn1(RCCL,psave)... */ name[i] = RCCL; left[i] = (int)psave; cclinter(1); } } #ifdef DEBUG if (debug) { printf("treedump after repbycgid().\n"); treedump(); } #endif } static void setsymbol(int i) { if (i > (int)sizeof (symbol)) error("setsymbol: (SYSERR) %d out of range", i); symbol[i] = TRUE; } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ #include #include #include #include #include #include #pragma weak yyprevious extern int yyprevious; #ifndef JLSLEX #define CHR char #pragma weak yyinput #pragma weak yyleng #pragma weak yyunput #pragma weak yytext extern CHR yytext[]; #define YYTEXT yytext #define YYLENG yyleng #define YYINPUT yyinput #define YYUNPUT yyunput #define YYOUTPUT yyoutput #endif #ifdef WOPTION #define CHR wchar_t #pragma weak yyinput #pragma weak yyleng #pragma weak yyunput #pragma weak yytext extern CHR yytext[]; #define YYTEXT yytext #define YYLENG yyleng #define YYINPUT yyinput #define YYUNPUT yyunput #define YYOUTPUT yyoutput #endif #ifdef EOPTION #define CHR wchar_t #pragma weak yyleng extern int yyleng; #pragma weak yytext extern CHR yytext[]; #pragma weak yywinput #pragma weak yywleng #pragma weak yywunput #pragma weak yywtext extern CHR yywtext[]; #define YYTEXT yywtext #define YYLENG yywleng #define YYINPUT yywinput #define YYUNPUT yywunput #define YYOUTPUT yywoutput #endif extern int YYLENG; extern void YYUNPUT(int); /* XCU4: type of yyless() changes to int */ int yyless(int x) { CHR *lastch, *ptr; lastch = YYTEXT+YYLENG; if (x >= 0 && x <= YYLENG) ptr = x + YYTEXT; else { #ifdef _LP64 static int seen = 0; if (!seen) { (void) write(2, "warning: yyless pointer arg truncated\n", 39); seen = 1; } #endif /* _LP64 */ /* * The cast on the next line papers over an unconscionable nonportable * glitch to allow the caller to hand the function a pointer instead of * an integer and hope that it gets figured out properly. But it's * that way on all systems. */ ptr = (CHR *)(intptr_t)x; } while (lastch > ptr) YYUNPUT(*--lastch); *lastch = 0; if (ptr > YYTEXT) yyprevious = *--lastch; YYLENG = ptr-YYTEXT; #ifdef EOPTION yyleng = wcstombs((char *)yytext, YYTEXT, YYLENG*MB_LEN_MAX); #endif return (0); } /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* Copyright (c) 1989 AT&T */ /* All Rights Reserved */ int yywrap(void) { return (1); }