"only" now a report query modifier for --only

This fits with "show" and "bold", etc.
This commit is contained in:
John Wiegley 2010-06-24 00:30:18 -04:00
parent eda6cbd014
commit 129b2de901
3 changed files with 31 additions and 20 deletions

View file

@ -186,6 +186,8 @@ test_ident:
return token_t(token_t::TOK_META);
else if (ident == "show")
return token_t(token_t::TOK_SHOW);
else if (ident == "only")
return token_t(token_t::TOK_ONLY);
else if (ident == "bold")
return token_t(token_t::TOK_BOLD);
else if (ident == "for")
@ -249,6 +251,7 @@ query_t::parser_t::parse_query_term(query_t::lexer_t::token_t::kind_t tok_contex
lexer_t::token_t tok = lexer.next_token();
switch (tok.kind) {
case lexer_t::token_t::TOK_SHOW:
case lexer_t::token_t::TOK_ONLY:
case lexer_t::token_t::TOK_BOLD:
case lexer_t::token_t::TOK_FOR:
case lexer_t::token_t::TOK_SINCE:
@ -452,9 +455,26 @@ query_t::parser_t::parse_query_expr(lexer_t::token_t::kind_t tok_context,
lexer_t::token_t tok = lexer.peek_token();
while (tok.kind != lexer_t::token_t::END_REACHED) {
switch (tok.kind) {
case lexer_t::token_t::TOK_SHOW: {
case lexer_t::token_t::TOK_SHOW:
case lexer_t::token_t::TOK_ONLY:
case lexer_t::token_t::TOK_BOLD: {
lexer.next_token();
kind_t kind;
switch (tok.kind) {
case lexer_t::token_t::TOK_SHOW:
kind = QUERY_SHOW;
break;
case lexer_t::token_t::TOK_ONLY:
kind = QUERY_ONLY;
break;
case lexer_t::token_t::TOK_BOLD:
kind = QUERY_BOLD;
break;
default:
break;
}
expr_t::ptr_op_t node;
while (expr_t::ptr_op_t next = parse_or_expr(tok_context)) {
if (! node) {
@ -470,25 +490,7 @@ query_t::parser_t::parse_query_expr(lexer_t::token_t::kind_t tok_context,
if (node)
query_map.insert
(query_map_t::value_type
(QUERY_SHOW, predicate_t(node, what_to_keep).print_to_str()));
break;
}
case lexer_t::token_t::TOK_BOLD: {
lexer.next_token();
expr_t::ptr_op_t node = parse_or_expr(tok_context);
while (expr_t::ptr_op_t next = parse_or_expr(tok_context)) {
expr_t::ptr_op_t prev(node);
node = new expr_t::op_t(expr_t::op_t::O_OR);
node->set_left(prev);
node->set_right(next);
}
if (node)
query_map.insert
(query_map_t::value_type
(QUERY_BOLD, predicate_t(node, what_to_keep).print_to_str()));
(kind, predicate_t(node, what_to_keep).print_to_str()));
break;
}

View file

@ -90,6 +90,7 @@ public:
TOK_EXPR,
TOK_SHOW,
TOK_ONLY,
TOK_BOLD,
TOK_FOR,
TOK_SINCE,
@ -144,6 +145,7 @@ public:
case TOK_META: return "TOK_META";
case TOK_EXPR: return "TOK_EXPR";
case TOK_SHOW: return "TOK_SHOW";
case TOK_ONLY: return "TOK_ONLY";
case TOK_BOLD: return "TOK_BOLD";
case TOK_FOR: return "TOK_FOR";
case TOK_SINCE: return "TOK_SINCE";
@ -170,6 +172,7 @@ public:
case TOK_META: return "meta";
case TOK_EXPR: return "expr";
case TOK_SHOW: return "show";
case TOK_ONLY: return "only";
case TOK_BOLD: return "bold";
case TOK_FOR: return "for";
case TOK_SINCE: return "since";
@ -234,6 +237,7 @@ public:
enum kind_t {
QUERY_LIMIT,
QUERY_SHOW,
QUERY_ONLY,
QUERY_BOLD,
QUERY_FOR
};

View file

@ -267,6 +267,11 @@ void report_t::parse_query_args(const value_t& args, const string& whence)
DEBUG("report.predicate", "Limit predicate = " << HANDLER(limit_).str());
}
if (query.has_query(query_t::QUERY_ONLY)) {
HANDLER(only_).on(whence, query.get_query(query_t::QUERY_ONLY));
DEBUG("report.predicate", "Only predicate = " << HANDLER(only_).str());
}
if (query.has_query(query_t::QUERY_SHOW)) {
HANDLER(display_).on(whence, query.get_query(query_t::QUERY_SHOW));
DEBUG("report.predicate", "Display predicate = " << HANDLER(display_).str());