summaryrefslogtreecommitdiffstats
path: root/parse.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-07-31 13:46:54 -0700
committerJosh Stone <jistone@redhat.com>2009-07-31 17:08:07 -0700
commit81931eaba5dcd0727f33328bf4b0ff511b791990 (patch)
tree398784156586dfe4bb1de23f09d1530c3f664e54 /parse.cxx
parent8eb285ac4ec3a34b29ebf20fde0e28cc647d940f (diff)
downloadsystemtap-steved-81931eaba5dcd0727f33328bf4b0ff511b791990.tar.gz
systemtap-steved-81931eaba5dcd0727f33328bf4b0ff511b791990.tar.xz
systemtap-steved-81931eaba5dcd0727f33328bf4b0ff511b791990.zip
Refactor parser for target_symbol->components
The components were being parsed for both target_symbols and cast_ops, so this change refactors that code into a single function. * parse.cxx (parser::parse_target_symbol_components): New. (parser::parse_symbol): Use the new function.
Diffstat (limited to 'parse.cxx')
-rw-r--r--parse.cxx72
1 files changed, 30 insertions, 42 deletions
diff --git a/parse.cxx b/parse.cxx
index 35c78abe..29d97589 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -2346,27 +2346,8 @@ parser::parse_symbol ()
expect_unknown(tok_string, cop->module);
}
expect_op(")");
- while (true)
- {
- string c;
- if (peek_op ("->"))
- {
- next();
- expect_ident_or_keyword (c);
- cop->components.push_back
- (make_pair (target_symbol::comp_struct_member, c));
- }
- else if (peek_op ("["))
- {
- next();
- expect_unknown (tok_number, c);
- expect_op ("]");
- cop->components.push_back
- (make_pair (target_symbol::comp_literal_array_index, c));
- }
- else
- break;
- }
+ parse_target_symbol_components(cop);
+
// if there aren't any dereferences, then the cast is pointless
if (cop->components.empty())
{
@@ -2494,27 +2475,7 @@ parser::parse_symbol ()
target_symbol *tsym = new target_symbol;
tsym->tok = t;
tsym->base_name = name;
- while (true)
- {
- string c;
- if (peek_op ("->"))
- {
- next();
- expect_ident_or_keyword (c);
- tsym->components.push_back
- (make_pair (target_symbol::comp_struct_member, c));
- }
- else if (peek_op ("["))
- {
- next();
- expect_unknown (tok_number, c);
- expect_op ("]");
- tsym->components.push_back
- (make_pair (target_symbol::comp_literal_array_index, c));
- }
- else
- break;
- }
+ parse_target_symbol_components(tsym);
return tsym;
}
@@ -2604,4 +2565,31 @@ parser::parse_symbol ()
return sym;
}
+
+void
+parser::parse_target_symbol_components (target_symbol* e)
+{
+ while (true)
+ {
+ string c;
+ if (peek_op ("->"))
+ {
+ next();
+ expect_ident_or_keyword (c);
+ e->components.push_back
+ (make_pair (target_symbol::comp_struct_member, c));
+ }
+ else if (peek_op ("["))
+ {
+ next();
+ expect_unknown (tok_number, c);
+ expect_op ("]");
+ e->components.push_back
+ (make_pair (target_symbol::comp_literal_array_index, c));
+ }
+ else
+ break;
+ }
+}
+
/* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */