USG_PG3/usr/source/lexgen1/cpyact.c
cpyact(){ /* copy C action to the next ; or closing } */
int brac, c, match, *i, j, savline;
extern int output, lineno;
brac = 0;
loop:
c = getchar();
swt:
switch( c ){
case ';':
if( brac == 0 ){
cputc( c , output);
return;
}
goto lcopy;
case '{':
brac++;
savline=lineno;
goto lcopy;
case '}':
brac--;
if( brac == 0 ){
cputc( c , output);
return;
}
goto lcopy;
case '/': /* look for comments */
cputc( c , output);
c = getchar();
if( c != '*' ) goto swt;
/* it really is a comment */
cputc( c , output);
savline=lineno;
while( c=getchar() ){
if( c=='*' ){
cputc( c , output);
if( (c=getchar()) == '/' ) goto lcopy;
}
cputc( c , output);
}
lineno=savline;
error( "EOF inside comment" );
case '\'': /* character constant */
match = '\'';
goto string;
case '"': /* character string */
match = '"';
string:
cputc( c , output);
while( c=getchar() ){
if( c=='\\' ){
cputc( c , output);
c=getchar();
}
else if( c==match ) goto lcopy;
cputc( c , output);
if (c == '\n')
{
lineno--;
error( "Non-terminated string or character constant");
}
}
error( "EOF in string or character constant" );
case '\0':
lineno = savline;
error("action does not terminate");
case '\n':
goto lcopy;
}
lcopy:
cputc( c , output);
goto loop;
}