Branch: Tag:

2003-06-06

2003-06-06 14:32:03 by Henrik Grubbström (Grubba) <grubba@grubba.org>

parse_type() now uses yyerror() instead of throwing errors on syntax errors in the input.

Rev: src/pike_types.c:1.215

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: pike_types.c,v 1.214 2003/04/02 19:22:43 mast Exp $ + || $Id: pike_types.c,v 1.215 2003/06/06 14:32:03 grubba Exp $   */      #include "global.h" - RCSID("$Id: pike_types.c,v 1.214 2003/04/02 19:22:43 mast Exp $"); + RCSID("$Id: pike_types.c,v 1.215 2003/06/06 14:32:03 grubba Exp $");   #include <ctype.h>   #include "svalue.h"   #include "pike_types.h"
941:    len=0;    for(len=0;isidchar(EXTRACT_UCHAR(s[0]+len));len++)    { -  if(len>=sizeof(buf)) Pike_error("Buffer overflow in parse_type\n"); +  if(len>=sizeof(buf)) { +  my_yyerror("Buffer overflow in parse_type(\"%s\") (limit %d).", +  *s, sizeof(buf)); +  push_type(T_MIXED); +  return; +  }    buf[len] = s[0][len];    }    buf[len]=0;
966:    while(ISSPACE(**s)) ++*s;    if(s[0][0]=='.' && s[0][1]=='.')    s[0]+=2; -  else -  Pike_error("Missing .. in integer type.\n"); +  else { +  yyerror("Missing .. in integer type."); +  }       while(ISSPACE(**s)) ++*s;    max=STRTOL((const char *)*s,(char **)s,0);    while(ISSPACE(**s)) ++*s;    -  if(**s != ')') Pike_error("Missing ')' in integer range.\n"); +  if(**s != ')') yyerror("Missing ')' in integer range."); +  else    ++*s;    push_int_type(min, max);    }else{
1010:    {    *s+=3;    while(ISSPACE(**s)) ++*s; -  if(**s != ':') -  Pike_error("Missing ':' after ... in function type.\n"); +  if(**s != ':') { +  yyerror("Missing ':' after ... in function type."); +  *s--; +  }    break;    } else {    nargs++;    }    } -  +  /* Skip the colon. */    ++*s;    internal_parse_type(_s); /* return type */    push_reverse_type(T_MANY);
1025:    push_reverse_type(T_FUNCTION);    }    -  if(**s != ')') Pike_error("Missing ')' in function type.\n"); +  if(**s != ')') yyerror("Missing ')' in function type."); +  else    ++*s;    }else{    push_type(T_VOID);
1116:    {    ++*s;    internal_parse_type(_s); -  if(**s != ',') Pike_error("Expecting ','.\n"); +  if(**s != ',') yyerror("Expected ','."); +  else    ++*s;    internal_parse_type(_s); -  if(**s != ')') Pike_error("Expecting ')'.\n"); +  if(**s != ')') yyerror("Expected ')'."); +  else    ++*s;    }else{    push_type(T_MIXED);
1141:    {    ++*s;    internal_parse_type(_s); -  if(**s != ':') Pike_error("Expecting ':'.\n"); +  if(**s != ':') yyerror("Expected ':'."); +  else    ++*s;    internal_parse_type(_s); -  if(**s != ')') Pike_error("Expecting ')'.\n"); +  if(**s != ')') yyerror("Expected ')'."); +  else    ++*s;    }else{    push_type(T_MIXED);
1160:    {    ++*s;    internal_parse_type(_s); -  if(**s != ')') Pike_error("Expecting ')'.\n"); +  if(**s != ')') yyerror("Expected ')'."); +  else    ++*s;    }else{    push_type(T_MIXED);
1182:    {    ++*s;    internal_parse_type(_s); -  if(**s != ')') Pike_error("Expecting ')'.\n"); +  if(**s != ')') yyerror("Expected ')'."); +  else    ++*s;    }else{    push_type(T_MIXED);
1218:       default:    bad_type: -  Pike_error("Couldn't parse type. (%s)\n",buf); +  push_type(T_MIXED); +  my_yyerror("Couldn't parse type. (%s).", buf);    }       while(ISSPACE(**s)) ++*s;
1240:    ++*s;    internal_parse_type(s);    while(ISSPACE(EXTRACT_UCHAR(*s))) ++*s; -  if(**s != ')') Pike_error("Expecting ')'.\n"); +  if(**s != ')') { +  yyerror("Expected ')' in type."); +  }    ++*s;    break;   
1306:    TYPE_STACK_DEBUG("parse_type");       type_stack_mark(); +     internal_parse_type(&s);       if( *s ) -  Pike_fatal("Extra junk at end of type definition.\n"); +  yyerror("Extra junk at end of type definition.");       ret=pop_unfinished_type();