parrotcode: does macro substitution | |
Contents | Language Implementations | M4 |
src/macro.pir - does macro substitution
Copyright: 2004-2005 Bernhard Schmalhofer. All Rights Reserved. SVN Info: $Id$ History: Ported from GNU m4 1.4 References: http://www.gnu.org/software/m4/m4.html
Loop through some input files. TODO: read files in next_token()
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.
The macro expansion is handled by expand_macro(). It parses the arguments in collect_arguments() and builds a ResizablePMCArray 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().
Apply macro to a token.
TODO: distinguish between TOKEN_FUNC and TOKEN_WORD
Collect all the arguments to a call of a macro.
|