Package jflex.core
Class Macros
java.lang.Object
jflex.core.Macros
Symbol table and expander for macros.
Maps macros to their (expanded) definitions, detects cycles and unused macros.
- Version:
- JFlex 1.8.2
- Author:
- Gerwin Klein
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
expand()
Expands all stored macros, so that getDefinition always returns a definition that doesn't contain any macro usages.getDefinition
(String name) Fetches the definition of the macro with the specified name,boolean
Stores a new macro and its definition.boolean
Tests if a macro has been used.boolean
Marks a macro as used.unused()
Returns all unused macros.
-
Constructor Details
-
Macros
public Macros()Creates a new macro expander.
-
-
Method Details
-
insert
Stores a new macro and its definition.- Parameters:
name
- the name of the new macrodefinition
- the definition of the new macro- Returns:
true
, iff the macro name has not been stored before.
-
markUsed
Marks a macro as used.- Parameters:
name
- aString
object.- Returns:
true
, iff the macro name has been stored before.
-
isUsed
Tests if a macro has been used.- Parameters:
name
- aString
object.- Returns:
true
, iff the macro has been used in a regular expression.
-
unused
Returns all unused macros.- Returns:
- the macro names that have not been used.
-
getDefinition
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).
- Parameters:
name
- the name of the macro- Returns:
- the definition of the macro,
null
if no macro with the specified name has been stored. - See Also:
-
expand
Expands all stored macros, so that getDefinition always returns a definition that doesn't contain any macro usages.- Throws:
MacroException
- if there is a cycle in the macro usage graph.
-