/*
* 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"
#include "sgs.h"
#include <stdio.h>
#define ENDFILE 0
/* communication variables between various I/O routines */
static void finact(void);
static void defout(void);
static void cpyunion(void);
static void cpycode(void);
static void cpyact(int);
static void lrprnt(void);
static void beg_debug(void);
static void end_toks(void);
static void end_debug(void);
static void exp_tokname(void);
static void exp_prod(void);
static void exp_ntok(void);
static void exp_nonterm(void);
static int gettok(void);
static int skipcom(void);
static int findchtok(int);
static void put_prefix_define(char *);
/* storage of names */
/*
* initial block to place token and
* nonterminal names are stored
* points to initial block - more space
* is allocated as needed.
*/
/* place where next name is to be put in */
/* number of defined symbols output */
/* storage of types */
/* symbol tables for tokens and nonterminals */
int ntokens = 0;
int *toklev;
/* assigned token type values */
static int extval = 0;
/* input and output file descriptors */
/* output string */
/* storage for grammar rules */
int *mem;
int *tracemem;
extern int *optimmem;
int **prdptr;
int *levprd;
/* flag for generating the # line's default is yes */
int act_lines = 0;
/* flag for whether to include runtime debugging */
static int gen_testing = 0;
/* flag for version stamping--default turned off */
void
int argc;
char *argv[];
/* ty is the sequencial number of token name in tokset */
int c;
int *p;
char *cp;
unsigned int options = 0;
i = 1;
switch (c) {
case 'v':
break;
case 'V':
(const char *)SGU_PKG,
(const char *)SGU_REL);
break;
case 'Q':
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate -Q and [y/n].
*/
"yacc: -Q should be followed by [y/n]"));
break;
case 'd':
break;
case 'l':
gen_lines = 0; /* don't gen #lines */
break;
case 't':
break;
case 'Y':
sizeof ("/yaccpar") + 1);
break;
case 'P':
break;
case 'p':
sym_prefix = optarg;
else
sym_prefix = "";
break;
case 'b':
break;
case '?':
default:
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* This is a usage message. The translate should be
* consistent with man page translation.
*/
"Usage: yacc [-vVdltY] [-Q(y/n)] [-b file_prefix] [-p sym_prefix]"
" [-P parser] file\n"));
exit(1);
}
/*
* Open y.output if -v is specified
*/
"cannot open y.output"));
}
/*
* Open y.tab.h if -d is specified
*/
"cannot open y.tab.h"));
}
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate yacc.debug.
*/
"cannot open yacc.debug"));
/*
* Open y.tab.c
*/
"cannot open %s"), fname);
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* The message means: "Could not open a temporary file."
*/
"cannot open temp file"));
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"cannot open input file"));
lineno = 1;
(void) defin(0, L"$end");
extval = 0400;
(void) defin(0, L"error");
lev = 0;
ty = 0;
i = 0;
beg_debug(); /* initialize fdebug file */
/*
* sorry -- no yacc parser here.....
* we must bootstrap somehow...
*/
t = gettok();
if (*v_stmp == 'y')
int tok_in_line;
switch (t) {
case L';':
t = gettok();
break;
case START:
if ((t = gettok()) != IDENTIFIER) {
error("bad %%start construction");
}
t = gettok();
continue;
case TYPEDEF:
tok_in_line = 0;
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate %%type.
*/
"bad syntax in %%type"));
for (;;) {
t = gettok();
switch (t) {
case IDENTIFIER:
/*
* The following lines are idented to left.
*/
tok_in_line = 1;
if (j != 0 && j != ty) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"type redeclaration of token %ws"),
}
else
} else {
if (j != 0 && j != ty) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Check how nonterminal is translated in translated
* yacc man page or yacc user's document.
*/
"type redeclaration of nonterminal %ws"),
}
else
}
/* FALLTHRU */
/*
* End Indentation
*/
case L',':
continue;
case L';':
t = gettok();
break;
default:
break;
}
if (!tok_in_line)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"missing tokens or illegal tokens"));
break;
}
continue;
case UNION:
/* copy the union declaration to the output */
cpyunion();
defunion = 1;
t = gettok();
continue;
case LEFT:
case BINARY:
case RIGHT:
i++;
/* FALLTHRU */
case TERM:
tok_in_line = 0;
/* nonzero means new prec. and assoc. */
ty = 0;
/* get identifiers so defined */
t = gettok();
if (t == TYPENAME) { /* there is a type defined */
t = gettok();
}
for (;;) {
switch (t) {
case L',':
t = gettok();
continue;
case L';':
break;
case IDENTIFIER:
tok_in_line = 1;
if (j > NTBASE) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"%ws is not a token."),
tokname);
}
if (lev & ~04) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"redeclaration of precedence of %ws"),
tokname);
} else {
"redeclaration of precedence of %ws."),
tokname);
}
if (ty) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"redeclaration of type of %ws"),
tokname);
}
if (j < ndefout && j > 2) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"type number of %ws should be defined earlier"),
}
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"token numbers must be less than %d"),
-YYFLAG1);
}
t = gettok();
}
continue;
}
if (!tok_in_line)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"missing tokens or illegal tokens"));
break;
}
continue;
case LCURLY:
defout();
cpycode();
t = gettok();
continue;
default:
error("syntax error");
}
}
if (t == ENDFILE) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate %%%%.
*/
error("unexpected EOF before %%%%");
}
/* t is MARK */
defout();
end_toks(); /* all tokens dumped - get ready for reductions */
if (sym_prefix[0] != '\0')
"\n#if defined(__cplusplus) || defined(__STDC__)\n");
"\n#if defined(__cplusplus) && defined(__EXTERN_C__)\n");
"#if defined(__cplusplus) && defined(__EXTERN_C__)\n");
"#ifndef YYSTYPE\n#define YYSTYPE int\n#endif\n");
"#ifndef YYMAXDEPTH\n#define YYMAXDEPTH 150\n#endif\n");
/* added production */
/* if start is 0, we will overwrite with the lhs of the first rule */
*mem++ = 1;
*mem++ = 0;
cpycode();
if (t != C_IDENTIFIER)
error("bad syntax on first rule");
if (!start)
/* read rules */
/* process a rule */
if (t == L'|') {
exp_mem(1);
} else if (t == C_IDENTIFIER) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Check how nonterminal is translated.
*/
"illegal nonterminal in grammar rule"));
exp_mem(1);
} else
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"illegal rule: missing semicolon or | ?"));
/* read rule body */
t = gettok();
while (t == IDENTIFIER) {
exp_mem(1);
t = gettok();
}
if (t == PREC) {
if (gettok() != IDENTIFIER)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate %%prec.
*/
"illegal %%prec syntax"));
if (j >= NTBASE)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate %%prec.
*/
"nonterminal %ws illegal after %%prec"),
t = gettok();
}
if (t == L'=') {
if ((t = gettok()) == IDENTIFIER) {
/* action within rule... */
lrprnt(); /* dump lhs, rhs */
/*
* make it nonterminal
*/
/*
* the current rule will become rule
* number nprod+1 move the contents down,
* and make room for the null
*/
exp_mem(1);
p[2] = *p;
mem += 2;
/* enter null production for action */
*p++ = j;
*p++ = -nprod;
/* update the production information */
exp_prod();
/*
* make the action appear in
* the original rule
*/
*mem++ = j;
exp_mem(1);
/* get some more of the rule */
goto more_rule;
}
}
while (t == L';')
t = gettok();
exp_mem(1);
/* check that default action is reasonable */
/* no explicit action, LHS has value */
int tempty;
if (tempty < 0)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* LHS means Left Hand Side. It does not need to be translated.
*/
"must return a value, since LHS has a type"));
else
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Check how action is transltated in yacc man page or documents.
*/
"default action causes potential type clash"));
}
}
exp_prod();
}
/* end of all rules */
end_debug(); /* finish fdebug file's input */
finact();
if (t == MARK) {
if (gen_lines)
}
}
static void
finact()
{
/* finish action routine */
}
static wchar_t *
cstash(s)
register wchar_t *s;
{
static int used = 0;
static int used_save = 0;
/*
* 2/29/88 -
* Don't need to expand the table, just allocate new space.
*/
if (!used)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*
* You may just translate this as:
* 'Could not allocate internally used memory.'
*/
"cannot expand string dump"));
used = 0;
}
do {
*cnamp++ = *s;
} while (*s++);
return (temp);
}
static int
{
/* define s to be a terminal if t=0 or a nonterminal if t=1 */
int val;
if (t) {
exp_nonterm();
}
/* must be a token */
exp_ntok();
/* establish value for token */
if (s[0] == L' ' && s[2] == 0) { /* single character literal */
} else if (s[0] == L' ' && s[1] == L'\\') { /* escape sequence */
if (s[3] == 0) { /* single character escape sequence */
switch (s[2]) {
/* character which is escaped */
case L'a':
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to warning() function.
* Do not trasnlate ANSI C, \\a.
*/
"\\a is ANSI C \"alert\" character"));
#if __STDC__ - 1 == 0
val = L'\a';
break;
#else
val = L'\007';
break;
#endif
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"invalid escape"));
}
} else if (s[2] <= L'7' && s[2] >= L'0') { /* \nnn sequence */
int i = 3;
while (iswdigit(s[i]) && i <= 4) {
if (s[i] >= L'0' && s[i] <= L'7')
else
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"illegal octal number"));
i++;
}
if (s[i] != 0)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate \\nnn.
*/
"illegal \\nnn construction"));
if (val > 255)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate
* \\nnn, \\xnnnnnnnn.
*/
"\\nnn exceed \\377; use \\xnnnnnnnn for wchar_t value of multibyte char");
if (val == 0 && i >= 4)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate \\000.
*/
"'\\000' is illegal"));
} else if (s[2] == L'x') { /* hexadecimal \xnnn sequence */
int i = 3;
val = 0;
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to warning() function.
* Do not translate \\x, ANSI C.
*/
"\\x is ANSI C hex escape"));
if (iswxdigit(s[i]))
while (iswxdigit(s[i])) {
int tmpval;
if (iswdigit(s[i]))
tmpval = s[i] - L'0';
else if (s[i] >= L'a')
else
i++;
}
else
"illegal hexadecimal number"));
if (s[i] != 0)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate \\xnn.
*/
"illegal \\xnn construction"));
if ((unsigned)val > LWCHAR_MAX)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate \\xnnnnnnnn and %#x.
*/
" \\xnnnnnnnn exceed %#x"),
if (val == 0)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate \\x00.
*/
"'\\x00' is illegal"));
} else
"invalid escape"));
} else {
}
return (ntokens);
}
static void
defout()
{
/* write out the defines (at the end of the declaration section) */
register int i, c;
{
continue; /* was cp++ */
}
iswdigit(c) || c == L'_')
/* EMPTY */;
else
goto nodef;
}
WSFMT("# define %ws %d\n"),
nodef:;
}
}
static int
gettok()
{
int i, base;
reserve = 0;
peekline = 0;
/*
* while (c == ' ' || c == '\n' || c == '\t' || c == '\f') {
*/
while (iswspace(c)) {
if (c == L'\n')
++lineno;
}
if (c == L'/') { /* skip comment */
goto begin;
}
switch (c) {
case EOF:
return (ENDFILE);
case L'{':
return (L'='); /* action ... */
case L'<': /* get, and look up, a type name (union member name) */
i = 0;
c != EOF && c != L'\n') {
tokname[i] = c;
if (++i >= toksize)
exp_tokname();
}
if (c != L'>')
"unterminated < ... > clause"));
tokname[i] = 0;
if (i == 0)
error("missing type name in < ... > clause");
for (i = 1; i <= ntypes; ++i) {
numbval = i;
return (TYPENAME);
}
}
return (TYPENAME);
case L'"':
case L'\'':
match = c;
tokname[0] = L' ';
i = 1;
for (;;) {
if (c == L'\n' || c == EOF)
"illegal or missing ' or \""));
if (c == L'\\') {
tokname[i] = L'\\';
if (++i >= toksize)
exp_tokname();
} else if (c == match) break;
tokname[i] = c;
if (++i >= toksize)
exp_tokname();
}
break;
case L'%':
case L'\\':
case L'0': return (TERM);
case L'<': return (LEFT);
case L'2': return (BINARY);
case L'>': return (RIGHT);
case L'%':
case L'\\': return (MARK);
case L'=': return (PREC);
case L'{': return (LCURLY);
default: reserve = 1;
}
default:
if (iswdigit(c)) { /* number */
numbval = c - L'0';
iswdigit(c);
}
return (NUMBER);
c == L'_' || c == L'.' ||
c == L'$') {
i = 0;
iswdigit(c) || c == L'_' ||
c == L'.' || c == L'$') {
tokname[i] = c;
if (++i >= toksize)
exp_tokname();
}
}
else
return (c);
}
tokname[i] = 0;
if (reserve) { /* find a reserved word */
return (TERM);
return (TERM);
return (LEFT);
return (BINARY);
return (BINARY);
return (RIGHT);
return (PREC);
return (START);
return (TYPEDEF);
return (UNION);
"invalid escape, or illegal reserved word: %ws"),
tokname);
}
/* look ahead to distinguish IDENTIFIER from C_IDENTIFIER */
/*
* while (c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '/')
* {
*/
while (iswspace(c) || c == L'/') {
if (c == L'\n') {
++peekline;
} else if (c == L'/') { /* look for comments */
}
}
if (c == L':')
return (C_IDENTIFIER);
return (IDENTIFIER);
}
static int
fdtype(int t)
{
/* determine the type of a symbol */
int v;
if (t >= NTBASE)
else
if (v <= 0)
"must specify type for %ws"),
return (v);
}
static int
{
int i;
if (s[0] == ' ')
t = 0;
TLOOP(i) {
return (i);
}
}
NTLOOP(i) {
return (i + NTBASE);
}
}
/* cannot find name */
if (t > 1)
"%ws should have been defined earlier"), s);
return (defin(t, s));
}
static void
cpyunion()
{
/*
* copy the union declaration to the output,
* and the define file if present
*/
int level, c;
if (gen_lines)
if (fdefine)
if (fdefine)
"#ifdef __cplusplus\n\tYYSTYPE\n#endif\n");
level = 0;
for (;;) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* EOF - End Of File.
* Do not translate %%union.
*/
"EOF encountered while processing %%union"));
if (fdefine)
switch (c) {
case L'\n':
++lineno;
break;
case L'{':
++level;
break;
case L'}':
--level;
if (level == 0) { /* we are finished copying */
if (fdefine)
" YYSTYPE;\nextern YYSTYPE yylval;\n");
return;
}
}
}
}
static void
cpycode()
{
/* copies code between \{ and \} */
int c;
if (c == L'\n') {
lineno++;
}
if (gen_lines)
while (c != EOF) {
if (c == L'\\') {
return;
else
} else if (c == L'%') {
return;
else
}
if (c == L'\n')
++lineno;
}
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate %%}.
*/
"eof before %%}"));
}
static int
skipcom()
{
/* skip over comments */
int c, i = 0; /* i is the number of lines skipped */
/* skipcom is called after reading a / */
"illegal comment"));
while (c != EOF) {
while (c == L'*') {
return (i);
}
if (c == L'\n')
++i;
}
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* EOF -- End Of File.
*/
"EOF inside comment"));
/* NOTREACHED */
return (0);
}
static void
{
/* copy C action to the next ; or closing } */
int id_idx = 0;
if (gen_lines) {
act_lines++;
}
brac = 0;
id_name[0] = 0;
loop:
swt:
switch (c) {
case L';':
if (brac == 0) {
return;
}
goto lcopy;
case L'{':
brac++;
goto lcopy;
case L'$':
s = 1;
tok = -1;
argument = 1;
/* NULL */;
if (c == L'<') { /* type description */
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate $<ident>
*/
"bad syntax on $<ident> clause"));
}
if (c == L'$') {
if (ntypes) { /* put out the proper tag... */
if (tok < 0)
}
goto loop;
}
if (iswalpha(c)) {
int same = 0;
int id_sw = 0;
if (gettok() != IDENTIFIER)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"bad action format"));
/*
* Save the number of non-terminal
*/
/*
* Check if the identifier is added as a non-terminal
*/
id_sw = 1;
else
id_sw = 0;
c == L'\t')
/* NULL */;
if (c == L'#') {
c == L'\t')
/* NULL */;
if (iswdigit(c)) {
m = 0;
while (iswdigit(c)) {
m = m*10+c-L'0';
}
argument = m;
} else
"illegal character \"#\""));
}
if (argument < 1)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"illegal action argument no."));
for (i = 1; i <= offset; ++i)
"yypvt[-%d]", offset-i);
if (ntypes) {
if (tok < 0)
tok =
/* CSTYLED */
WSFMT(".%ws"),
}
goto swt;
}
/*
* This used to be handled as error.
* Treat this as a valid C statement.
* (Likely id with $ in.)
* If non-terminal is added, remove it from the list.
*/
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to warning() function.
* Do not translate Ansi C.
*/
"Illegal character '$' in Ansi C symbol: %ws$%ws."),
if (id_sw == 1)
--nnonter;
goto swt;
}
if (c == '-') {
s = -s;
}
if (iswdigit(c)) {
j = 0;
while (iswdigit(c)) {
j = j*10 + c - L'0';
}
j = j*s - offset;
if (j > 0) {
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate $%d.
*/
"Illegal use of $%d"),
j + offset);
}
if (ntypes) { /* put out the proper tag */
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate $%d.
*/
"must specify type of $%d"),
j + offset);
if (tok < 0)
}
goto swt;
}
if (s < 0)
goto swt;
case L'}':
if (--brac)
goto lcopy;
return;
case L'/': /* look for comments */
if (c != L'*')
goto swt;
/* it really is a comment */
while (c != EOF) {
while (c == L'*') {
goto lcopy;
}
if (c == L'\n')
++lineno;
}
error("EOF inside comment");
/* FALLTHRU */
case L'\'': /* character constant */
case L'"': /* character string */
match = c;
if (c == L'\\') {
if (c == L'\n')
++lineno;
} else if (c == match)
goto lcopy;
else if (c == L'\n')
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* This error message is issued when
* quoted string has multiple lines.
*/
"newline in string or char. const."));
}
"EOF in string or character constant"));
/* FALLTHRU */
case EOF:
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*/
"action does not terminate"));
/* FALLTHRU */
case L'\n':
++lineno;
goto lcopy;
}
/*
* Save the possible identifier name.
* Used to print out a warning message.
*/
/*
* Error. Silently ignore.
*/
/* EMPTY */;
}
/*
* If c has a possibility to be a
* part of identifier, save it.
*/
else if (iswalnum(c) || c == L'_') {
} else {
id_idx = 0;
}
goto loop;
}
static void
wchar_t *s;
{
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* LHS -- Left Hand Side.
*/
"couldn't expanded LHS length"));
}
}
static void
rhsfill(s)
wchar_t *s; /* either name or 0 */
{
static int used = 0;
register wchar_t *p;
if (!s) /* print out and erase old text */
{
if (*lhstext) /* there was an old rule - dump it */
lrprnt();
return;
}
/* add to stuff in rhstext */
p = s;
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* RHS -- Right Hand Side.
*/
"couldn't expanded RHS length"));
}
*loc++ = L' ';
if (*s == L' ') /* special quoted symbol */
{
p++;
}
while (*loc = *p++)
break;
if (*s == L' ')
*loc++ = L'\'';
*loc = 0; /* terminate the string */
}
static void
{
if (!*rhstext) /* empty rhs - print usual comment */
rhs = L" /* empty */";
else {
wchar_t *p;
/*
* Check if there are any double quote in RHS.
*/
/*
* A double quote is found.
*/
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* RHS - Right Hand Side.
*
* You may just translate this as:
* 'Could not allocate internally used memory.'
*/
"Couldn't allocate memory for RHS."));
/*
* Copy string
*/
/*
* Check if this quote is escaped or not
*/
int cnt = 0;
while (tmp_l >= 0 &&
cnt++;
tmp_l--;
}
/*
* If quote is not escaped,
* then escape it.
*/
if (cnt%2 == 0)
*p++ = L'\\';
}
}
*p = 0;
/*
* Break from the loop
*/
break;
}
}
else
}
if (m_rhs)
}
static void
{
"typedef struct\n");
"#ifdef __cplusplus\n\tyytoktype\n");
"#ifdef __cplusplus\nconst\n#endif\n");
"#ifndef YYDEBUG\n#\tdefine YYDEBUG\t%d", gen_testing);
}
static void
{
"#ifdef __cplusplus\nconst\n#endif\n");
}
static void
{
lrprnt(); /* dump last lhs, rhs */
}
/*
* 2/29/88 -
* The normal length for token sizes is NAMESIZE - If a token is
* seen that has a longer length, expand "tokname" by NAMESIZE.
*/
static void
{
}
/*
* 2/29/88 -
*
*/
static void
exp_prod()
{
int i;
had_act[i] = 0;
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*
* You may just translate this as:
* 'Could not allocate internally used memory.'
*/
"couldn't expand productions"));
}
/*
* 2/29/88 -
* Expand the number of terminals. Initially there are NTERMS;
* each time space runs out, the size is increased by NTERMS.
* The total size, however, cannot exceed MAXTERMS because of
* the way LOOKSETS(struct looksets) is set up.
* Tables affected:
* tokset, toklev : increased to ntoksz
*
* tables with initial dimensions of TEMPSIZE must be changed if
* (ntoksz + NNONTERM) >= TEMPSIZE : temp1[]
*/
static void
exp_ntok()
{
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate NTERMS.
*
* You may just translate this as:
* 'Could not allocate internally used memory.'
*/
"couldn't expand NTERMS"));
}
static void
{
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
* Do not translate NTERMS.
*
* You may just translate this as:
* 'Could not allocate internally used memory.'
*/
"couldn't expand NNONTERM"));
}
void
int flag;
{
int i;
static int *membase;
new_memsize += MEMSIZE;
tracemem = (int *)
/*
* TRANSLATION_NOTE -- This is a message from yacc.
* This message is passed to error() function.
*
* You may just translate this as:
* 'Could not allocate internally used memory.'
*/
"couldn't expand mem table"));
if (flag) {
for (i = 0; i <= nprod; ++i)
} else {
}
}
static int
int chlit;
/*
* findchtok(chlit) returns the token number for a character literal
* chlit that is "bigger" than 255 -- the max char value that the
* original yacc was build for. This yacc treate them as though
* an ordinary token.
*/
{
int i;
if (chlit < 0xff)
return (chlit); /* single-byte char */
for (i = 0; i < nmbchars; ++i) {
}
/* Not found. Register it! */
"too many character literals"));
}
/* Return the newly assigned token. */
}
/*
* When -p is specified, symbol prefix for
* yy{parse, lex, error}(),
* yy{lval, val, char, debug, errflag, nerrs}
* are defined to the specified name.
*/
static void
{
char *syms[] = {
/* Functions */
"parse",
"lex",
"error",
/* Variables */
"lval",
"val",
"char",
"debug",
"errflag",
"nerrs",
NULL};
int i;
for (i = 0; syms[i]; i++)
}