version 1.6, 2005/05/13 05:05:22 |
version 1.7, 2005/10/17 07:35:29 |
|
|
%{ |
%{ |
/* |
/* |
* Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan |
* Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan |
* (Royal Institute of Technology, Stockholm, Sweden). |
* (Royal Institute of Technology, Stockholm, Sweden). |
* All rights reserved. |
* All rights reserved. |
* |
* |
|
|
* notice, this list of conditions and the following disclaimer in the |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* documentation and/or other materials provided with the distribution. |
* |
* |
* 3. All advertising materials mentioning features or use of this software |
* 3. Neither the name of the Institute nor the names of its contributors |
* must display the following acknowledgement: |
|
* This product includes software developed by Kungliga Tekniska |
|
* Högskolan and its contributors. |
|
* |
|
* 4. Neither the name of the Institute nor the names of its contributors |
|
* may be used to endorse or promote products derived from this software |
* may be used to endorse or promote products derived from this software |
* without specific prior written permission. |
* without specific prior written permission. |
* |
* |
|
|
*/ |
*/ |
|
|
#include "compile_et.h" |
#include "compile_et.h" |
/* RCSID("$KTH: parse.y,v 1.9 1999/07/04 14:54:58 assar Exp $"); */ |
|
|
|
|
/* RCSID("$KTH: parse.y,v 1.13 2005/05/16 08:53:34 lha Exp $"); */ |
|
|
void yyerror (char *s); |
void yyerror (char *s); |
long name2number(const char *str); |
static long name2number(const char *str); |
void error_message(char *, ...); |
void error_message(char *, ...); |
|
|
extern char *yytext; |
extern char *yytext; |
|
|
} |
} |
| PREFIX STRING |
| PREFIX STRING |
{ |
{ |
size_t len = strlen($2) + 2; |
free(prefix); |
|
asprintf (&prefix, "%s_", $2); |
if ((prefix = realloc(prefix, len)) == NULL) { |
if (prefix == NULL) |
yyerror(strerror(errno)); |
errx(1, "malloc"); |
exit(1); |
|
} |
|
strlcpy(prefix, $2, len); |
|
strlcat(prefix, "_", len); |
|
free($2); |
free($2); |
} |
} |
| PREFIX |
| PREFIX |
{ |
{ |
if ((prefix = realloc(prefix, 1)) == NULL) { |
prefix = realloc(prefix, 1); |
yyerror(strerror(errno)); |
if (prefix == NULL) |
exit(1); |
errx(1, "malloc"); |
} |
|
*prefix = '\0'; |
*prefix = '\0'; |
} |
} |
| EC STRING ',' STRING |
| EC STRING ',' STRING |
{ |
{ |
struct error_code *ec = malloc(sizeof(*ec)); |
struct error_code *ec = malloc(sizeof(*ec)); |
|
|
if (ec == NULL) { |
if (ec == NULL) |
yyerror(strerror(errno)); |
errx(1, "malloc"); |
exit(1); |
|
} |
|
ec->next = NULL; |
ec->next = NULL; |
ec->number = number; |
ec->number = number; |
if(prefix && *prefix != '\0') { |
if(prefix && *prefix != '\0') { |
if (asprintf (&ec->name, "%s%s", prefix, $2) == -1) { |
asprintf (&ec->name, "%s%s", prefix, $2); |
yyerror(strerror(errno)); |
if (ec->name == NULL) |
exit(1); |
errx(1, "malloc"); |
} |
|
free($2); |
free($2); |
} else |
} else |
ec->name = $2; |
ec->name = $2; |
|
|
|
|
%% |
%% |
|
|
long |
static long |
name2number(const char *str) |
name2number(const char *str) |
{ |
{ |
const char *p; |
const char *p; |