struct CatspeakEnvironment
GameMaker Language (.gml)Copyfunction CatspeakEnvironment() constructor {
self.codegenType : Function;
self.interface : Struct.CatspeakForeignInterface;
self.lexerType : Function;
self.parserType : Function;
// 2 fields omitted
}
Encapsulates all common Catspeak features into a single, configurable box.
§ addKeywordtop ^
GameMaker Language (.gml)Copystatic addKeyword = function(
name : String,
token : Enum.CatspeakToken,
... : Any,
)
🔬 This is an experimental feature. It may change at any moment.
Used to add a new Catspeak keyword alias.
Arguments
name
The name of the keyword to add. E.g.
"otherwise"
token
The token this keyword should represent. E.g.
CatspeakToken.ELSE
...
Additional arguments in the same name-value format.
§ applyPresettop ^
GameMaker Language (.gml)Copystatic applyPreset = function(
preset : Enum.CatspeakPreset,
... : Enum.CatspeakPreset,
)
🔬 This is an experimental feature. It may change at any moment.
Applies list of presets to this Catspeak environment. These changes cannot be undone, so only choose presets you really need.
You can add additional presets using the catspeak_preset_add
function.
Arguments
preset
The preset type to apply.
...
Additional presets.
Example
Enabling the math and draw presets on the default Catspeak environment:
GameMaker Language (.gml)CopyCatspeak.applyPreset(
CatspeakPreset.MATH,
CatspeakPreset.DRAW
);
§ codegenTypetop ^
GameMaker Language (.gml)Copyself.codegenType : Function
🔬 This is an experimental feature. It may change at any moment.
The code generator to use for this Catspeak environment. Defaults to
CatspeakGMLCompiler
.
Returns Function
§ compiletop ^
GameMaker Language (.gml)Copystatic compile = function(
ir : Struct,
) -> Function
Compiles Catspeak IR into its final representation.
📝 NoteBy default, the result is a function callable from GML. However, this may vary if you have customised the
codegen
field on this environment.
Arguments
ir
The Catspeak IR to compile. You can get this from
Catspeak.parse
.
Returns Function
§ enableSharedGlobaltop ^
GameMaker Language (.gml)Copystatic enableSharedGlobal = function(
enabled? : Bool,
) -> Struct
Enables the shared global feature on this Catspeak environment, forcing all Catspeak programs compiled after this point to share the same global variable scope.
Typically this should not be enabled, but it can be useful for REPL (Read-Eval-Print-Loop) style command consoles, where variables persist between commands.
Returns the shared global struct if this feature is enabled, or
undefined
if the feature is disabled.
Arguments
enabled
(optional)Whether to enable this feature. Defaults to
true
.
Returns Struct
§ interfacetop ^
GameMaker Language (.gml)Copyself.interface : Struct.CatspeakForeignInterface
The foreign interface used by this Catspeak environment. This is where all external GML functions and constants are exposed to the Catspeak runtime environment.
Returns Struct.CatspeakForeignInterface
§ lexerTypetop ^
GameMaker Language (.gml)Copyself.lexerType : Function
🔬 This is an experimental feature. It may change at any moment.
The tokeniser to use for this Catspeak environment. Defaults to
CatspeakLexer
.
Returns Function
§ parsetop ^
GameMaker Language (.gml)Copystatic parse = function(
buff : Id.Buffer,
offset? : Real,
size? : Real,
) -> Struct
Parses a buffer containing a Catspeak program into a bespoke format
understood by Catspeak. Overrides the keyword database if one exists
for this CatspeakEngine
.
⚠️ WarningThe parser does not take ownership of this buffer, so you must make sure to delete it after calling this function. Failure to do this will result in leaking memory.
Arguments
buff
The ID of the GML buffer to use.
offset
(optional)The offset in the buffer to start parsing from. Defaults to 0.
size
(optional)The length of the buffer input. Any characters beyond this limit will be treated as the end of the file. Defaults to
infinity
.
Returns Struct
§ parseAsynctop ^
GameMaker Language (.gml)Copystatic parseAsync = function(
buff : Id.Buffer,
offset? : Real,
size? : Real,
)
🔬 This is an experimental feature. It may change at any moment.
Similar to parse
, except it will pass the responsibility of
parsing to this environments async handler.
📝 NoteThe async handler can be customised, and therefore any third-party handlers are not guaranteed to finish within a reasonable time.
Arguments
buff
The ID of the GML buffer to use.
offset
(optional)The offset in the buffer to start parsing from. Defaults to 0.
size
(optional)The length of the buffer input. Any characters beyond this limit will be treated as the end of the file. Defaults to
infinity
.
§ parserTypetop ^
GameMaker Language (.gml)Copyself.parserType : Function
🔬 This is an experimental feature. It may change at any moment.
The parser to use for this Catspeak environment. Defaults to
CatspeakParser
.
Returns Function
§ parseStringtop ^
GameMaker Language (.gml)Copystatic parseString = function(
src : String,
) -> Struct
Similar to Catspeak.parse
, except a string is used instead of a buffer.
Arguments
src
The string containing Catspeak source code to parse.
Returns Struct
§ removeKeywordtop ^
GameMaker Language (.gml)Copystatic removeKeyword = function(
name : String,
... : String,
)
🔬 This is an experimental feature. It may change at any moment.
Used to remove an existing Catspeak keyword from this environment.
Arguments
name
The name of the keyword to remove. E.g.
"do"
...
Additional keywords to remove.
§ renameKeywordtop ^
GameMaker Language (.gml)Copystatic renameKeyword = function(
currentName : String,
newName : String,
... : Any,
)
🔬 This is an experimental feature. It may change at any moment.
Used to change the string representation of a Catspeak keyword.
Arguments
currentName
The current string representation of the keyword to change. E.g.
"fun"
newName
The new string representation of the keyword. E.g.
"function"
...
Additional arguments in the same name-value format.
§ tokenisetop ^
GameMaker Language (.gml)Copystatic tokenise = function(
buff : Id.Buffer,
offset? : Real,
size? : Real,
) -> Struct
Creates a new lazy tokeniser from the supplied buffer, overriding the keyword database if one exists for the current Catspeak environment.
⚠️ WarningThe lexer does not take ownership of this buffer, so you must make sure to delete it after calling this function. Failure to do this will result in leaking memory.
Arguments
buff
The ID of the GML buffer to use.
offset
(optional)The offset in the buffer to start parsing from. Defaults to 0.
size
(optional)The length of the buffer input. Any characters beyond this limit will be treated as the end of the file. Defaults to
infinity
.
Returns Struct
§ addConstanttop ^
GameMaker Language (.gml)Copystatic addConstant = function(
name : String,
value : Any,
... : Any,
)
👎 Deprecated since 3.0.1Use
Catspeak.interface.exposeConstant
instead.
Used to add a new constant to this environment.
Arguments
name
The name of the constant as it will appear in Catspeak.
value
The constant value to add.
...
Additional arguments in the same name-value format.
§ addFunctiontop ^
GameMaker Language (.gml)Copystatic addFunction = function(
name : String,
func : Function,
... : Any,
)
👎 Deprecated since 3.0.1Use
Catspeak.interface.exposeFunction
instead.
Used to add a new unbound function to this environment.
Arguments
name
The name of the function as it will appear in Catspeak.
func
The script or function to add.
...
Additional arguments in the same name-value format.
§ addMethodtop ^
GameMaker Language (.gml)Copystatic addMethod = function(
name : String,
func : Function,
... : Any,
)
👎 Deprecated since 3.0.1Use
Catspeak.interface.exposeMethod
instead.
Used to add a new method to this environment.
Arguments
name
The name of the function as it will appear in Catspeak.
func
The script or function to add.
...
Additional arguments in the same name-value format.
§ compileGMLtop ^
GameMaker Language (.gml)Copystatic compileGML : Function
👎 Deprecated since 3.0.2Use
Catspeak.compile
instead.
Compiles Catspeak IR into a callable GML function.
Arguments
ir
The Catspeak IR to compile. You can get this from
Catspeak.parse
.
Returns Function
§ getInterfacetop ^
GameMaker Language (.gml)Copystatic getInterface = function()
-> Struct.CatspeakForeignInterface
👎 Deprecated since 3.0.0Use
Catspeak.interface
instead.
Returns Struct.CatspeakForeignInterface
§ removeConstanttop ^
GameMaker Language (.gml)Copystatic removeConstant
👎 Deprecated since 3.0.1Use
Catspeak.interface.addBanList
instead.
Used to remove an existing constant from this environment.
📝 NoteAlthough you can use this to remove functions, it's recommended to use
Catspeak.removeFunction
for that purpose instead.
Arguments
name
The name of the constant to remove.
...
Additional constants to remove.
§ removeFunctiontop ^
GameMaker Language (.gml)Copystatic removeFunction
👎 Deprecated since 3.0.1Use
Catspeak.interface.addBanList
instead.
Used to remove an existing function from this environment.
Arguments
name
The name of the function to remove.
...
Additional functions to remove.