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 we allow in-line content and top-level commands.


mSupportFolderPath


protected

const char* mSupportFolderPath;
Discussion

< Name of file being parsed right now.


Member Data

mCurrentNotes
mFirstHandlerIsFunction
mFirstHandlerName
mHandlerNotes
mIncludeFiles
mIncludeHandler
mMessages
mWebPageEmbedMode
sConstantToValueTable

mCurrentNotes


protected

std::string mCurrentNotes;
Discussion

< List of documentation comments found in the script.


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.


mHandlerNotes


protected

std::vector<CHandlerNotesEntry> mHandlerNotes;
Discussion

< Errors and warnings.


mIncludeFiles


protected

std::vector<CIncludeFileEntry> mIncludeFiles;
Discussion

< Lambda that is called (if present) to retrieve a file included using the "use" statement in web page mode.


mIncludeHandler


protected

CParserIncludeHandler mIncludeHandler;
Discussion

< The most recent "notes" text (documentation "comment") we encountered, so a handler definition can snarf it up and associate it with its handler name. Only valid while parsing.


mMessages


protected

std::vector<CMessageEntry> mMessages;
Discussion

< Path to folder with support files.


mWebPageEmbedMode


protected

bool mWebPageEmbedMode;
Discussion

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


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, TAllVarsAreGlobals inAllVarsAreGlobals ); 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 ); CFunctionDefinitionNode* StartParsingFunctionDefinition( const std::string& handlerName, const std::string& userHandlerName, bool isCommand, size_t fcnLineNum, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, CParseTree& parseTree ); // Called by ParseFunctionDefinition. 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 FindPrintHostCommand( LEOInstructionID *printInstrID, uint16_t *param1, uint32_t *param2 ); 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 ParseWebPageContentToken( 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( const std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseRepeatForEachStatement( const std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseRepeatStatement( const std::string& userHandlerName, CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens ); void ParseIfStatement( const 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( const 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* ParseNumberOfExpression( CParseTree& parseTree, CCodeBlockNodeBase *currFunction, std::deque<CToken>::iterator& tokenItty, std::deque<CToken>& tokens, TIdentifierSubtype inEndIdentifier ); 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); CValueNode* ParseAnyPostfixOperatorForTerm( 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(); void SetWebPageEmbedMode( bool inState ) void SetIncludeHandler( CParserIncludeHandler inIncludeHandler ); const std::vector<CMessageEntry>& GetMessages(); const std::vector<CHandlerNotesEntry>& GetHandlerNotes(); const std::vector<CIncludeFileEntry>& GetIncludedFiles() // statics: static TBuiltInFunctionEntry* GetBuiltInFunctionWithName( const std::string& inName ); static void LoadNativeHeadersFromFile( const char *filepath ); static void SetFirstNativeCallCallback( LEOFirstNativeCallCallbackPtr inCallback ); static void AddOperatorsAndOffsetInstructions( TOperatorEntry *inEntries, size_t firstOperatorInstruction ); static void AddUnaryOperatorsAndOffsetInstructions( TUnaryOperatorEntry *inEntries, size_t firstUnaryOperatorInstruction ); static void AddPostfixOperatorsAndOffsetInstructions( TUnaryOperatorEntry *inEntries, size_t firstUnaryOperatorInstruction ); 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 ); static void AddStringConstants( TStringConstantEntry *inEntries ); static void AddNumberConstants( TNumberConstantEntry *inEntries ); static void AddBuiltInVariables( TBuiltInVariableEntry *inEntries ); }
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.