void insertMacros ( TokenList tokens ) { TokenList . Token t = tokens . getFirst ( ) ; while ( t != null ) { if ( t . getType ( ) == Type . WORD ) { Macro v = lookupMacro ( t . word ) ; if ( v != null ) { TokenList . Token before = t . previous ; List < TokenList . Token > inputs = new ArrayList < TokenList . Token > ( ) ; t = parseMacroInput ( inputs , t . next ) ; TokenList sniplet = v . execute ( inputs ) ; tokens . extractSubList ( before . next , t ) ; tokens . insertAfter ( before , sniplet ) ; t = sniplet . last ; } } t = t . next ; } }
Checks to see if a WORD matches the name of a macro . if it does it applies the macro at that location