MacroTable class final

Macro definitions with TeX group scoping.

Local definitions are undone at the end of the group that made them; global ones (\gdef, \global) survive. Reuse one table across several parses to share definitions between formulas.

Constructors

MacroTable([Map<String, MacroDefinition>? builtins])
Creates a table. builtins are consulted when no definition is set.

Properties

definedNames → Iterable<String>
Names currently given a meaning by definitions (not builtins).
no setter
depth → int
Number of open groups.
no setter
extensions ↔ Map<String, MacroDefinition>
Macros of the enabled extensions, consulted after definitions and before _builtins. Set by the parser from its options.
getter/setter pair
fallbacks ↔ Map<String, MacroDefinition>
Common package commands (\abs, \sgn, \sfrac…), consulted last. They give a meaning to a name nothing else defines, but do not count as defined: \newcommand{\abs} defines it without a warning, as in a document that does not load the package. Set by the parser.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
hasState → bool
Whether any state was ever set: lets callers skip state lookups on formulas that use none.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

beginGroup() → void
Opens a group.
endAllGroups() → void
Closes every open group.
endGroup() → void
Closes the innermost group, undoing its local definitions.
has(String name) → bool
Whether name currently has a meaning.
hasOwn(String name) → bool
Whether name has a meaning other than a fallback's.
hasUserDefinition(String name) → bool
Whether name was defined by the user (not a builtin).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
set(String name, MacroDefinition? definition, {bool global = false}) → void
Sets name to definition (null undefines it).
setState(String key, Object? value, {bool global = false}) → void
Sets state key to value (null removes it), until the end of the current group unless global.
state(String key) → Object?
The value of state key (a register, a counter…), or null when it was never set.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](String name) → MacroDefinition?
The current meaning of name, or null.