#include <OgreMaterialScriptCompiler.h>
Inheritance diagram for Ogre::MaterialScriptCompiler:
Public Member Functions | |
MaterialScriptCompiler (void) | |
~MaterialScriptCompiler (void) | |
virtual const String & | getClientBNFGrammer (void) |
gets BNF Grammer for Compositor script. | |
virtual const String & | getClientGrammerName (void) |
get the name of the BNF grammer. | |
bool | compile (const String &source, const String &sourceName) |
compile the source - performs 2 passes. | |
Protected Types | |
typedef void(MaterialScriptCompiler::* | MSC_Action )(void) |
typedef std::map< size_t, MSC_Action > | TokenActionMap |
typedef TokenActionMap::iterator | TokenActionIterator |
enum | TokenID { ID_UNKOWN = 0, ID_OPENBRACE, ID_CLOSEBRACE, ID_VERTEX_PROGRAM, ID_FRAGMENT_PROGRAM, ID_MATERIAL, ID_CLONE, ID_TECHNIQUE, ID_SET_TEXTURE_ALIAS, ID_LOD_DISTANCES, ID_RECEIVE_SHADOWS, ID_TRANSPARENCY_CASTS_SHADOWS, ID_LOD_INDEX, ID_PASS, ID_AMBIENT, ID_DIFFUSE, ID_SPECULAR, ID_EMISSIVE, ID_VERTEXCOLOUR, ID_SCENE_BLEND, ID_BLEND_ADD, ID_BLEND_MODULATE, ID_COLOUR_BLEND, ID_ALPHA_BLEND, ID_BLEND_ONE, ID_BLEND_ZERO, ID_BLEND_DEST_COLOUR, ID_BLEND_SRC_COLOUR, ID_BLEND_ONCE_MINUS_DEST_COLOUR, ID_BLEND_ONE_MINUS_SRC_COLOUR, ID_BLEND_DEST_ALPHA, ID_BLEND_SRC_ALPHA, ID_BLEND_ONE_MINUS_DEST_ALPHA, ID_BLEND_ONE_MINUS_SRC_ALPHA, ID_DEPTH_CHECK, ID_DEPTH_WRITE, ID_ALPHA_REJECTION, ID_DEPTH_FUNC, ID_ALWAYS_FAIL, ID_ALWAYS_PASS, ID_LESS_EQUAL, ID_LESS, ID_EQUAL, ID_NOT_EQUAL, ID_GREATER_EQUAL, ID_GREATER, ID_COLOUR_WRITE, ID_CULL_HARDWARE, ID_CLOCKWISE, ID_ANTICLOCKWISE, ID_CULL_NONE, ID_CULL_SOFTWARE, ID_CULL_BACK, ID_CULL_FRONT, ID_SHADING, ID_FLAT, ID_GOURAUD, ID_PHONG, ID_LIGHTING, ID_MAX_LIGHTS, ID_FOG_OVERRIDE, ID_POINT_SIZE, ID_POINT_SPRITES, ID_POINT_SIZE_ATTENUATION, ID_POINT_SIZE_MIN, ID_POINT_SIZE_MAX, ID_TEXTURE_UNIT, ID_ON, ID_OFF, ID_TRUE, ID_FALSE } |
enum | MaterialScriptSection { MSS_NONE, MSS_MATERIAL, MSS_TECHNIQUE, MSS_PASS, MSS_TEXTUREUNIT, MSS_PROGRAM_REF, MSS_PROGRAM, MSS_DEFAULT_PARAMETERS, MSS_TEXTURESOURCE } |
Enum to identify material sections. More... | |
typedef std::vector< TokenRule > | TokenRuleContainer |
typedef TokenRuleContainer::iterator | TokenRuleIterator |
typedef std::vector< LexemeTokenDef > | LexemeTokenDefContainer |
typedef LexemeTokenDefContainer::iterator | LexemeTokenDefIterator |
typedef std::map< std::string, size_t > | LexemeTokenMap |
typedef LexemeTokenMap::iterator | TokenKeyIterator |
typedef std::vector< TokenInst > | TokenInstContainer |
typedef TokenInstContainer::iterator | TokenInstIterator |
enum | OperationType { otUNKNOWN, otRULE, otAND, otOR, otOPTIONAL, otREPEAT, otDATA, otNOT_TEST, otEND } |
enum | SystemRuleToken { _no_token_ = SystemTokenBase, _character_, _value_, _no_space_skip_ } |
enum | BNF_ID { BNF_UNKOWN = 0, BNF_SYNTAX, BNF_RULE, BNF_IDENTIFIER, BNF_IDENTIFIER_RIGHT, BNF_IDENTIFIER_CHARACTERS, BNF_ID_BEGIN, BNF_ID_END, BNF_CONSTANT_BEGIN, BNF_SET_RULE, BNF_EXPRESSION, BNF_AND_TERM, BNF_OR_TERM, BNF_TERM, BNF_TERM_ID, BNF_CONSTANT, BNF_OR, BNF_TERMINAL_SYMBOL, BNF_TERMINAL_START, BNF_REPEAT_EXPRESSION, BNF_REPEAT_BEGIN, BNF_REPEAT_END, BNF_SET, BNF_SET_BEGIN, BNF_SET_END, BNF_NOT_TEST, BNF_NOT_TEST_BEGIN, BNF_OPTIONAL_EXPRESSION, BNF_NOT_EXPRESSION, BNF_NOT_CHK, BNF_OPTIONAL_BEGIN, BNF_OPTIONAL_END, BNF_NO_TOKEN_START, BNF_SINGLEQUOTE, BNF_SINGLE_QUOTE_EXC, BNF_SET_END_EXC, BNF_ANY_CHARACTER, BNF_SPECIAL_CHARACTERS1, BNF_SPECIAL_CHARACTERS2, BNF_WHITE_SPACE_CHK, BNF_LETTER, BNF_LETTER_DIGIT, BNF_DIGIT, BNF_WHITE_SPACE, BNF_ALPHA_SET, BNF_NUMBER_SET, BNF_SPECIAL_CHARACTER_SET1, BNF_SPECIAL_CHARACTER_SET2, BNF_SPECIAL_CHARACTER_SET3, BNF_NOT_CHARS } |
Protected Member Functions | |
virtual void | executeTokenAction (const size_t tokenID) |
Execute an Action associated with a token. | |
virtual void | setupTokenDefinitions (void) |
Associate all the lexemes used in a material script with their corresponding tokens and actions. | |
void | addLexemeTokenAction (const String &lexeme, const size_t token, const MSC_Action action=0) |
void | logParseError (const String &error) |
ColourValue | _parseColourValue (void) |
CompareFunction | convertCompareFunction (void) |
void | parseOpenBrace (void) |
void | parseCloseBrace (void) |
void | parseVertexProgram (void) |
void | parseFragmentProgram (void) |
void | parseMaterial (void) |
void | parseTechnique (void) |
void | parseTransparencyCastsShadows (void) |
void | parseReceiveShadows (void) |
void | parsePass (void) |
void | parseAmbient (void) |
void | parseDiffuse (void) |
void | parseSpecular (void) |
void | parseEmissive (void) |
void | parseDepthCheck (void) |
void | parseDepthWrite (void) |
void | parseDepthFunc (void) |
void | parseAlphaRejection (void) |
void | parseColourWrite (void) |
void | parseCullHardware (void) |
void | parseCullSoftware (void) |
void | parseLighting (void) |
void | parseMaxLights (void) |
void | parseShading (void) |
void | parsePointSize (void) |
void | parsePointSprites (void) |
void | parsePointSizeMin (void) |
void | parsePointSizeMax (void) |
void | parsePointSizeAttenuation (void) |
void | parseTextureUnit (void) |
void | parseTextureCustomParameter (void) |
void | finishProgramDefinition (void) |
bool | doPass1 () |
perform pass 1 of compile process scans source for lexemes that can be tokenized and then performs general semantic and context verification on each lexeme before it is tokenized. | |
bool | doPass2 () |
performs Pass 2 of compile process which is execution of the tokens | |
const TokenInst & | getNextToken (const size_t expectedTokenID=0) |
Gets the next token from the instruction que. | |
const TokenInst & | getCurrentToken (void) |
Gets the current token from the instruction que. | |
bool | testNextTokenID (const size_t expectedTokenID) |
If a next token instruction exist then test if its token ID matches. | |
void | replaceToken (void) |
float | getNextTokenValue (void) |
Gets the next token's associated floating point value in the instruction que that was parsed from the text source. | |
const String & | getNextTokenLabel (void) |
Gets the next token's associated text label in the instruction que that was parsed from the text source. | |
size_t | getPass2TokenQueCount (void) const |
Gets the number of tokens waiting in the instruction que that need to be processed by an token action in pass 2. | |
size_t | getRemainingTokensForAction (void) const |
Get the number of tokens not processed by action token. | |
void | addLexemeToken (const String &lexeme, const size_t token, const bool hasAction=false, const bool caseSensitive=false) |
Add a lexeme token association. | |
void | setClientBNFGrammer (void) |
sets up the parser rules for the client based on the BNF Grammer text passed in. | |
void | findEOL () |
find the eol charater | |
bool | isFloatValue (float &fvalue, size_t &charsize) const |
check to see if the text at the present position in the source is a numerical constant | |
bool | isCharacterLabel (const size_t rulepathIDX) |
Check if source at current position is supposed to be a user defined character label. | |
bool | isLexemeMatch (const String &lexeme, const bool caseSensitive) const |
check to see if the text is in the lexeme text library | |
bool | positionToNextLexeme () |
position to the next possible valid sysmbol | |
bool | processRulePath (size_t rulepathIDX) |
process input source text using rulepath to determine allowed tokens | |
void | setActiveContexts (const uint contexts) |
setup ActiveContexts - should be called by subclass to setup initial language contexts | |
void | skipComments () |
comment specifiers are hard coded | |
void | skipEOL () |
find end of line marker and move past it | |
void | skipWhiteSpace () |
skip all the white space which includes spaces and tabs | |
bool | ValidateToken (const size_t rulepathIDX, const size_t activeRuleID) |
check if current position in source has the lexeme text equivalent to the TokenID | |
void | verifyTokenRuleLinks (const String &grammerName) |
scan through all the rules and initialize token definition with index to rules for non-terminal tokens. | |
void | checkTokenActionTrigger (void) |
Checks the last token instruction and if it has an action then it triggers the action of the previously found token having an action. | |
String | getBNFGrammerTextFromRulePath (size_t ruleID) |
Get the text representation of the rule path. | |
Protected Attributes | |
MaterialScriptContext | mScriptContext |
TokenState * | mClientTokenState |
TokenState * | mActiveTokenState |
Active token que, definitions, rules currntly being used by parser. | |
size_t | mPass2TokenQuePosition |
the location within the token instruction container where pass 2 is | |
size_t | mPreviousActionQuePosition |
the que position of the previous token that had an action. | |
const String * | mSource |
pointer to the source to be compiled | |
String | mSourceName |
name of the source to be compiled | |
size_t | mEndOfSource |
size_t | mCurrentLine |
size_t | mCharPos |
current line number in source being tokenized | |
std::map< size_t, float > | mConstants |
storage container for constants defined in source container uses Token index as a key associated with a float constant | |
std::map< size_t, String > | mLabels |
storage container for string labels defined in source container uses Token index as a key associated with a label | |
bool | mLabelIsActive |
flag indicates when a label is being parsed. | |
size_t | mActiveLabelKey |
the key of the active label being built during pass 1. | |
bool | mNoSpaceSkip |
flag being true indicates that spaces are not to be skipped automatically gets set to false when mLabelIsActive goes to false | |
bool | mNoTerminalToken |
if flag is true then next terminal token is not added to token que if found but does effect rule path flow | |
uint | mActiveContexts |
Active Contexts pattern used in pass 1 to determine which tokens are valid for a certain context. | |
Static Protected Attributes | |
TokenRule | materialScript_RulePath [] |
String | materialScript_BNF |
TokenActionMap | mTokenActionMap |
Map of Token value as key to an Action. | |
const size_t | SystemTokenBase = 1000 |
|
Definition at line 185 of file OgreCompiler2Pass.h. |
|
Definition at line 186 of file OgreCompiler2Pass.h. |
|
Definition at line 188 of file OgreCompiler2Pass.h. |
|
Definition at line 144 of file OgreMaterialScriptCompiler.h. |
|
Definition at line 146 of file OgreMaterialScriptCompiler.h. |
|
Definition at line 145 of file OgreMaterialScriptCompiler.h. |
|
Definition at line 203 of file OgreCompiler2Pass.h. |
|
Definition at line 204 of file OgreCompiler2Pass.h. |
|
Definition at line 189 of file OgreCompiler2Pass.h. |
|
Definition at line 135 of file OgreCompiler2Pass.h. |
|
Definition at line 136 of file OgreCompiler2Pass.h. |
|
Definition at line 146 of file OgreCompiler2Pass.h. |
|
Enum to identify material sections.
Definition at line 85 of file OgreMaterialScriptCompiler.h. |
|
Definition at line 120 of file OgreCompiler2Pass.h. |
|
Definition at line 139 of file OgreCompiler2Pass.h. |
|
Definition at line 54 of file OgreMaterialScriptCompiler.h. |
|
|
|
|
|
|
|
Add a lexeme token association. The backend compiler uses the associations between lexeme and token when building the rule base from the BNF script so all associations must be done prior to compiling a source.
|
|
|
|
Checks the last token instruction and if it has an action then it triggers the action of the previously found token having an action.
|
|
compile the source - performs 2 passes. First pass is to tokinize, check semantics and context. The second pass is performed by using tokens to look up function implementors and executing them which convert tokens to application specific instructions.
|
|
|
|
perform pass 1 of compile process scans source for lexemes that can be tokenized and then performs general semantic and context verification on each lexeme before it is tokenized. A tokenized instruction list is built to be used by Pass 2. A rule path can trigger Pass 2 execution if enough tokens have been generated in Pass 1. Pass 1 will then pass control to pass 2 temporarily until the current tokens have been consumed. |
|
performs Pass 2 of compile process which is execution of the tokens
|
|
Execute an Action associated with a token. Gets called when the compiler finishes tokenizing a section of the source that has been parsed. Implements Ogre::Compiler2Pass. |
|
find the eol charater
|
|
|
|
Get the text representation of the rule path. This is a good way to way to visually verify that the BNF grammer did compile correctly.
|
|
gets BNF Grammer for Compositor script.
Implements Ogre::Compiler2Pass. Definition at line 46 of file OgreMaterialScriptCompiler.h. References Ogre::String. |
|
get the name of the BNF grammer.
Implements Ogre::Compiler2Pass. Definition at line 50 of file OgreMaterialScriptCompiler.h. References Ogre::String. |
|
Gets the current token from the instruction que.
|
|
Gets the next token from the instruction que. If an unkown token is found then an exception is raised but the instruction pointer is still moved passed the unknown token. The subclass should catch the exception, provide an error message, and attempt recovery.
|
|
Gets the next token's associated text label in the instruction que that was parsed from the text source. If an unkown token is found or no associated label was found then an exception is raised but the instruction pointer is still moved passed the unknown token. The subclass should catch the exception, provide an error message, and attempt recovery. |
|
Gets the next token's associated floating point value in the instruction que that was parsed from the text source. If an unkown token is found or no associated value was found then an exception is raised but the instruction pointer is still moved passed the unknown token. The subclass should catch the exception, provide an error message, and attempt recovery. |
|
Gets the number of tokens waiting in the instruction que that need to be processed by an token action in pass 2.
|
|
Get the number of tokens not processed by action token. Client Actions should use this method to retreive the number of parameters(tokens) remaining to be processed in the action. |
|
Check if source at current position is supposed to be a user defined character label. A new label is processed when previous operation was not _character_ otherwise the processed character (if match was found) is added to the current label. This allows _character_ operations to be chained together to form a crude regular expression to build a label.
|
|
check to see if the text at the present position in the source is a numerical constant
|
|
check to see if the text is in the lexeme text library
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position to the next possible valid sysmbol
|
|
process input source text using rulepath to determine allowed tokens
|
|
|
|
setup ActiveContexts - should be called by subclass to setup initial language contexts
Definition at line 405 of file OgreCompiler2Pass.h. References Ogre::uint. |
|
sets up the parser rules for the client based on the BNF Grammer text passed in. Raises an exception if the grammer did not compile successfully. This method gets called when a call to compile occurs and no compiled BNF grammer exists, otherwise nothing will happen since the compiler has no rules to work with. The grammer only needs to be set once during the lifetime of the compiler unless the grammer changes. BNF Grammer rules are cached once the BNF grammer source is compiled. The client should never have to call this method directly. |
|
Associate all the lexemes used in a material script with their corresponding tokens and actions.
Implements Ogre::Compiler2Pass. |
|
comment specifiers are hard coded
|
|
find end of line marker and move past it
|
|
skip all the white space which includes spaces and tabs
|
|
If a next token instruction exist then test if its token ID matches. This method is usefull for peeking ahead during pass 2 to see if a certain token exists.
|
|
check if current position in source has the lexeme text equivalent to the TokenID
|
|
scan through all the rules and initialize token definition with index to rules for non-terminal tokens. Gets called when internal grammer is being verified or after client grammer has been parsed.
|
|
Active Contexts pattern used in pass 1 to determine which tokens are valid for a certain context.
Definition at line 255 of file OgreCompiler2Pass.h. |
|
the key of the active label being built during pass 1. a new key is calculated when mLabelIsActive switches from false to true Definition at line 246 of file OgreCompiler2Pass.h. |
|
Active token que, definitions, rules currntly being used by parser.
Definition at line 218 of file OgreCompiler2Pass.h. |
|
Definition at line 142 of file OgreMaterialScriptCompiler.h. |
|
Definition at line 140 of file OgreMaterialScriptCompiler.h. |
|
current line number in source being tokenized
Definition at line 233 of file OgreCompiler2Pass.h. |
|
Definition at line 215 of file OgreCompiler2Pass.h. |
|
storage container for constants defined in source container uses Token index as a key associated with a float constant
Definition at line 237 of file OgreCompiler2Pass.h. |
|
Definition at line 232 of file OgreCompiler2Pass.h. |
|
Definition at line 230 of file OgreCompiler2Pass.h. |
|
flag indicates when a label is being parsed. It gets set false when a terminal token not of _character_ is encountered Definition at line 243 of file OgreCompiler2Pass.h. |
|
storage container for string labels defined in source container uses Token index as a key associated with a label
Definition at line 240 of file OgreCompiler2Pass.h. |
|
flag being true indicates that spaces are not to be skipped automatically gets set to false when mLabelIsActive goes to false
Definition at line 249 of file OgreCompiler2Pass.h. |
|
if flag is true then next terminal token is not added to token que if found but does effect rule path flow
Definition at line 252 of file OgreCompiler2Pass.h. |
|
the location within the token instruction container where pass 2 is
Definition at line 220 of file OgreCompiler2Pass.h. |
|
the que position of the previous token that had an action. A token's action is fired on the next token having an action. Definition at line 224 of file OgreCompiler2Pass.h. |
|
Definition at line 137 of file OgreMaterialScriptCompiler.h. |
|
pointer to the source to be compiled
Definition at line 227 of file OgreCompiler2Pass.h. |
|
name of the source to be compiled
Definition at line 229 of file OgreCompiler2Pass.h. |
|
Map of Token value as key to an Action. An Action converts tokens into the final format. All instances use the same Token Action Map. Definition at line 151 of file OgreMaterialScriptCompiler.h. |
|
Definition at line 138 of file OgreCompiler2Pass.h. |
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:39:53 2006