/*Copyright (C) 1992, 1994 by Thomas Glen Smith. All Rights Reserved.*/
/* execpars APL2 V1.0.0 ************************************************
* Called by apledit and executg to interface to the apl parsing *
* routine, and display error messages when appropriate. *
***********************************************************************/
#define INCLUDES APLTOKEN
#include "includes.h"
Apltoken execpars(stmtptr,stmtlen)
char *stmtptr;
int stmtlen;
{
Aplparse; Execfree; Execmsg; Execpop; Pop;
extern int aplerr;
Apltoken bug,tokhdr;
char *msg = NULL;
int offset = 0; /* offset of error, if one occurs */
if (aplerr) return(NULL);
tokhdr = aplparse(stmtptr,stmtlen);
if (tokhdr->token_code == MESSAGE_TOKEN) {
aplerr = 58; /* syntax error */
msg = tokhdr->token_ptr.token_string; /* error message */
offset = tokhdr->token_offset; /* offset of error */
}
else {
/* execfree(pop(&tokhdr)); * pop & free NO_MORE_TOKENS */
/* the above statement didn't work - I don't know why. */
bug = pop(&tokhdr);
execfree(bug);
}
if (aplerr) {
execmsg(stmtptr,stmtlen,offset,msg); /* print message */
execpop(&tokhdr); /* pop/free any tokens on stack */
}
return(tokhdr); /* return list of tokens */
}