]> sourceware.org Git - systemtap.git/commitdiff
2005-06-03 Frank Ch. Eigler <fche@redhat.com>
authorfche <fche>
Fri, 3 Jun 2005 15:54:47 +0000 (15:54 +0000)
committerfche <fche>
Fri, 3 Jun 2005 15:54:47 +0000 (15:54 +0000)
* parse.cxx (scan): Support C and C++ comment styles.
* testsuite/parseok/four.stp: Test them some ...
* testsuite/parseko/nine.stp: ... and some more.

ChangeLog
main.cxx
parse.cxx
testsuite/parseko/nine.stp [new file with mode: 0755]
testsuite/parseok/four.stp

index ee3c57314ec418c2d8fed532d85d098dea2fc02a..f7c7e1dbf9eb81b0351d72a5cbb55bdecdfd4c8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-06-03  Frank Ch. Eigler  <fche@redhat.com>
+
+       * parse.cxx (scan): Support C and C++ comment styles.
+       * testsuite/parseok/four.stp: Test them some ...
+       * testsuite/parseko/nine.stp: ... and some more.
+
 2005-06-02  Frank Ch. Eigler  <fche@redhat.com>
 
        * translate.cxx (visit_concatenation, visit_binary_expression):
index e9f191bbd036a973fdea52474337269f6966099d..1de145766b0c4fa5f8136452aafabf3c8215fdad 100644 (file)
--- a/main.cxx
+++ b/main.cxx
@@ -40,7 +40,7 @@ void usage ()
   cerr << "   -p NUM\tStop after pass NUM 1-3" << endl;
   cerr << "         \t(parse, elaborate, translate)" << endl;
   cerr << "   -I DIR\tLook in DIR for additional .stp script files." << endl;
-  cerr << "   -o FILE\tSend translator output to file instead of stdout." << endl;
+  cerr << "   -o FILE\tSend output to file instead of stdout." << endl;
   // XXX: other options:
   // -s: safe mode
   // -d: dump safety-related external references 
index a117d1bcbf6198edb4896cf2abfae2be874847e4..2e350b4d206150b147446e55c696760e61002c10 100644 (file)
--- a/parse.cxx
+++ b/parse.cxx
@@ -253,13 +253,33 @@ lexer::scan ()
     {
       int c2 = input.peek ();
 
-      if (c == '#') // comment to end-of-line
+      if (c == '#') // shell comment
         {
           unsigned this_line = cursor_line;
           while (input && cursor_line == this_line)
             input_get ();
           goto skip;
         }
+      else if (c == '/' && c2 == '/') // C++ comment
+        {
+          unsigned this_line = cursor_line;
+          while (input && cursor_line == this_line)
+            input_get ();
+          goto skip;
+        }
+      else if (c == '/' && c2 == '*') // C comment
+       {
+          c2 = input_get ();
+          unsigned chars = 0;
+          while (input)
+            {
+              chars ++; // track this to prevent "/*/" from being accepted
+              c = c2;
+              c2 = input_get ();
+              if (chars > 1 && c == '*' && c2 == '/')
+                goto skip;
+            }
+       }
 
       n->type = tok_operator;
       n->content = (char) c;
diff --git a/testsuite/parseko/nine.stp b/testsuite/parseko/nine.stp
new file mode 100755 (executable)
index 0000000..438824c
--- /dev/null
@@ -0,0 +1,4 @@
+#! stap -p1
+probe foo {
+  /*/ 0
+}
index 39c9ebd4e4710781012e6859421d15485fefecff..9d7a87298a506c211dea0e2b61b65a5b29c3da0c 100755 (executable)
@@ -1,7 +1,10 @@
 #! stap -p1
 
 probe syscall ("foo").foo.bar , syscall ("bar"), syscall ("*").return
-{
-  $a = a$a = a$a$ = 0;
+{ # no comment
+  $a = /* comment */ a$a = /**/ a$a$ = 0; // more comment
 }
-
+/* empty comment lines */
+/**/
+#
+//
This page took 0.04424 seconds and 5 git commands to generate.