]> sourceware.org Git - systemtap.git/commitdiff
2007-12-03 Masami Hiramatsu <mhiramat@redhat.com>
authorhiramatu <hiramatu>
Mon, 3 Dec 2007 21:30:31 +0000 (21:30 +0000)
committerhiramatu <hiramatu>
Mon, 3 Dec 2007 21:30:31 +0000 (21:30 +0000)
PR 5376
* parse.cxx (lexer::scan): Treat '*' as an alphabet if the wildcard
flag is true.
(parser::parse_probe_point): Call parser::next() with wildcard = true.
(parser::scan_pp): Add wildcard flag and pass it to lexer::scan.
(parser::next): Ditto.
(parser::peek): Ditto.
* parse.h : Ditto.
* testsuites/perseko/twentytwo.stp: Change testcase to the wildcarded
probe points with spaces.

ChangeLog
parse.cxx
parse.h
testsuite/ChangeLog
testsuite/parseko/twentytwo.stp

index 1d26a4f11732b139ffbc7c0a8cb6b998347f7b8d..6bf0ad7299682dcfce83434df9990b894f6ee522 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-12-03  Masami Hiramatsu  <mhiramat@redhat.com>
+
+       PR 5376
+       * parse.cxx (lexer::scan): Treat '*' as an alphabet if the wildcard
+       flag is true.
+       (parser::parse_probe_point): Call parser::next() with wildcard = true.
+       (parser::scan_pp): Add wildcard flag and pass it to lexer::scan.
+       (parser::next): Ditto.
+       (parser::peek): Ditto.
+       * parse.h : Ditto.
+
 2007-12-01  Frank Ch. Eigler  <fche@elastic.org>
 
        * gen-stapmark.h, stapmark.h: Retire.
index 2732194c5f64a86859775270cf88ce538fa86e56..2aca32fbe47ffad6973a144c680f71709c507d35 100644 (file)
--- a/parse.cxx
+++ b/parse.cxx
@@ -263,7 +263,7 @@ bool eval_pp_conditional (systemtap_session& s,
 // expand_args is used to know if we must expand $x and @x identifiers.
 // Only tokens corresponding to the TRUE statement must be expanded
 const token*
-parser::scan_pp (bool expand_args)
+parser::scan_pp (bool wildcard, bool expand_args)
 {
   while (true)
     {
@@ -274,7 +274,7 @@ parser::scan_pp (bool expand_args)
           return t;
         }
 
-      const token* t = input.scan (expand_args); // NB: not recursive!
+      const token* t = input.scan (wildcard, expand_args); // NB: not recursive!
       if (t == 0) // EOF
         return t;
       
@@ -284,9 +284,9 @@ parser::scan_pp (bool expand_args)
       // We have a %( - it's time to throw a preprocessing party!
 
       const token *l, *op, *r;
-      l = input.scan (expand_args); // NB: not recursive, though perhaps could be
-      op = input.scan (expand_args);
-      r = input.scan (expand_args);
+      l = input.scan (false, expand_args); // NB: not recursive, though perhaps could be
+      op = input.scan (false, expand_args);
+      r = input.scan (false, expand_args);
       if (l == 0 || op == 0 || r == 0)
         throw parse_error ("incomplete condition after '%('", t);
       // NB: consider generalizing to consume all tokens until %?, and
@@ -309,7 +309,7 @@ parser::scan_pp (bool expand_args)
       
       while (true) // consume THEN tokens
         {
-          m = scan_pp (result); // NB: recursive
+          m = scan_pp (wildcard, result); // NB: recursive
           if (m == 0)
             throw parse_error (have_token ?
                                "incomplete conditional - missing %: or %)" :
@@ -334,7 +334,7 @@ parser::scan_pp (bool expand_args)
           delete m; // "%:"
           while (true)
             {
-              m = scan_pp (expand_args && !result); // NB: recursive
+              m = scan_pp (wildcard, expand_args && !result); // NB: recursive
               if (m == 0)
                  throw parse_error (have_token ?
                                      "incomplete conditional - missing %)" :
@@ -372,10 +372,10 @@ parser::scan_pp (bool expand_args)
 
 
 const token*
-parser::next ()
+parser::next (bool wildcard)
 {
   if (! next_t)
-    next_t = scan_pp ();
+    next_t = scan_pp (wildcard);
   if (! next_t)
     throw parse_error ("unexpected end-of-file");
 
@@ -387,10 +387,10 @@ parser::next ()
 
 
 const token*
-parser::peek ()
+parser::peek (bool wildcard)
 {
   if (! next_t)
-    next_t = scan_pp ();
+    next_t = scan_pp (wildcard);
 
   // don't advance by zeroing next_t
   last_t = next_t;
@@ -574,7 +574,7 @@ lexer::input_put (const string& chars)
 
 
 token*
-lexer::scan (bool expand_args)
+lexer::scan (bool wildcard, bool expand_args)
 {
   token* n = new token;
   n->location.file = input_name;
@@ -645,11 +645,13 @@ lexer::scan (bool expand_args)
       goto semiskip;
     }
 
-  else if (isalpha (c) || c == '$' || c == '@' || c == '_')
+  else if (isalpha (c) || c == '$' || c == '@' || c == '_' ||
+          (wildcard && c == '*'))
     {
       n->type = tok_identifier;
       n->content = (char) c;
-      while (isalnum (c2) || c2 == '_' || c2 == '$')
+      while (isalnum (c2) || c2 == '_' || c2 == '$' ||
+            (wildcard && c2 == '*'))
        {
           input_get ();
           n->content.push_back (c2);
@@ -1289,11 +1291,10 @@ parser::parse_probe_point ()
 
   while (1)
     {
-      const token* t = next ();
+      const token* t = next (true); // wildcard scanning here
       if (! (t->type == tok_identifier
             // we must allow ".return" and ".function", which are keywords
-            || t->type == tok_keyword
-            || (t->type == tok_operator && t->content == "*")))
+            || t->type == tok_keyword))
         throw parse_error ("expected identifier or '*'");
 
       if (pl->tok == 0) pl->tok = t;
@@ -1303,28 +1304,8 @@ parser::parse_probe_point ()
       pl->components.push_back (c);
       // NB we may add c->arg soon
 
-      const token* last_t = t;
       t = peek ();
 
-      // We need to keep going until we find something other than a
-      // '*' or identifier, since a probe point wildcard can be
-      // something like "*a", "*a*", "a*b", "a*b*", etc.
-      while (t &&
-            // case 1: '*{identifier}'
-            ((last_t->type == tok_operator && last_t->content == "*"
-              && (t->type == tok_identifier || t->type == tok_keyword))
-             // case 2: '{identifier}*'
-             || ((last_t->type == tok_identifier
-                  || last_t->type == tok_keyword)
-                 && t->type == tok_operator && t->content == "*")))
-        {
-         c->functor += t->content;
-         next ();                      // consume the identifier or '*'
-
-         last_t = t;
-         t = peek ();
-       }
-
       // consume optional parameter
       if (t && t->type == tok_operator && t->content == "(")
         {
diff --git a/parse.h b/parse.h
index c81559dd9d7abd0b2519a85eb1d3628aff2d3401..557fa4c55cec83c1e4872e90d9c780bd1e2d36e8 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -69,7 +69,7 @@ struct systemtap_session;
 class lexer
 {
 public:
-  token* scan (bool expand_args=true);
+  token* scan (bool wildcard=false, bool expand_args=true);
   lexer (std::istream&, const std::string&, systemtap_session&);
 
 private:
@@ -132,12 +132,12 @@ private:
 
   // preprocessing subordinate
   std::vector<const token*> enqueued_pp;
-  const token* scan_pp (bool expand_args=true);
+  const token* scan_pp (bool wildcard=false, bool expand_args=true);
 
   // scanning state
   const token* last ();
-  const token* next ();
-  const token* peek ();
+  const token* next (bool wildcard=false);
+  const token* peek (bool wildcard=false);
 
   const token* last_t; // the last value returned by peek() or next()
   const token* next_t; // lookahead token
index dd7234adcdcf8dc74460f93d9047f20937959708..843dd90ef84606d0d3bf1416e9930417576f4eb3 100644 (file)
@@ -1,3 +1,9 @@
+2007-12-03  Masami Hiramatsu  <mhiramat@redhat.com>
+
+       PR 5376
+       * perseko/twentytwo.stp: Change testcase to the wildcarded probe
+       points with spaces.
+
 2007-11-29  David Smith  <dsmith@redhat.com>
 
        * systemtap.base/marker.exp: Gets marker list from
index a5434355f49c452625bf6eba8cdabf13bd1fd25e..3b1b7d5aae6d143764f3dab3563aaa01d40d75dc 100755 (executable)
@@ -1,5 +1,5 @@
 #! stap -p1
 
-# bad wildcard
+# wildcard with space
 
-probe a** { }
+probe a * b { }
This page took 0.04562 seconds and 5 git commands to generate.