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.9.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexpand()Expands all stored macros, so that getDefinition always returns a definition that doesn't contain any macro usages.private RegExpexpandMacro(String name, RegExp definition) Expands the specified macro by replacing each macro usage with the stored definition.getDefinition(String name) Fetches the definition of the macro with the specified name,booleanStores a new macro and its definition.booleanTests if a macro has been used.booleanMarks a macro as used.unused()Returns all unused macros.
-
Field Details
-
macros
-
used
-
-
Constructor Details
-
Macros
public Macros()Creates a new macro expander.
-
-
Method Details
-
insert
-
markUsed
-
isUsed
-
unused
-
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,
nullif 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.
-
expandMacro
Expands the specified macro by replacing each macro usage with the stored definition.- Parameters:
name- the name of the macro to expand (for detecting cycles)definition- the definition of the macro to expand- Returns:
- the expanded definition of the macro.
- Throws:
MacroException- when an error (such as a cyclic definition) occurs during expansion
-