public final class Macros
extends java.lang.Object
Constructor and Description |
---|
Macros()
Creates a new macro expander.
|
Modifier and Type | Method and Description |
---|---|
void |
expand()
Expands all stored macros, so that getDefinition always returns
a defintion that doesn't contain any macro usages.
|
RegExp |
getDefinition(java.lang.String name)
Fetches the definition of the macro with the specified name,
|
boolean |
insert(java.lang.String name,
RegExp definition)
Stores a new macro and its definition.
|
boolean |
isUsed(java.lang.String name)
Tests if a macro has been used.
|
boolean |
markUsed(java.lang.String name)
Marks a makro as used.
|
java.util.Enumeration |
unused()
Returns all unused macros.
|
public boolean insert(java.lang.String name, RegExp definition)
name
- the name of the new macrodefinition
- the definition of the new macrotrue
, iff the macro name has not been
stored before.public boolean markUsed(java.lang.String name)
true
, iff the macro name has been
stored before.public boolean isUsed(java.lang.String name)
true
, iff the macro has been used in
a regular expression.public java.util.Enumeration unused()
public RegExp getDefinition(java.lang.String name)
The definition will either be the same as stored (expand() not called), or an equivalent one, that doesn't contain any macro usages (expand() called before).
name
- the name of the macronull
if
no macro with the specified name has been stored.expand()
public void expand() throws MacroException
MacroException
- if there is a cycle in the macro usage graph.