public final class Macros extends 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(String name)
Fetches the definition of the macro with the specified name,
|
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.
|
List<String> |
unused()
Returns all unused macros.
|
public boolean insert(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(String name)
true
, iff the macro name has been
stored before.public boolean isUsed(String name)
true
, iff the macro has been used in
a regular expression.public List<String> unused()
public RegExp getDefinition(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.Copyright © 1998–2016. All rights reserved.