public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
* patch for suffixes like '.b.w' using keywords
@ 2001-06-25 15:24 Geoffrey Keating
  2001-06-27 12:48 ` J. Johnston
  0 siblings, 1 reply; 2+ messages in thread
From: Geoffrey Keating @ 2001-06-25 15:24 UTC (permalink / raw)
  To: cgen

This patch slightly extends my last keyword-parsing patch to allow
special first characters in a keyword to be treated differently than
other special characters.  As an example, if you have a keyword set
"a" "foo_bar" ".foo", the parser will consider any sequence of
characters starting with any character and continuing with
alphanumerics and '_' to be a possible keyword.  Thus, "a.b" will
match "a", but "foo_bar_baz" will not match anything.

This works on both internal ports that have been discussed in this
context.  I think it's likely to be the best that can be done
that's simpler than a proper finite state machine.

Is this OK to commit?

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/cgen-keywordfirstspecial.patch============
2001-06-19  Geoffrey Keating  <geoffk@redhat.com>

	* cgen-asm.c (cgen_parse_keyword): Allow any first character.
	* cgen-opc.c (cgen_keyword_add): Ignore special first
	character when building nonalpha_chars field.

Index: opcodes/cgen-asm.c
===================================================================
RCS file: /cvs/cvsfiles/devo/opcodes/cgen-asm.c,v
retrieving revision 1.21
diff -p -u -p -r1.21 cgen-asm.c
--- cgen-asm.c	2001/06/14 21:00:28	1.21
+++ cgen-asm.c	2001/06/19 07:55:33
@@ -212,6 +212,12 @@ cgen_parse_keyword (cd, strp, keyword_ta
 
   p = start = *strp;
 
+  /* Allow any first character.  This is to make life easier for
+     the fairly common case of suffixes, eg. 'ld.b.w', where the first
+     character of the suffix ('.') is special.  */
+  if (*p)
+    ++p;
+  
   /* Allow letters, digits, and any special characters.  */
   while (((p - start) < (int) sizeof (buf))
 	 && *p
Index: opcodes/cgen-opc.c
===================================================================
RCS file: /cvs/cvsfiles/devo/opcodes/cgen-opc.c,v
retrieving revision 1.28
diff -p -u -p -r1.28 cgen-opc.c
--- cgen-opc.c	2001/06/14 21:11:59	1.28
+++ cgen-opc.c	2001/06/19 07:55:33
@@ -134,7 +134,7 @@ cgen_keyword_add (kt, ke)
   if (ke->name[0] == 0)
     kt->null_entry = ke;
 
-  for (i = 0; i < strlen (ke->name); i++)
+  for (i = 1; i < strlen (ke->name); i++)
     if (! isalnum ((unsigned char) ke->name[i])
 	&& ! strchr (kt->nonalpha_chars, ke->name[i]))
       {
============================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: patch for suffixes like '.b.w' using keywords
  2001-06-25 15:24 patch for suffixes like '.b.w' using keywords Geoffrey Keating
@ 2001-06-27 12:48 ` J. Johnston
  0 siblings, 0 replies; 2+ messages in thread
From: J. Johnston @ 2001-06-27 12:48 UTC (permalink / raw)
  To: geoffk; +Cc: cgen

Geoffrey Keating wrote:
> 
> This patch slightly extends my last keyword-parsing patch to allow
> special first characters in a keyword to be treated differently than
> other special characters.  As an example, if you have a keyword set
> "a" "foo_bar" ".foo", the parser will consider any sequence of
> characters starting with any character and continuing with
> alphanumerics and '_' to be a possible keyword.  Thus, "a.b" will
> match "a", but "foo_bar_baz" will not match anything.
> 
> This works on both internal ports that have been discussed in this
> context.  I think it's likely to be the best that can be done
> that's simpler than a proper finite state machine.
> 
> Is this OK to commit?
> 

Please check it in.  I have talked to Frank and he approves.

-- Jeff J.

> --
> Geoff Keating <geoffk@redhat.com>
> 
> ===File ~/patches/cgen-keywordfirstspecial.patch============
> 2001-06-19  Geoffrey Keating  <geoffk@redhat.com>
> 
>         * cgen-asm.c (cgen_parse_keyword): Allow any first character.
>         * cgen-opc.c (cgen_keyword_add): Ignore special first
>         character when building nonalpha_chars field.
> 
> Index: opcodes/cgen-asm.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/opcodes/cgen-asm.c,v
> retrieving revision 1.21
> diff -p -u -p -r1.21 cgen-asm.c
> --- cgen-asm.c  2001/06/14 21:00:28     1.21
> +++ cgen-asm.c  2001/06/19 07:55:33
> @@ -212,6 +212,12 @@ cgen_parse_keyword (cd, strp, keyword_ta
> 
>    p = start = *strp;
> 
> +  /* Allow any first character.  This is to make life easier for
> +     the fairly common case of suffixes, eg. 'ld.b.w', where the first
> +     character of the suffix ('.') is special.  */
> +  if (*p)
> +    ++p;
> +
>    /* Allow letters, digits, and any special characters.  */
>    while (((p - start) < (int) sizeof (buf))
>          && *p
> Index: opcodes/cgen-opc.c
> ===================================================================
> RCS file: /cvs/cvsfiles/devo/opcodes/cgen-opc.c,v
> retrieving revision 1.28
> diff -p -u -p -r1.28 cgen-opc.c
> --- cgen-opc.c  2001/06/14 21:11:59     1.28
> +++ cgen-opc.c  2001/06/19 07:55:33
> @@ -134,7 +134,7 @@ cgen_keyword_add (kt, ke)
>    if (ke->name[0] == 0)
>      kt->null_entry = ke;
> 
> -  for (i = 0; i < strlen (ke->name); i++)
> +  for (i = 1; i < strlen (ke->name); i++)
>      if (! isalnum ((unsigned char) ke->name[i])
>         && ! strchr (kt->nonalpha_chars, ke->name[i]))
>        {
> ============================================================

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-06-27 12:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-25 15:24 patch for suffixes like '.b.w' using keywords Geoffrey Keating
2001-06-27 12:48 ` J. Johnston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).