Checking variable scope - progress and questions
Rob Quill
rob.quill@gmail.com
Sun Jan 14 14:11:00 GMT 2007
Hi,
I have been modifying the c-exp.y grammer, to allow expressions of the form:
$in_scope(a)
evaluating to 1, when the variable a is in scope, and 0 when it is not.
The implementation I have currently set a global vaibale check_scope
to 1, when a $in_scope token is parsed. There is then an if statement
in the 'variable' production rules, checking if check_scope is 1, and
doing as follows if it is:
YYSTYPE val;
parse_number ("0", 1, 0, &val);
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (val.typed_val_int.type);
write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
write_exp_elt_opcode (OP_LONG);
With the string being passed to parse_number being 1 fi the variable
is in scope and 0 if it is not.
This currently works perfectly for doing things of the form
$in_scope(x)
But I am having difficulty getting it to work for expressions of the form
$in_scope(x.y)
Becuase I can't find the place in the grammar when it is checked if
this is in scope.
If anyone is willing to take a look at the code, if that makes it
easier to understand then I am happy to send the modified c-exp.y
Thanks for your help.
Rob
More information about the Gdb
mailing list