summaryrefslogtreecommitdiffstats
path: root/parse.cxx
diff options
context:
space:
mode:
authorfche <fche>2005-10-07 19:09:02 +0000
committerfche <fche>2005-10-07 19:09:02 +0000
commit934845563af3c85df78c17ee4752caa100ea6157 (patch)
tree1bba25b9e1e6c035720a8115c4fb212306453a8f /parse.cxx
parent9f0f2d3f93a63c91f817fda7e4e4cd02884a9084 (diff)
downloadsystemtap-steved-934845563af3c85df78c17ee4752caa100ea6157.tar.gz
systemtap-steved-934845563af3c85df78c17ee4752caa100ea6157.tar.xz
systemtap-steved-934845563af3c85df78c17ee4752caa100ea6157.zip
2005-10-07 Frank Ch. Eigler <fche@elastic.org>
PR 1366. * staptree.h (foreach_loop): Add sort_column, sort_direction fields. * parse.cxx (parse_foreach_loop): Parse "+"/"-" suffix operators. * stap.1.in, stapex.5.in: Document them. * staptree.cxx (foreach_loop print, copy): Propagate them. * translate.cxx (visit_foreach_loop): Support them. * testsuite/parseok/fifteen.stp, parseko/thirteen.stp, buildok/twentyone.stp: Test them. 2005-10-07 Frank Ch. Eigler <fche@elastic.org> PR 1366. * systemtap.samples/primes.*: Sort foreach gratuitiously.
Diffstat (limited to 'parse.cxx')
-rw-r--r--parse.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/parse.cxx b/parse.cxx
index 9f714359..bbb209b8 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -1148,6 +1148,7 @@ parser::parse_foreach_loop ()
throw parse_error ("expected 'foreach'");
foreach_loop* s = new foreach_loop;
s->tok = t;
+ s->sort_direction = 0;
t = next ();
if (! (t->type == tok_operator && t->content == "("))
@@ -1173,9 +1174,20 @@ parser::parse_foreach_loop ()
sym->name = t->content;
s->indexes.push_back (sym);
+ t = peek ();
+ if (t && t->type == tok_operator &&
+ (t->content == "+" || t->content == "-"))
+ {
+ if (s->sort_direction)
+ throw parse_error ("multiple sort directives");
+ s->sort_direction = (t->content == "+") ? 1 : -1;
+ s->sort_column = s->indexes.size();
+ next();
+ }
+
if (parenthesized)
{
- const token* t = peek ();
+ t = peek ();
if (t && t->type == tok_operator && t->content == ",")
{
next ();
@@ -1202,6 +1214,17 @@ parser::parse_foreach_loop ()
throw parse_error ("expected identifier");
s->base = t->content;
+ t = peek ();
+ if (t && t->type == tok_operator &&
+ (t->content == "+" || t->content == "-"))
+ {
+ if (s->sort_direction)
+ throw parse_error ("multiple sort directives");
+ s->sort_direction = (t->content == "+") ? 1 : -1;
+ s->sort_column = 0;
+ next();
+ }
+
t = next ();
if (! (t->type == tok_operator && t->content == ")"))
throw parse_error ("expected ')'");