From 6e3347a9815f4a457b6393a22f21b6f2c6b588af Mon Sep 17 00:00:00 2001 From: fche Date: Fri, 2 Jun 2006 18:09:29 +0000 Subject: 2006-06-02 Frank Ch. Eigler PR 2645. * stapprobes.5.in: Document "?" probe point suffix. * parse.cxx (parse_probe_point): Recognize "?" optional suffix. * elaborate.cxx (derive_probes): Observe probe_point->optional. * staptree.h, staptree.cxx: Corresponding changes. * tapsets.cxx (never_derived_probe, never_builder): New classes. (register_standard_tapsets): Support "never" probe point. * testsuite/buildok/six.stp, parseok/five.stp: Modifed tests. * translate.cxx (emit_module_init): Format "-t" (benchmarking) cycle-time reports similarly to "-v" (verbose) times. --- parse.cxx | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'parse.cxx') diff --git a/parse.cxx b/parse.cxx index cc1638fa..a6a90412 100644 --- a/parse.cxx +++ b/parse.cxx @@ -1140,7 +1140,7 @@ parser::parse_probe_point () probe_point::component* c = new probe_point::component; c->functor = t->content; pl->components.push_back (c); - // NB though we still may add c->arg soon + // NB we may add c->arg soon const token* last_t = t; t = peek (); @@ -1164,11 +1164,7 @@ parser::parse_probe_point () t = peek (); } - if (t && t->type == tok_operator - && (t->content == "{" || t->content == "," || t->content == "=" - || t->content == "+=" )) - break; - + // consume optional parameter if (t && t->type == tok_operator && t->content == "(") { next (); // consume "(" @@ -1179,19 +1175,31 @@ parser::parse_probe_point () throw parse_error ("expected ')'"); t = peek (); - if (t && t->type == tok_operator - && (t->content == "{" || t->content == "," || t->content == "=")) - break; - else if (t && t->type == tok_operator && - t->content == "(") - throw parse_error ("unexpected '.' or ',' or '{'"); } - // fall through if (t && t->type == tok_operator && t->content == ".") - next (); - else - throw parse_error ("expected '.' or ',' or '(' or '{' or '=' or '+='"); + { + next (); + continue; + } + + // We only fall through here at the end of a probe point (past + // all the dotted/parametrized components). + + if (t && t->type == tok_operator && t->content == "?") + { + pl->optional = true; + next (); + t = peek (); + // fall through + } + + if (t && t->type == tok_operator + && (t->content == "{" || t->content == "," || + t->content == "=" || t->content == "+=" )) + break; + + throw parse_error ("expected '.' or ',' or '(' or '?' or '{' or '=' or '+='"); } return pl; -- cgit