yerror
cp y.output /tmp/my$$
ex - /tmp/my$$ <<'!' > tmp.yerror$$
/accept\$/;?^state?,/^state/-1d
1kc
1,\$g/\. error\$/kb\
?^state?ka\
'c,'a-d\
'a+,/ shift /-1d\
'a+,'b-s/ \(.*\) shift.*/\1 or /\
'b-s/or //\
'as/state /case /\
'as/\$/: doprintf("/\
'a,'b-j!\
'b-s/\$/expected\");break;/\
'b;kc
\$;?case?+1,\$d
1i
ifndef Y_ERROR_C
define Y_ERROR_C
define doprintf(X) { \
sprintf(buf,"%s --> %s",buf,X); \
}
include <stdio.h>
include <hush/string.h>
char* NAME::error()
{
//ostream& out = &cout; // * _scanner->yyout;
char buf[1024];
int state = yystate;
int yy_lineno = _scanner?_scanner->yylineno:yylineno;
int yy_context = _scanner?_scanner->yycontext:yycontext;
//extern int yytchar;
//extern int yychar;
sprintf(buf,"line: %d *** %s *** (%d)\t",
yy_lineno,strof(yylval),yychar);
switch(state) {
default:
sprintf(buf,"%s ???",buf);
break;
.
\$a
}
dvstring* s = new string(buf);
if (!_garbage) _garbage = new handler();
_garbage->_register(s);
return((char*)*s); }
endif
.
w
q
!
cat /tmp/my$$ | @BIN/yerror.flt > y.error.c
cp /tmp/my$$ @y.error.c
rm /tmp/my$$
rm -f tmp.yerror$$
slide: yerror