NAME ^

src/macro.imc - does macro substitution

DESCRIPTION ^

Copyright: 2004 Bernhard Schmalhofer. All Rights Reserved. CVS Info: $Id$ History: Ported from GNU m4 1.4 References: http://www.gnu.org/software/m4/m4.html

SUBROUTINES ^

void _expand_input( PerlHash state ) ^

Loop through some input files. TODO: read files in next_token()

void _expand_token( PerlHash state, string token_type, string token_data ) ^

Expand one token, according to its type. Potential macro names (TOKEN_WORD) are looked up in the symbol table, to see if they have a macro definition. If they have, they are expanded as macros, otherwise the text are just copied to the output.

string processed_token _expand_macro( PerlHash state, PerlHash symbol ) ^

The macro expansion is handled by expand_macro(). It parses the arguments, using collect_arguments(), and builds a PerlArray containing the arguments. The arguments themselves are stored on a local obstack. Expand_macro() uses call_macro() to do the call of the macro.

Expand_macro() is potentially recursive, since it calls expand_argument(), which might call expand_token (), which might call expand_macro().

string processed_token _call_macro( PerlArray macro, string token ) ^

Apply macro to a token.

TODO: distinguish between TOKEN_FUNC and TOKEN_WORD

void _collect_arguments ^

Collect all the arguments to a call of a macro.


parrot