The MacroTable is used by the TextScanner to store defined macros and resolve them on request later on. A macro is a text pattern that has a name. The pattern may contain variable parts that are replaced by arguments passed during the macro call.
Add a new macro definition to the table or replace an existing one.
# File lib/MacroTable.rb, line 43 43: def add(macro) 44: @macros[macro.name] = macro 45: end
Remove all definitions from the table.
# File lib/MacroTable.rb, line 48 48: def clear 49: @macros = [] 50: end
This function sends an error message to the message handler.
# File lib/MacroTable.rb, line 76 76: def error(id, text, sourceFileInfo) 77: @messageHandler.error(id, text, sourceFileInfo) 78: end
Returns true only if a macro named name is defined in the table.
# File lib/MacroTable.rb, line 53 53: def include?(name) 54: @macros.include?(name) 55: end
Returns the definition of the macro specified by name as first entry of args. The other entries of args are parameters that are replacing the ${n} tokens in the macro definition. In case the macro call has less arguments than the macro definition uses, the ${n} tokens remain unchanged. No error is generated.
# File lib/MacroTable.rb, line 62 62: def resolve(args, sourceFileInfo) 63: name = args[0] 64: return nil unless @macros[name] 65: 66: resolved = @macros[name].value.dup 67: i = 0 68: args.each do |arg| 69: resolved.gsub!("${#{i}}", arg) 70: i += 1 71: end 72: [ @macros[name], resolved ] 73: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.