diff options
author | fche <fche> | 2005-03-04 20:10:09 +0000 |
---|---|---|
committer | fche <fche> | 2005-03-04 20:10:09 +0000 |
commit | 0fefb486c5965e371cb52f55548123233da85f72 (patch) | |
tree | d8f847e4fa6972bdd9ff22b180a5f057d52d579e /parse.cxx | |
parent | 8af3da4621b58b8bf39f42f65cac2d6111928fd7 (diff) | |
download | systemtap-steved-0fefb486c5965e371cb52f55548123233da85f72.tar.gz systemtap-steved-0fefb486c5965e371cb52f55548123233da85f72.tar.xz systemtap-steved-0fefb486c5965e371cb52f55548123233da85f72.zip |
2005-03-04 Frank Ch. Eigler <fche@redhat.com>
* parse.cxx (scan): Support '$' characters in identifiers.
(parse_symbol): Support thread-> / process-> shorthand.
* staptree.cxx (symresolution_info::find): Split up into
find_scalar, find_array, find_function.
(resolve_symbols): Call the above for symbol/arrayindex/functioncall.
(find_scalar): Add stub support for synthetic builtin variables.
* staptree.h: Corresponding changes.
* testsuite/*: Some new tests.
Diffstat (limited to 'parse.cxx')
-rw-r--r-- | parse.cxx | 37 |
1 files changed, 33 insertions, 4 deletions
@@ -157,7 +157,7 @@ lexer::scan () if (isspace (c)) goto skip; - else if (isalpha (c)) + else if (isalpha (c) || c == '$') { n->type = tok_identifier; n->content = (char) c; @@ -166,7 +166,7 @@ lexer::scan () int c2 = input.peek (); if (! input) break; - if ((isalnum(c2) || c2 == '_')) + if ((isalnum(c2) || c2 == '_' || c2 == '$')) { n->content.push_back(c2); input_get (); @@ -247,6 +247,7 @@ lexer::scan () (c == '+' && c2 == '=') || (c == '-' && c2 == '=') || (c == ':' && c2 == ':') || + (c == '-' && c2 == '>') || false) // XXX: etc. n->content.push_back((char) input_get ()); @@ -947,8 +948,9 @@ parser::parse_value () } +// var, var[index], func(parms), thread->var, process->var expression* -parser::parse_symbol () // var, var[index], func(parms) +parser::parse_symbol () { const token* t = next (); if (t->type != tok_identifier) @@ -957,7 +959,34 @@ parser::parse_symbol () // var, var[index], func(parms) string name = t->content; t = peek (); - if (t && t->type == tok_operator && t->content == "[") // array + if (t && t->type == tok_operator && t->content == "->") + { + // shorthand for process- or thread-specific array element + // map "thread->VAR" to "VAR[$tid]", + // and "process->VAR" to "VAR[$pid]" + symbol* sym = new symbol; + if (name == "thread") + sym->name = "$tid"; + else if (name == "process") + sym->name = "$pid"; + else + throw parse_error ("expected 'thread->' or 'process->'"); + struct token* t2prime = new token (*t2); + t2prime->content = sym->name; + sym->tok = t2prime; + + next (); // swallow "->" + t = next (); + if (! (t->type == tok_identifier)) + throw parse_error ("expected identifier"); + + struct arrayindex* ai = new arrayindex; + ai->tok = t; + ai->base = t->content; + ai->indexes.push_back (sym); + return ai; + } + else if (t && t->type == tok_operator && t->content == "[") // array { next (); struct arrayindex* ai = new arrayindex; |