/*
* 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
* 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 */
#pragma ident "%Z%%M% %I% %E% SMI"
#include "dextern.h"
static void go2gen(int);
static void precftn(int, int, int);
static void wract(int);
static void wrstate(int);
static void wrmbchars(void);
/* important local variables */
int *defact;
extern int *toklev;
extern int cwp;
/* print the output for the states */
void
output()
{
int i, k, c;
register WSET *u, *v;
closure(i);
/* output actions */
nolook = 1;
c = *(u->pitem);
WSLOOP(u, v) {
if (c == *(v->pitem))
(LOOKSETS *)0);
}
} else if (c > NTBASE &&
}
}
if (i == 1)
/* now, we have the shifts; look at the reductions */
lastred = 0;
c = *(u->pitem);
if (c <= 0) { /* reduction */
lastred = -c;
TLOOP(k) {
if (temp1[k] == 0)
temp1[k] = c;
else if (temp1[k] < 0) {
/*
* conflict
*/
/* BEGIN CSTYLED */
" (red'ns %d and %d ) on %ws"),
i, -temp1[k],
++zzrrconf;
/* END CSTYLED */
} else
/*
* potentia
* conflict.
*/
}
}
}
}
wract(i);
}
if (nmbchars > 0) {
wrmbchars();
}
}
static int pkdebug = 0;
int
apack(p, n)
int *p;
int n;
{
/* pack state i from temp1 into amem */
int off;
int *q, *rr;
int diff;
/*
* we don't need to worry about checking because we
* we will only look up entries known to be there...
*/
/* eliminate leading and trailing 0's */
q = p + n;
/* NULL */;
if (pp > q)
return (0); /* no actions */
p = pp;
/* now, find a place for the elements from p to q, inclusive */
/* for( rr=amem; rr<=r; ++rr,++off ){ */ /* try rr */
if (*pp) {
}
goto nextk;
}
}
/* we have found an acceptable k */
if (*pp) {
}
}
}
}
}
return (off);
nextk:;
}
/* error("no space in action table" ); */
/* NOTREACHED */
}
void
go2out()
{
/* output the gotos for the nontermninals */
for (i = 1; i <= nnonter; ++i) {
go2gen(i);
/* find the best one to make default */
best = -1;
times = 0;
for (j = 0; j < nstate; ++j) { /* is j the most frequent */
if (tystate[j] == 0)
continue;
continue;
/* is tystate[j] the most frequent */
count = 0;
for (k = j; k < nstate; ++k)
++count;
}
}
/* best is now the default entry */
for (j = 0; j < nstate; ++j) {
zzgoent += 1;
}
}
/* now, the default */
zzgoent += 1;
}
}
static int g2debug = 0;
static void go2gen(int c)
{
/* output the gotos for nonterminal c */
ITEM *p, *q;
/* first, find nonterminals with gotos on c */
temp1[c] = 1;
work = 1;
while (work) {
work = 0;
PLOOP(0, i) {
/* cc is a nonterminal */
/*
* cc has a goto on c
* thus, the left side of
* production i does too.
*/
work = 1;
}
}
}
}
}
/* now, we have temp1[c] = 1 if a goto on c in closure of cc */
}
/* now, go through and put gotos into tystate */
SLOOP(i) {
ITMLOOP(i, p, q) {
/* goto on c is possible */
break;
}
}
}
}
}
static void
precftn(int r, int t, int s)
{
/*
* r is a rule number, t a token number
* the conflict is in state s
* temp1[t] is changed to reflect the action
*/
/* conflict */
" (shift %d, red'n %d) on %ws"),
++zzsrconf;
return;
}
else
switch (action) {
case BASC: /* error action */
return;
case LASC: /* reduce */
temp1[t] = -r;
return;
}
}
static void
wract(int i)
{
/* output state i */
/* temp1 has the actions, lastred the default */
int flag;
/* find the best choice for lastred */
lastred = 0;
ntimes = 0;
TLOOP(j) {
if (temp1[j] >= 0)
continue;
continue;
/* count the number of appearances of temp1[j] */
count = 0;
TLOOP(p) {
++count;
}
}
}
/*
* for error recovery, arrange that, if there is a shift on the
* error recovery token, `error', that the default be the error action
*/
if (temp1[2] > 0)
lastred = 0;
/* clear out entries in temp1 which equal lastred */
TLOOP(p) {
temp1[p] = 0;
}
wrstate(i);
flag = 0;
if (p1 < 0) {
goto exc;
} else if (p1 == ACCEPTCODE) {
p1 = -1;
goto exc;
p1 = 0;
goto exc;
exc:
if (flag++ == 0)
++zzexcp;
} else {
++zzacent;
}
}
}
if (flag) {
defact[i] = -2;
}
}
static void
wrstate(int i)
{
/* writes state i */
register WSET *u;
return;
}
if (tystate[i] == MUSTLOOKAHEAD) {
/* print out empty productions in closure */
if (*(u->pitem) < 0)
}
}
/* check for state equal to another */
if (j1 > 0) { /* shift, error, or accept */
if (j1 == ACCEPTCODE)
else
}
else
}
/* output the final production */
if (lastred)
else
/* now, output nonterminal actions */
WSFMT("\t%ws goto %d\n"),
}
}
static void
{
/* output a definition of s to the value n */
}
void
warray(s, v, n)
wchar_t *s;
int *v, n;
{
int i;
for (i = 0; i < n; ) {
if (i % 10 == 0)
if (++i == n)
else
}
}
void
hideprod()
{
/*
* in order to free up the mem and amem arrays for the optimizer,
* and still be able to output yyr1, etc., after the sizes of
* the action array is known, we hide the nonterminals
* derived by productions in levprd.
*/
int i, j;
j = 0;
levprd[0] = 0;
PLOOP(1, i) {
++j;
WSFMT("Rule not reduced: %ws\n"),
}
}
}
if (j)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
*/
gettext("%d rules never reduced\n"),
j);
}
static int
cmpmbchars(p, q)
MBCLIT *p, *q;
{
/* Compare two MBLITs. */
}
static void
{
int i;
(int (*)(const void *, const void *))cmpmbchars);
"static struct{\n\twchar_t character;"
"\n\tint tvalue;\n}yymbchars[YYNMBCHARS]={\n");
for (i = 0; i < nmbchars; ++i) {
if (i < nmbchars - 1) {
/* Not the last. */
}
}
}