How can I get the code in the begin block to evaluate BEFORE the compound-stmt?
You can't.
The documentation says:
Each action is Racket code that has the same scope as its parser’s definition, except that the variables $1, ..., $i are bound, where i is the number of grammar-ids in the corresponding production. Each $k is bound to the result of the action for the kth grammar symbol on the right of the production, if that grammar symbol is a non-terminal, or the value stored in the token if the grammar symbol is a terminal.
It sounds as if you are attempting to write a one-pass compiler.
The solution to your problem, is to write a two-pass compiler instead.
The first pass is the parsing. The parser must generate a temporary data structure representing the parsed code (i.e. an abstract syntax tree, AST). In the second pass you use the tree representation to generate code.