summaryrefslogtreecommitdiffstats
path: root/parse.cxx
diff options
context:
space:
mode:
authordsmith <dsmith>2006-11-06 16:05:50 +0000
committerdsmith <dsmith>2006-11-06 16:05:50 +0000
commit27f21e8c049b0cd20fd2d4e2fd9b96cad6c910cc (patch)
tree78fad282ce4f36ad50a3b944d6c659941591d5f6 /parse.cxx
parenta90b629e6fe7420caeb0f7494f712c9664afbdc8 (diff)
downloadsystemtap-steved-27f21e8c049b0cd20fd2d4e2fd9b96cad6c910cc.tar.gz
systemtap-steved-27f21e8c049b0cd20fd2d4e2fd9b96cad6c910cc.tar.xz
systemtap-steved-27f21e8c049b0cd20fd2d4e2fd9b96cad6c910cc.zip
2006-11-06 David Smith <dsmith@redhat.com>
Added "limit EXP" support to foreach statements. * translate.cxx (c_tmpcounter::visit_foreach_loop): Handles "limit" member variable. (c_unparser::visit_foreach_loop): Ditto. * staptree.cxx (foreach_loop::print): Prints "limit EXP" addition. (traversing_visitor::visit_foreach_loop): Handles "limit" member variable. (deep_copy_visitor::visit_foreach_loop): Ditto. * staptree.h (struct foreach_loop): Added "limit" member variable. * stap.1.in: Added documentation for the "limit EXP" addition to foreach statement. * parse.cxx (lexer::scan): Added "limit" keyword for foreach statements. (parser::parse_foreach_loop): Parses "limit" keyword for foreach statements. * elaborate.cxx (symresolution_info::visit_foreach_loop): Handles "limit" member variable. (typeresolution_info::visit_foreach_loop): Ditto.
Diffstat (limited to 'parse.cxx')
-rw-r--r--parse.cxx9
1 files changed, 9 insertions, 0 deletions
diff --git a/parse.cxx b/parse.cxx
index 2d31e334..dd41a259 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -543,6 +543,7 @@ lexer::scan ()
|| n->content == "for"
|| n->content == "foreach"
|| n->content == "in"
+ || n->content == "limit"
|| n->content == "return"
|| n->content == "delete"
|| n->content == "while"
@@ -1518,6 +1519,7 @@ parser::parse_foreach_loop ()
foreach_loop* s = new foreach_loop;
s->tok = t;
s->sort_direction = 0;
+ s->limit = NULL;
t = next ();
if (! (t->type == tok_operator && t->content == "("))
@@ -1591,6 +1593,13 @@ parser::parse_foreach_loop ()
next();
}
+ t = peek ();
+ if (tok_is(t, tok_keyword, "limit"))
+ {
+ next (); // get past the "limit"
+ s->limit = parse_expression ();
+ }
+
t = next ();
if (! (t->type == tok_operator && t->content == ")"))
throw parse_error ("expected ')'");