summaryrefslogtreecommitdiffstats
path: root/parse.cxx
diff options
context:
space:
mode:
authorfche <fche>2005-06-03 15:54:47 +0000
committerfche <fche>2005-06-03 15:54:47 +0000
commit63a7c90e365874972925e886ed50941f5620bdfe (patch)
tree29977d33b01716551360ecf4b1fdc83df7cc8779 /parse.cxx
parentd8e610f05aafd65e2afef59088db43a2c946680f (diff)
downloadsystemtap-steved-63a7c90e365874972925e886ed50941f5620bdfe.tar.gz
systemtap-steved-63a7c90e365874972925e886ed50941f5620bdfe.tar.xz
systemtap-steved-63a7c90e365874972925e886ed50941f5620bdfe.zip
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.
Diffstat (limited to 'parse.cxx')
-rw-r--r--parse.cxx22
1 files changed, 21 insertions, 1 deletions
diff --git a/parse.cxx b/parse.cxx
index a117d1bc..2e350b4d 100644
--- 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;