main.c revision 672986541be54a7a471bb088e60780c37e371d7e
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * CDDL HEADER START
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * The contents of this file are subject to the terms of the
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * Common Development and Distribution License (the "License").
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * You may not use this file except in compliance with the License.
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * See the License for the specific language governing permissions
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * and limitations under the License.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * When distributing Covered Code, include this CDDL HEADER in each
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
dafcb997e390efa4423883dafd100c975c4095d6Mark Andrews * If applicable, add the following below this CDDL HEADER, with the
1633838b8255282d10af15c5c84cee5a51466712Bob Halley * fields enclosed by brackets "[]" replaced with your own identifying
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * information: Portions Copyright [yyyy] [name of copyright owner]
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence * CDDL HEADER END
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * Use is subject to license terms.
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley/* Copyright (c) 1988 AT&T */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley/* All Rights Reserved */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley/* Copyright 1976, Bell Telephone Laboratories, Inc. */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley#pragma ident "%Z%%M% %I% %E% SMI"
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halleystatic wchar_t L_INITIAL[] = {'I', 'N', 'I', 'T', 'I', 'A', 'L', 0};
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halleystatic void get1core(void);
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halleystatic void free1core(void);
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halleystatic void get2core(void);
005df5aba5181dc57b0e84eae72929f009b6b8fdBob Halleystatic void free2core(void);
005df5aba5181dc57b0e84eae72929f009b6b8fdBob Halleystatic void get3core(void);
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halleystatic void free3core(void);
441a57f959ae5e08b3008e067898d11d5ab71e0bMichael Graff while ((c = getopt(argc, argv, "dyctvnewVQ:Y:")) != EOF) {
441a57f959ae5e08b3008e067898d11d5ab71e0bMichael Graff while ((c = getopt(argc, argv, "ctvnewVQ:Y:")) != EOF) {
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley (const char *)SGU_PKG,
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley (const char *)SGU_REL);
cada82f4ffbbccf373e4483e67082e0d916d10c4Bob Halley "lex: -Q should be followed by [y/n]");
35a8d16d614cda6fec64c989c1a5ee0f3f16fb08Michael Graff "Usage: lex [-ewctvnVY] [-Q(y/n)] [file]\n");
3df43dad430973e273bc55b304c6d5965390db06Michael Graff "You may not specify both -w and -e simultaneously.");
07a9b8b58802575e1ec29a3c8b00e5fae1a94008Michael Graff /* XCU4: recognize "-" file operand for stdin */
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence "Can't open input file -- %s", argv[optind]);
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence /* may be gotten: def, subs, sname, schar, ccl, dchar */
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence /* may be gotten: name, left, right, nullstr, parent */
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence /* XCU4: %x exclusive start */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * Set ZCH and ncg to their default values
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * as they may be needed to handle %t directive.
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley ZCH = ncg = NCH; /* ncg behaves as constant in this mode. */
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff /* may be disposed of: def, subs, dchar */
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff "Too complex rules -- requires too many char groups.");
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff repbycgid(); /* Call this even in ASCII compat. mode. */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * maybe get:
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * tmpstat, foll, positions, gotof, nexts,
441a57f959ae5e08b3008e067898d11d5ab71e0bMichael Graff * nchar, state, atable, sfall, cpackflg
84d79ecd505cc880d01a73a2bf47541eaa53fcbcMichael Graff (void) printf("Print %d states:\n", stnum + 1);
4556681e191b7c1654639895ce719d98f2822ee2Michael Graff for (i = 0; i <= stnum; i++)
441a57f959ae5e08b3008e067898d11d5ab71e0bMichael Graff * may be disposed of:
441a57f959ae5e08b3008e067898d11d5ab71e0bMichael Graff * positions, tmpstat, foll, state, name,
441a57f959ae5e08b3008e067898d11d5ab71e0bMichael Graff * left, right, parent, ccl, schar, sname
441a57f959ae5e08b3008e067898d11d5ab71e0bMichael Graff * maybe get: verify, advance, stoff
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * may be disposed of:
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley * verify, advance, stoff, nexts, nchar,
87cafc5e70f79f2586d067fbdd64f61bbab069d2David Lawrence * gotof, atable, ccpackflg, sfall
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley error("Ratfor is not supported by -w or -e option.");
35a8d16d614cda6fec64c989c1a5ee0f3f16fb08Michael Graff return (0); /* success return code */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley ccptr = ccl = (CHR *)myalloc(CCLSIZE, sizeof (*ccl));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley pcptr = pchar = (CHR *)myalloc(pchlen, sizeof (*pchar));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley dp = dchar = (CHR *)myalloc(DEFCHAR, sizeof (*dchar));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley sname = (CHR **)myalloc(STARTSIZE, sizeof (*sname));
35a8d16d614cda6fec64c989c1a5ee0f3f16fb08Michael Graff /* XCU4: exclusive start array */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley exclusive = (int *)myalloc(STARTSIZE, sizeof (*exclusive));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley sp = schar = (CHR *)myalloc(STARTCHAR, sizeof (*schar));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley gotof = (int *)myalloc(nstates, sizeof (*gotof));
35a8d16d614cda6fec64c989c1a5ee0f3f16fb08Michael Graff state = (int **)myalloc(nstates, sizeof (*state));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley atable = (int *)myalloc(nstates, sizeof (*atable));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley sfall = (int *)myalloc(nstates, sizeof (*sfall));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley cpackflg = (Boolean *)myalloc(nstates, sizeof (*cpackflg));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley tmpstat = (CHR *)myalloc(tptr+1, sizeof (*tmpstat));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley nxtpos = positions = (int *)myalloc(maxpos, sizeof (*positions));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley if (tmpstat == 0 || foll == 0 || positions == 0 ||
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley state == 0 || atable == 0 || sfall == 0 || cpackflg == 0)
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley for (i = 0; i <= tptr; i++)
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley /* XCU4: exclusive start array */
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley verify = (int *)myalloc(outsize, sizeof (*verify));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley advance = (int *)myalloc(outsize, sizeof (*advance));
928da6e9e3f2e58666a59ba53d87f3e82486734eBob Halley stoff = (int *)myalloc(stnum+2, sizeof (*stoff));
cada82f4ffbbccf373e4483e67082e0d916d10c4Bob Halley "\"%s\":line %d: Error: %s\n", sargv[optind], yyline, s);