Fix parseing functions to return an error message if the parse failed

This commit is contained in:
Nick Clifton 2006-03-03 15:57:43 +00:00
parent 4cdc7696f5
commit c7d41dc5a0
6 changed files with 346 additions and 3177 deletions

View File

@ -1,3 +1,10 @@
2006-03-03 Shrirang Khisti <shrirangk@kpitcummins.com)
* xc16x.opc (parse_hash): Return NULL if the input was parsed or
an error message otherwise.
(parse_dot, parse_pof, parse_pag, parse_sof, parse_seg): Likewise.
Fix up comments to correctly describe the functions.
2006-02-24 DJ Delorie <dj@redhat.com> 2006-02-24 DJ Delorie <dj@redhat.com>
* m32c.cpu (RL_TYPE): New attribute, with macros. * m32c.cpu (RL_TYPE): New attribute, with macros.

File diff suppressed because it is too large Load Diff

View File

@ -59,9 +59,12 @@ parse_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (**strp == '#') if (**strp == '#')
{
++*strp; ++*strp;
return NULL; return NULL;
} }
return _("Missing '#' prefix");
}
/* Handle '.' prefixes (i.e. skip over them). */ /* Handle '.' prefixes (i.e. skip over them). */
@ -72,11 +75,14 @@ parse_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (**strp == '.') if (**strp == '.')
{
++*strp; ++*strp;
return NULL; return NULL;
} }
return _("Missing '.' prefix");
}
/* Handle '.' prefixes (i.e. skip over them). */ /* Handle 'pof:' prefixes (i.e. skip over them). */
static const char * static const char *
parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -84,12 +90,15 @@ parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "pof:", 4)) if (strncasecmp (*strp, "pof:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'pof:' prefix");
}
/* Handle '.' prefixes (i.e. skip over them). */ /* Handle 'pag:' prefixes (i.e. skip over them). */
static const char * static const char *
parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -97,34 +106,45 @@ parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "pag:", 4)) if (strncasecmp (*strp, "pag:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'pag:' prefix");
}
/* Handle 'sof' prefixes (i.e. skip over them). */ /* Handle 'sof' prefixes (i.e. skip over them). */
static const char * static const char *
parse_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
const char **strp, const char **strp,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "sof:", 4)) if (strncasecmp (*strp, "sof:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'sof:' prefix");
}
/* Handle 'seg' prefixes (i.e. skip over them). */ /* Handle 'seg' prefixes (i.e. skip over them). */
static const char * static const char *
parse_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
const char **strp, const char **strp,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "seg:", 4)) if (strncasecmp (*strp, "seg:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'seg:' prefix");
}
/* -- */ /* -- */
/* -- dis.c */ /* -- dis.c */
@ -141,7 +161,7 @@ parse_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
} \ } \
while (0) while (0)
/* Handle '.' prefixes as operands. */ /* Print a 'pof:' prefix to an operand. */
static void static void
print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -153,7 +173,7 @@ print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{ {
} }
/* Handle '.' prefixes as operands. */ /* Print a 'pag:' prefix to an operand. */
static void static void
print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -165,7 +185,7 @@ print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{ {
} }
/* Handle '.' prefixes as operands. */ /* Print a 'sof:' prefix to an operand. */
static void static void
print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -180,7 +200,7 @@ print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
info->fprintf_func (info->stream, "sof:"); info->fprintf_func (info->stream, "sof:");
} }
/* Handle '.' prefixes as operands. */ /* Print a 'seg:' prefix to an operand. */
static void static void
print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -195,7 +215,7 @@ print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
info->fprintf_func (info->stream, "seg:"); info->fprintf_func (info->stream, "seg:");
} }
/* Handle '#' prefixes as operands. */ /* Print a '#' prefix to an operand. */
static void static void
print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -210,7 +230,7 @@ print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
info->fprintf_func (info->stream, "#"); info->fprintf_func (info->stream, "#");
} }
/* Handle '.' prefixes as operands. */ /* Print a '.' prefix to an operand. */
static void static void
print_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,

View File

@ -1,3 +1,9 @@
2006-03-03 Shrirang Khisti <shrirangk@kpitcummins.com)
* xc16x-asm.c: Regenerate.
* xc16x-dis.c: Regenerate.
* xc16x-ibld.c: Regenerate.
2006-02-27 Carlos O'Donell <carlos@codesourcery.com> 2006-02-27 Carlos O'Donell <carlos@codesourcery.com>
* po/Make-in: Add html target. * po/Make-in: Add html target.

View File

@ -58,9 +58,12 @@ parse_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (**strp == '#') if (**strp == '#')
{
++*strp; ++*strp;
return NULL; return NULL;
} }
return _("Missing '#' prefix");
}
/* Handle '.' prefixes (i.e. skip over them). */ /* Handle '.' prefixes (i.e. skip over them). */
@ -71,11 +74,14 @@ parse_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (**strp == '.') if (**strp == '.')
{
++*strp; ++*strp;
return NULL; return NULL;
} }
return _("Missing '.' prefix");
}
/* Handle '.' prefixes (i.e. skip over them). */ /* Handle 'pof:' prefixes (i.e. skip over them). */
static const char * static const char *
parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -83,12 +89,15 @@ parse_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "pof:", 4)) if (strncasecmp (*strp, "pof:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'pof:' prefix");
}
/* Handle '.' prefixes (i.e. skip over them). */ /* Handle 'pag:' prefixes (i.e. skip over them). */
static const char * static const char *
parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -96,34 +105,45 @@ parse_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "pag:", 4)) if (strncasecmp (*strp, "pag:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'pag:' prefix");
}
/* Handle 'sof' prefixes (i.e. skip over them). */ /* Handle 'sof' prefixes (i.e. skip over them). */
static const char * static const char *
parse_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
const char **strp, const char **strp,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "sof:", 4)) if (strncasecmp (*strp, "sof:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'sof:' prefix");
}
/* Handle 'seg' prefixes (i.e. skip over them). */ /* Handle 'seg' prefixes (i.e. skip over them). */
static const char * static const char *
parse_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, parse_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
const char **strp, const char **strp,
int opindex ATTRIBUTE_UNUSED, int opindex ATTRIBUTE_UNUSED,
long *valuep ATTRIBUTE_UNUSED) long *valuep ATTRIBUTE_UNUSED)
{ {
if (!strncasecmp (*strp, "seg:", 4)) if (strncasecmp (*strp, "seg:", 4) == 0)
{
*strp += 4; *strp += 4;
return NULL; return NULL;
} }
return _("Missing 'seg:' prefix");
}
/* -- */ /* -- */
const char * xc16x_cgen_parse_operand const char * xc16x_cgen_parse_operand

View File

@ -72,7 +72,7 @@ static int read_insn
} \ } \
while (0) while (0)
/* Handle '.' prefixes as operands. */ /* Print a 'pof:' prefix to an operand. */
static void static void
print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -84,7 +84,7 @@ print_pof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{ {
} }
/* Handle '.' prefixes as operands. */ /* Print a 'pag:' prefix to an operand. */
static void static void
print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -96,7 +96,7 @@ print_pag (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
{ {
} }
/* Handle '.' prefixes as operands. */ /* Print a 'sof:' prefix to an operand. */
static void static void
print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -111,7 +111,7 @@ print_sof (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
info->fprintf_func (info->stream, "sof:"); info->fprintf_func (info->stream, "sof:");
} }
/* Handle '.' prefixes as operands. */ /* Print a 'seg:' prefix to an operand. */
static void static void
print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -126,7 +126,7 @@ print_seg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
info->fprintf_func (info->stream, "seg:"); info->fprintf_func (info->stream, "seg:");
} }
/* Handle '#' prefixes as operands. */ /* Print a '#' prefix to an operand. */
static void static void
print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
@ -141,7 +141,7 @@ print_hash (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
info->fprintf_func (info->stream, "#"); info->fprintf_func (info->stream, "#");
} }
/* Handle '.' prefixes as operands. */ /* Print a '.' prefix to an operand. */
static void static void
print_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, print_dot (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,