CParser

Declared In:

Introduction

The object that keeps all state while parsing a token stream and generates a CParseTree from it.



Constants

mFileName
mSupportFolderPath

mFileName


protected

const char* mFileName;
Discussion

< TRUE if mFirstHandlerName is a function, FALSE if it's a message/command handler.


mSupportFolderPath


protected

const char* mSupportFolderPath;
Discussion

< Name of file being parsed right now.


Member Data

mFirstHandlerIsFunction
mFirstHandlerName
mMessages
sConstantToValueTable

mFirstHandlerIsFunction


protected

bool mFirstHandlerIsFunction;
Discussion

< Name of the function implementing the first handler we parse (can be used by templates as main entry point).


mFirstHandlerName


protected

std::string mFirstHandlerName;
Discussion

< List of globals so we can declare them.


mMessages


protected

std::vector<CMessageEntry> mMessages;
Discussion

< Path to folder with support files.


sConstantToValueTable


protected

protected: static std::map<std::string,CObjCMethodEntry> sObjCMethodTable; static std::map<std::string,CObjCMethodEntry> sCFunctionTable; static std::map<std::string,CObjCMethodEntry> sCFunctionPointerTable; static std::map<std::string,std::string> sSynonymToTypeTable; static std::map<std::string,std::string> sConstantToValueTable; static LEOFirstNativeCallCallbackPtr sFirstNativeCallCallback; public: CParser(); void Parse( const char *fname, std::deque<CToken>& tokens, CParseTree& parseTree, const char *scriptText ); void ParseCommandOrExpression( const char *fname, std::deque<CToken>& tokens, CParseTree& parseTree ); void ParseTopLevelConstruct( std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, CParseTree& parseTree, const char *scriptText ); void ParseDocumentation( std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, CParseTree& parseTree, const char *scriptText ); void ParseFunctionDefinition( bool isCommand, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, CParseTree& parseTree ); CValueNode * ParseFunctionCall( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, bool isMessagePassing, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParsePassStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseHandlerCall( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, bool isMessagePassing, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParsePutStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseGetStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseSetStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseHostCommand( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); CValueNode* ParseHostFunction( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); CValueNode* ParseHostEntityWithTable( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, THostCommandEntry *inHostTable ); void ParseGlobalStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseReturnStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseDownloadStatement( std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseRepeatForEachStatement( std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseRepeatStatement( std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseIfStatement( std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); CValueNode* ParseContainer( bool asPointer, bool initWithName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, TIdentifierSubtype inEndToken ); CValueNode* ParseArrayItem( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseOneLine( std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, bool dontSwallowReturn = false ); void ParseFunctionBody( std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, size_t *outEndLineNum = NULL, TIdentifierSubtype endIdentifier = EEndIdentifier, bool parseFirstLineAsReturnExpression = false ); void ParseParamList( TIdentifierSubtype identifierToEndOn, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, CFunctionCallNode *inFCallToAddTo ); CValueNode* ParseObjCMethodCall( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); CValueNode* ParseNativeFunctionCallStartingAtParams( std::string& methodName, CObjCMethodEntry& methodInfo, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); CValueNode* ParseTerm( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, TIdentifierSubtype inEndIdentifier ); CValueNode* ParseAnyFollowingArrayDefinitionWithKey( CValueNode *theTerm, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, TIdentifierSubtype inEndIdentifier); void OutputExpressionStack( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<std::string> &terms, std::deque<const char*> &operators ); void CreateVariable( const std::string& varName, const std::string& realVarName, bool initWithName, CCodeBlockNodeBase *currFunction, bool isGlobal = false ); TIdentifierSubtype ParseOperator( std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, int *outPrecedence, LEOInstructionID *outOpName ); CValueNode* ParseChunkExpression( TChunkType typeConstant, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); CValueNode* ParseConstantChunkExpression( TChunkType typeConstant, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); CValueNode* ParseExpression( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, TIdentifierSubtype inEndToken ); void ParseAddStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseSubtractStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseMultiplyStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseDivideStatement( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); TChunkType GetChunkTypeNameFromIdentifierSubtype( TIdentifierSubtype identifierToCheck ); void FillArrayWithComponentsSeparatedBy( const char *typesStr, char delimiter, std::deque<std::string> &destTypesList ); void CreateHandlerTrampolineForFunction( const std::string &handlerName, const std::string& procPtrName, const char *typesStr, std::stringstream& theCode, std::string &outTrampolineName ); CValueNode* ParseColumnRowExpression( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, TIdentifierSubtype inEndToken ); CValueNode* CollapseExpressionStack( CParseTree& parseTree, std::deque<CValueNode*> &terms, std::deque<LEOInstructionID> &operators ); std::string GetFirstHandlerName(); const char* GetSupportFolderPath(); void SetSupportFolderPath( const char *spfp ); void GenerateObjCTypeToVariantCode( std::string type, std::string &prefix, std::string &suffix ); void GenerateVariantToObjCTypeCode( std::string type, std::string &prefix, std::string &suffix, std::string& ioValue ); void LoadNativeHeaders(); const std::vector<CMessageEntry>& GetMessages(); // statics: static void LoadNativeHeadersFromFile( const char *filepath ); static void SetFirstNativeCallCallback( LEOFirstNativeCallCallbackPtr inCallback ); static void AddBuiltInFunctionsAndOffsetInstructions( TBuiltInFunctionEntry *inEntries, size_t firstBuiltInFunctionInstruction ); static void AddGlobalPropertiesAndOffsetInstructions( TGlobalPropertyEntry *inEntries, size_t firstGlobalPropertyInstruction ); static void AddHostCommandsAndOffsetInstructions( THostCommandEntry *inEntries, size_t firstHostCommandInstruction ); static void AddHostFunctionsAndOffsetInstructions( THostCommandEntry *inEntries, size_t firstHostCommandInstruction ); }
Discussion

< Register functions that take no params and can be called as "foo()" or "the foo" and map them to a bunch of instructions previously registered.