JFlex
Class Macros
public final class Macros
extends java.lang.Object
Symbol table and expander for macros.
Maps macros to their (expanded) definitions, detects cycles and
unused macros.
Macros() - Creates a new macro expander.
|
void | expand() - Expands all stored macros, so that getDefinition always returns
a defintion that doesn't contain any macro usages.
|
RegExp | getDefinition(String name) - Fetches the definition of the macro with the specified 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).
|
boolean | insert(String name, RegExp definition) - Stores a new macro and its definition.
|
boolean | isUsed(String name) - Tests if a macro has been used.
|
boolean | markUsed(String name) - Marks a makro as used.
|
Enumeration | unused() - Returns all unused macros.
|
Macros
public Macros()
Creates a new macro expander.
expand
public void expand()
throws MacroException
Expands all stored macros, so that getDefinition always returns
a defintion that doesn't contain any macro usages.
getDefinition
public RegExp getDefinition(String name)
Fetches the definition of the macro with the specified 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 macro
- the definition of the macro,
null
if
no macro with the specified name has been stored.
insert
public boolean insert(String name,
RegExp definition)
Stores a new macro and its definition.
name
- the name of the new macrodefinition
- the definition of the new macro
true
, iff the macro name has not been
stored before.
isUsed
public boolean isUsed(String name)
Tests if a macro has been used.
true
, iff the macro has been used in
a regular expression.
markUsed
public boolean markUsed(String name)
Marks a makro as used.
true
, iff the macro name has been
stored before.
unused
public Enumeration unused()
Returns all unused macros.
- the enumeration of macro names that have not been used.