public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-keiths-linespec-rewrite: Update/simplification of keywords.
@ 2012-03-13 22:03 kseitz
  0 siblings, 0 replies; only message in thread
From: kseitz @ 2012-03-13 22:03 UTC (permalink / raw)
  To: archer-commits

The branch, archer-keiths-linespec-rewrite has been updated
       via  a3418d99a0653cb544ed9daab555fa4eac90530d (commit)
      from  d14a86c4c46eb6f5ddcb2ee83b2cd4f5b50f7267 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit a3418d99a0653cb544ed9daab555fa4eac90530d
Author: keiths <keiths@redhat.com>
Date:   Tue Mar 13 15:02:39 2012 -0700

    Update/simplification of keywords.

-----------------------------------------------------------------------

Summary of changes:
 gdb/linespec.c                         |   44 +++++++++----------------------
 gdb/testsuite/gdb.linespec/ls-errs.exp |    4 +++
 2 files changed, 17 insertions(+), 31 deletions(-)

First 500 lines of diff:
diff --git a/gdb/linespec.c b/gdb/linespec.c
index ba4baac..4940463 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -207,32 +207,9 @@ enum ls_token_type
 };
 typedef enum ls_token_type linespec_token_type;
 
-/* Keyword types  */
-
-enum ls_keyword_type
-{
-    LSKEYWORD_IF,
-    LSKEYWORD_THREAD,
-    LSKEYWORD_TASK
-};
-typedef enum ls_keyword_type linespec_keyword_type;
-
-/* A linespec keyword  */
-
-struct ls_keyword
-{
-  const char *string;
-  linespec_keyword_type type;
-};
-typedef struct ls_keyword linespec_keyword;
-
 /* List of keywords  */
 
-const linespec_keyword linespec_keywords[] = {
-  {"if", LSKEYWORD_IF},
-  {"thread", LSKEYWORD_THREAD},
-  {"task", LSKEYWORD_TASK}
-};
+const char * const linespec_keywords[] = { "if", "thread", "task" };
 
 /* A token of the linespec lexer  */
 
@@ -248,12 +225,13 @@ struct ls_token
     struct stoken string;
 
     /* A keyword  */
-    const linespec_keyword *keyword;
+    const char *keyword;
   } data;
 };
 typedef struct ls_token linespec_token;
 
 #define LS_TOKEN_STOKEN(TOK) (TOK).data.string
+#define LS_TOKEN_KEYWORD(TOK) (TOK).data.keyword
 
 /* An instance of the linespec parser.  */
 
@@ -409,7 +387,7 @@ linespec_lexer_lex_number (linespec_parser *parser)
 /* Does P represent one of the keywords?  If so, return
    the keyword.  If not, return NULL.  */
 
-static const linespec_keyword *
+static const char *
 linespec_lexer_lex_keyword (const char *p)
 {
   int i;
@@ -418,14 +396,14 @@ linespec_lexer_lex_keyword (const char *p)
     {
       for (i = 0; i < ARRAY_SIZE (linespec_keywords); ++i)
 	{
-	  int len = strlen (linespec_keywords[i].string);
+	  int len = strlen (linespec_keywords[i]);
 
 	  /* If P begins with one of the keywords and the next
 	     character is not a valid identifier character,
 	     we have found a keyword.  */
-	  if (strncmp (p, linespec_keywords[i].string, len) == 0
+	  if (strncmp (p, linespec_keywords[i], len) == 0
 	      && !(isalnum (p[len]) || p[len] == '_'))
-	    return &linespec_keywords[i];
+	    return linespec_keywords[i];
 	}
     }
 
@@ -491,6 +469,9 @@ copy_token_string (linespec_token token)
 {
   char *str;
 
+  if (token.type == LSTOKEN_KEYWORD)
+    return xstrdup (LS_TOKEN_KEYWORD (token));
+
   str = savestring (LS_TOKEN_STOKEN (token).ptr,
 		    LS_TOKEN_STOKEN (token).length);
   TRIM_WHITESPACE (str);
@@ -622,7 +603,7 @@ linespec_lexer_lex_string (linespec_parser *parser)
 static linespec_token
 linespec_lexer_lex_one (linespec_parser *parser)
 {
-  const linespec_keyword *keyword;
+  const char *keyword;
 
   if (parser->lexer.current.type == LSTOKEN_CONSUMED)
     {
@@ -633,7 +614,8 @@ linespec_lexer_lex_one (linespec_parser *parser)
       keyword = linespec_lexer_lex_keyword (PARSER_STREAM (parser));
       if (keyword != NULL)
 	{
-	  parser->lexer.current.type = LSTOKEN_EOF;
+	  parser->lexer.current.type = LSTOKEN_KEYWORD;
+	  LS_TOKEN_KEYWORD (parser->lexer.current) = keyword;
 	  return parser->lexer.current;
 	}
 
diff --git a/gdb/testsuite/gdb.linespec/ls-errs.exp b/gdb/testsuite/gdb.linespec/ls-errs.exp
index 2d7f63f..236ba56 100644
--- a/gdb/testsuite/gdb.linespec/ls-errs.exp
+++ b/gdb/testsuite/gdb.linespec/ls-errs.exp
@@ -171,6 +171,10 @@ foreach x {"3" "+100" "-100" "foo"} {
     add the_tests "main:here $x" invalid_label "here $x" "main"
 }
 
+foreach x {"if" "task" "thread"} {
+    add the_tests $x unexpected_opt "keyword" $x
+}
+
 # Run the tests
 foreach linespec $the_tests(linespecs) {
     gdb_test "break $linespec" $the_tests("$linespec")


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-13 22:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 22:03 [SCM] archer-keiths-linespec-rewrite: Update/simplification of keywords kseitz

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).