Introduction
This header defines the C data types a host application needs to register its
own syntax with the Forge parser, and to use the Forge parser to generate
Leonie bytecode.
Typedefs
- THostParameterOptional
- THostParameterType
typedef enum {
EHostParameterOptional = 1,
EHostParameterRequired = 0
} THostParameterOptional;
Discussion
The THostParameterOptional enum is used by THostCommandEntry to indicate whether
a part of a command is required or optional.
typedef enum {
EHostParamImmediateValue = 0,
EHostParamExpression,
EHostParamContainer,
EHostParamIdentifier,
EHostParamInvisibleIdentifier,
EHostParamLabeledValue,
EHostParamLabeledExpression,
EHostParamLabeledContainer,
EHostParamExpressionOrIdentifiersTillLineEnd,
EHostParamConstant,
EHostParamExpressionOrConstant,
EHostParam_Sentinel
} THostParameterType;
Constants
-
EHostParamExpression
< An entire expression, but no label.
-
EHostParamContainer
< A container that something can be put into.
-
EHostParamIdentifier
< An identifier that gets passed as a string.
-
EHostParamInvisibleIdentifier
< An identifier that is simply used to switch modes, but doesn't cause a parameter.
-
EHostParamLabeledValue
< A value preceded by an identifier labeling it.
-
EHostParamLabeledExpression
< An expression preceded by an identifier labeling it.
-
EHostParamLabeledContainer
< A container that something can be put into, preceded by an identifier labeling it.
-
EHostParamExpressionOrIdentifiersTillLineEnd
< Either an expression, or a bunch of unquoted string literals all merged into one string parameter with a single space separating each from the next. Used e.g. for 'play' command's melody.
-
EHostParamConstant
< A value from a particular set of (possibly multi-word) constants. mIdentifierType is an index into our list of constant sets. Use ELastIdentifier_Sentinel for "any" constant.
-
EHostParamExpressionOrConstant
< A value from a particular set of (possibly multi-word) constants. mIdentifierType is an index into our list of constant sets. If we don't find one from that set, parse an expression instead.
-
EHostParam_Sentinel
< If this value is specified, this is the last parameter.
Constants
Discussion
The THostParameterType enum is used by THostCommandEntry to indicate which
part of a command is to be parsed in what way.
Structs and Unions
- THostParameterEntry
Fields
-
mType
< The type of parameter to parse, or EHostParam_Sentinel if this is the end of the list of host command entries.
-
mIdentifierType
< The identifier (for the label or identifier, depending on mType).
-
mIsOptional
< Is this parameter required or optional? If not present and optional, we, pass an empty string unless mType indicates otherwise, or mInstructionID is not INVALID_INSTR2.
-
mInstructionID
< If not INVALID_INSTR2, this instruction overrides the one in the command entry if this parameter is present. If mType is EHostParamIdentifier, no string will be passed as a parameter either.
-
mInstructionParam1
< If mInstructionID is not INVALID_INSTR2, these parameters will be assigned to the instruction if this parameter is parsed.
-
mInstructionParam2
< If mInstructionID is not INVALID_INSTR2, these parameters will be assigned to the instruction if this parameter is parsed.
-
mModeRequired
< If this isn't 0, only parse this if the current mode is this number. The mode can be used to group together certain parameters so they only match when a previous parameter matched.
-
mModeToSet
< If this parameter matches, and this isn't 0, change the current mode to this. The mode can be used to only look for certain parameters when a previous parameter matched.
Discussion
An entry for a parameter to a THostCommandEntry in our host command look-up table:
Macro Definitions
- X1
#define X1(constName,constStr) X2(constName,constName,constStr)
Discussion
The various built-in identifiers the parser recognizes:
Adding an identifier here defines the identifier type enum for it, as well
as the matching string table entry (which must be all-lowercase so our fake
case-insensitivity will work). Also, if you use the X2 macro instead of
X1, you can also declare a token as synonymous to another token, e.g. to
register a short form that is always remapped to the longer form before
the parser sees it.
If you want to use any identifiers for your host-specific commands that aren't
in here, you must currently edit this file to add them. In the future, you
will hopefully be able to just define your own identifiers elsewhere in addition
to the ones here that are needed for built-in commands.
© 2010-2013 Uli Kusterer, all rights reserved.
Last Updated: 2019-02-10
|