-
Notifications
You must be signed in to change notification settings - Fork 0
Token and Types
The first step of the gifscript process (once the input has been read) is tokenization.
gifscript supports C style and C++ style comments.
/*
all of this will be ignored by the lexer
even this line
*/
// And this line too!
I was originally going to do away with using line ending 'command' characters, but it proved to be difficult when writing the tokenizer.
To end a line, you must put a semicolon ';'
xyz2 123,456,789 // malformed
xyz2 123,456,789; // correct
To keep from duplicating information, I'll keep this section simple. A register token is simply the register name.
To also keep from duplicating information, please refer to the register information page for modifier tokens.
- Integer ->
123
- Hexadecimal ->
0x123
,x123
(0 prefix is optional) - Floating Point ->
123.456f
,123.456
(f suffix is optional)
Do know that 123.0f does not equal 123! Internally it is bitcasted and in this example will emit0x42f60000
.
Vectors are simple, any of the above constants are accepted for each segment of a vector.
-
vec2
->123,0x456
-
vec3
->123,0x456,789.0f
-
vec4
->123,0x456,789.0f,x12
SCISSOR 200,300,100,200 // Pushes a vec4 to SCISSOR
LABEL 0x100,0xFFF // Pushes a vec2 to LABEL
Blocks and packets may be terms used interchangeably. A block is simply a list of commands that form a GIF packet.
There are currently two types of blocks, macro and emitting / drawing blocks.
To start and end either type of block, use the curly brackets characters
my_block { // starts block
} // ends block
Macros will be documented on a separate page.
The token for macro controls is simply macro
macro my_macro_block { // Starts macro block
macro my_second_macro_block; // Nests the second macro block into this one
} // Ends macro block
Used for block or macro names. They are case sensitive strings that must start with a letter or underscore. Underscores (_) are the only special character permitted in an identifier. They are tokenized as such
[a-zA-Z_][a-zA-Z0-9_]*