Commit eb303477 authored by dcw's avatar dcw
Browse files

minor changes;

put casts on all uses of NULL to shut lint up;
expected->error, removed "expected" word from default message,
so all calls to expected (and the macro MUSTBE) have expected
added
parent 65a36dd3
......@@ -10,11 +10,11 @@
*
******* Grammar for Declarations
*
* declns = ne-list( decln ) tEOF
* declns = list+( decln ) tEOF
* decln = tID tEQ shapes tSEMI
* shapes = ne-sep-list( shape, tOR )
* shapes = sep-list+( shape, tOR )
* shape = tID [ tOPENBR params tCLOSEBR ] printlist
* params = ne-sep-list( param, tCOMMA )
* params = sep-list+( param, tCOMMA )
* param = tID tID
* printlist = list( tSTR | tNUM )
*/
......@@ -26,26 +26,34 @@
#include "parser.h"
/*
/^#ifdef HASPROTOS
!/endif$
stat %
*/
#ifdef HASPROTOS
static void error( char * );
static BOOL parse_decln( char ** , shapelist * );
static BOOL parse_shapes( shapelist * );
static BOOL parse_shape( char ** , paramlist *, printlist * );
static BOOL parse_shape( char ** , paramlist * , printlist * );
static BOOL parse_params( paramlist * );
static BOOL parse_param( char ** , char ** );
static BOOL parse_printlist( printlist * );
static BOOL parse_printitem( printitem * );
static BOOL parse_param( char ** , char ** );
#else
static void error();
static BOOL parse_decln();
static BOOL parse_shapes();
static BOOL parse_shape();
static BOOL parse_params();
static BOOL parse_param();
static BOOL parse_printlist();
static BOOL parse_printitem();
static BOOL parse_param();
#endif
/* declns = ne-list( decln ) tEOF */
/* declns = list+( decln ) tEOF */
BOOL parse_declns( dp ) declnlist *dp;
{
......@@ -54,7 +62,7 @@ BOOL parse_declns( dp ) declnlist *dp;
for(;;) {
if( ! parse_decln( &name, &shapes ) ) return FALSE;
*dp = build_declnlist( name, shapes, NULL );
*dp = build_declnlist( name, shapes, (declnlist) NULL );
if( nexttok() == tEOF ) break;
ungettok();
dp = &( (*dp)->next );
......@@ -63,33 +71,33 @@ BOOL parse_declns( dp ) declnlist *dp;
}
static void expected( s ) char *s;
static void error( s ) char *s;
{
fprintf( stderr, "%s expected at line %d\n", s, lineno );
fprintf( stderr, "%s at line %d\n", s, lineno );
}
#define MUSTBE(t,mesg) if( nexttok() != (t) ) {expected(mesg); return FALSE;}
#define MUSTBE(t,mesg) if( nexttok() != (t) ) {error(mesg); return FALSE;}
/* decln = tID tEQ shapes tSEMI */
static BOOL parse_decln( name, shapes ) char **name; shapelist *shapes;
{
MUSTBE( tID, "declaration" );
MUSTBE( tID, "declaration expected" );
COPYOF( *name, lexidval );
MUSTBE( tEQ, "'='" );
MUSTBE( tEQ, "'=' expected" );
if( ! parse_shapes( shapes ) ) return FALSE;
MUSTBE( tSEMI, "';'" );
MUSTBE( tSEMI, "';' expected" );
return TRUE;
}
/* shapes = ne-sep-list( shape, tOR ) */
/* shapes = sep-list+( shape, tOR ) */
static BOOL parse_shapes( sp ) shapelist *sp;
{
......@@ -99,7 +107,8 @@ static BOOL parse_shapes( sp ) shapelist *sp;
for(;;) {
if( ! parse_shape( &tagname, &paras, &print ) ) return FALSE;
*sp = build_shapelist( tagname, paras, print, NULL );
*sp = build_shapelist( tagname, paras,
print, (shapelist) NULL );
if( nexttok() != tOR ) break;
sp = &( (*sp)->next );
}
......@@ -112,17 +121,17 @@ static BOOL parse_shapes( sp ) shapelist *sp;
static BOOL parse_shape( tagname, pl, print ) char **tagname; paramlist *pl; printlist *print;
{
*pl = NULL;
*print = NULL;
*pl = (paramlist) NULL;
*print = (printlist) NULL;
MUSTBE( tID, "shape name" );
MUSTBE( tID, "shape name expected" );
COPYOF( *tagname, lexidval );
if( nexttok() == tOPENBR )
{
if( ! parse_params( pl ) ) return FALSE;
MUSTBE( tCLOSEBR, "')'" );
MUSTBE( tCLOSEBR, "')' expected" );
} else
{
ungettok();
......@@ -132,7 +141,7 @@ static BOOL parse_shape( tagname, pl, print ) char **tagname; paramlist *pl; pri
}
/* params = ne-sep-list( param, tCOMMA ) */
/* params = sep-list+( param, tCOMMA ) */
static BOOL parse_params( pp ) paramlist *pp;
{
......@@ -141,7 +150,7 @@ static BOOL parse_params( pp ) paramlist *pp;
for(;;) {
if( !parse_param( &type, &name ) ) return FALSE;
*pp = build_paramlist( type, name, NULL );
*pp = build_paramlist( type, name, (paramlist) NULL );
if( nexttok() != tCOMMA ) break;
pp = &( (*pp)->next );
}
......@@ -157,11 +166,11 @@ static BOOL parse_printlist( pp ) printlist *pp;
{
printitem item;
*pp = NULL;
*pp = (printlist) NULL;
while( parse_printitem( &item ) )
{
*pp = build_printlist( item, NULL );
*pp = build_printlist( item, (printlist) NULL );
pp = &( (*pp)->next );
}
return TRUE;
......@@ -193,10 +202,10 @@ static BOOL parse_printitem( item ) printitem *item;
static BOOL parse_param( type, name ) char **type, **name;
{
MUSTBE( tID, "Field type" );
MUSTBE( tID, "Field type expected" );
COPYOF( *type, lexidval );
MUSTBE( tID, "Field name" );
MUSTBE( tID, "Field name expected" );
COPYOF( *name, lexidval );
return TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment