eRPC Generator (erpcgen)
Rev. 1.12.0
NXP Semiconductors
|
Scans for symbol names. More...
#include <SymbolScanner.hpp>
Public Member Functions | |
SymbolScanner (SymbolScope *globals) | |
This function is constructor of symbol scanner class. More... | |
SymbolScanner (SymbolScope *globals, const std::string &fileName) | |
This function is constructor of symbol scanner class. More... | |
virtual | ~SymbolScanner () |
Destructor. | |
Program * | getProgram () |
Program is out of global symbol scope. More... | |
Public Member Functions inherited from erpcgen::AstWalker | |
AstWalker ()=default | |
default constructor | |
AstWalker (const std::string &inputFile) | |
Constructor. More... | |
virtual | ~AstWalker ()=default |
destructor | |
virtual void | startWalk (AstNode *node) |
This function walk the AstNode depth-first and invoke handler methods. More... | |
Protected Member Functions | |
virtual void | handleRoot (AstNode *node, bottom_up) override |
This function is called at the end of scanning. More... | |
virtual AstNode * | handleProgram (AstNode *node, top_down) override |
This function start handle program. More... | |
virtual AstNode * | handleProgram (AstNode *node, bottom_up) override |
This function start handle program. More... | |
virtual AstNode * | handleConst (AstNode *node, bottom_up) override |
This function handles a constant definition. More... | |
virtual AstNode * | handleType (AstNode *node, top_down) override |
This function start handle type. More... | |
virtual AstNode * | handleType (AstNode *node, bottom_up) override |
This function end handle type. More... | |
virtual AstNode * | handleEnum (AstNode *node, top_down) override |
This function end handle enum. More... | |
virtual AstNode * | handleEnum (AstNode *node, bottom_up) override |
This function end handle enum. More... | |
virtual AstNode * | handleEnumMember (AstNode *node, bottom_up) override |
This function end handle enum member. More... | |
bool | enumMemberHasValue (AstNode *enumMember) |
Check to see if enum member is assigned a value by the user. More... | |
virtual AstNode * | handleExpr (AstNode *node, bottom_up) override |
This function start handle expression. More... | |
virtual AstNode * | handleBinaryOp (AstNode *node, bottom_up) override |
This function end handle binary operator. More... | |
virtual AstNode * | handleUnaryOp (AstNode *node, bottom_up) override |
This function end handle unary operator. More... | |
virtual AstNode * | handleStruct (AstNode *node, top_down) override |
This function start handle struct. More... | |
virtual AstNode * | handleStruct (AstNode *node, bottom_up) override |
This function end handle struct. More... | |
virtual AstNode * | handleStructMember (AstNode *node, bottom_up) override |
This function end handle struct member. More... | |
virtual AstNode * | handleUnion (AstNode *node, top_down) override |
Handles Union data type while traversing down the AST. More... | |
virtual AstNode * | handleUnion (AstNode *node, bottom_up) override |
Handles Union data type while traversing down the AST. More... | |
virtual AstNode * | handleUnionCase (AstNode *node, top_down) override |
virtual AstNode * | handleUnionCase (AstNode *node, bottom_up) override |
This function end handle struct member. More... | |
virtual AstNode * | handleInterface (AstNode *node, top_down) override |
This function start handle interface. More... | |
virtual AstNode * | handleInterface (AstNode *node, bottom_up) override |
This function end handle interface. More... | |
virtual AstNode * | handleFunction (AstNode *node, top_down) override |
This function start handle function. More... | |
virtual AstNode * | handleFunction (AstNode *node, bottom_up) override |
This function end handle function. More... | |
virtual AstNode * | handleParam (AstNode *node, top_down) override |
This function start handle function parameter. More... | |
virtual AstNode * | handleParam (AstNode *node, bottom_up) override |
This function end handle function parameter. More... | |
void | setParameterDirection (StructMember *param, AstNode *directionNode) |
set parameter direction: in, out, inout More... | |
Value * | getValueFromSymbol (const Token &tok) |
Get value from symbol table for name defined by given token. More... | |
DataType * | getDataTypeForConst (AstNode *typeNode) |
This function returns the data type for a constant variable. More... | |
bool | containsStructEnumDeclaration (const AstNode *typeNode) |
Returns true when given Astnode is enum or structure declaration. More... | |
DataType * | lookupDataType (const AstNode *typeNode) |
This function returns pointer to new type object. More... | |
DataType * | createListType (const AstNode *typeNode) |
This function returns pointer to new list object. More... | |
DataType * | createArrayType (const AstNode *typeNode) |
This function returns pointer to new array object. More... | |
DataType * | lookupDataTypeByName (const Token &tok, SymbolScope *scope, bool recursive=true) |
This function returns pointer to new type object. More... | |
uint64_t | getIntExprValue (const AstNode *exprNode) |
This function returns token integer value. More... | |
bool | rhsIsAStringLiteral (AstNode *rhs) |
Determines if the right hand side of a constant declaration is a string literal. More... | |
bool | rhsIsAnExpression (AstNode *rhs) |
Determines if the right hand side of a constant declaration is an expression. More... | |
Value * | getValueForConst (AstNode *const node, DataType *const constDataType) |
Gets the value object for the const variable. More... | |
void | addAnnotations (AstNode *childTok, Symbol *symbol) |
This function add annotations to vector of symbol annotations. More... | |
void | checkAnnotationBeforeAdding (AstNode *annotation, Symbol *symbol) |
This function check annotation just before it will be added to symbol. More... | |
Value * | getAnnotationValue (AstNode *annotationNode) |
Helper function to get Value from annotation AstNode. More... | |
Annotation::program_lang_t | getAnnotationLang (AstNode *annotationNode) |
Helper function to get programming language type if specified for which is annotation intended. More... | |
void | scanStructForAnnotations () |
Controlling annotations used on structure members. More... | |
void | addDoxygenComments (Symbol *symbol, AstNode *above, AstNode *trailing) |
This function sets to given symbol given doxygen comments. More... | |
StructMember * | createCallbackParam (StructMember *structMember, const std::string &name) |
This function creates new function parameter. More... | |
void | addForwardDeclaration (DataType *dataType) |
This function registers forward union/structure declarations. More... | |
void | removeForwardDeclaration (DataType *dataType) |
This function unregister union/structure declarations. More... | |
void | addGlobalSymbol (Symbol *symbol) |
This function add symbol into global symbol scope. More... | |
Protected Member Functions inherited from erpcgen::AstWalker | |
virtual void | walk (AstNode *node) |
This function walk the AstNode depth-first and invoke handler methods. More... | |
template<typename D > | |
void | dispatch (AstNode *node) |
This function invoke the appropriate handler method for the node's token type.. More... | |
virtual void | handleRoot (AstNode *node, top_down) |
virtual AstNode * | handleConst (AstNode *node, top_down) |
virtual AstNode * | handleChildren (AstNode *node, top_down) |
virtual AstNode * | handleEnumMember (AstNode *node, top_down) |
virtual AstNode * | handleStructMember (AstNode *node, top_down) |
virtual AstNode * | handleExpr (AstNode *node, top_down) |
virtual AstNode * | handleBinaryOp (AstNode *node, top_down) |
virtual AstNode * | handleUnaryOp (AstNode *node, top_down) |
virtual AstNode * | handleAnnotation (AstNode *node, top_down) |
virtual AstNode * | handleChildren (AstNode *node, bottom_up) |
virtual AstNode * | handleAnnotation (AstNode *node, bottom_up) |
Protected Attributes | |
SymbolScope * | m_globals |
Interface * | m_currentInterface |
StructType * | m_currentStruct |
Program * | m_currentProgram |
EnumType * | m_currentEnum |
AliasType * | m_currentAlias |
UnionType * | m_currentUnion |
std::vector< UnionCase * > | m_emptyUnionCases |
std::map< std::string, DataType * > | m_forwardDeclarations |
Protected Attributes inherited from erpcgen::AstWalker | |
std::string | m_fileName |
Stores name of file from which AST was built. | |
Scans for symbol names.
|
inlineexplicit |
This function is constructor of symbol scanner class.
This function set their variables to default values, when object is created.
[in] | globals | Global symbol scope variable. |
|
inline |
This function is constructor of symbol scanner class.
This function set their variables to default values, when object is created.
[in] | globals | Global symbol scope variable. |
[in] | fileName | name of IDL from which AST was built. |
|
protected |
This function sets to given symbol given doxygen comments.
Comments can be placed above declaration or as trailing comments.
[in] | symbol | Symbol where doxygen comments will be added. |
[in] | above | Doxygen comments placed above. |
[in] | trailing | Trailing doxygen comments. |
|
protected |
This function registers forward union/structure declarations.
[in] | dataType | Union/structure data type. |
|
protected |
This function add symbol into global symbol scope.
[in] | dataType | Union/structure data type. |
This function check annotation just before it will be added to symbol.
[in] | annotation | Node containing information about annotation. |
[in] | symbol | Symbol containing vector of annotations belongs to him. |
|
protected |
This function returns pointer to new array object.
The function returns pointer to new array object with set array size and nested element type.
[in] | typeNode | Node, which has array token type. |
|
protected |
This function returns pointer to new list object.
The function returns pointer to new list object with set list variable name for list size and nested element type.
[in] | typeNode | Node, which has list token type. |
|
protected |
Check to see if enum member is assigned a value by the user.
[in] | enumMember | AST node type enum member. |
Returns | whether or not the enum member has user-defined value. |
|
protected |
Helper function to get programming language type if specified for which is annotation intended.
[in] | annotationNode | AstNode pointing to the annotation |
This function returns the data type for a constant variable.
[in] | typeNode | Node referring to the data type |
|
protected |
This function returns token integer value.
The function returns token integer value, when when given AstNode is expression and his child token is equal TOK_INT_LITERAL. Otherwise throw error.
[in] | exprNode | Expression node. |
semantic_error | Thrown if given ast node has not child with token type TOK_INT_LITERAL. |
|
inline |
|
protected |
Gets the value object for the const variable.
[in] | node | Parent const node |
[in] | constDataType | const variable's data type |
Get value from symbol table for name defined by given token.
[in] | tok | Token with symbol name defined |
Value | object for name defined by given token |
syntax_error | Thrown, when token value is null or when symbol is not defined in global symbol scope. |
semantic_error | Thrown, when symbol type is not constant or enum member. |
This function end handle binary operator.
This function handle binary operator for integer and float value.
[in] | node | AST node. |
nullptr | Return null pointer, when left or right token value of given AstNode can't be cast to IntegerValue or FloatValue. |
internal_error | Thrown if is used unknown binary operator for integer or float value. |
semantic_error | Thrown if is used invalid binary operators on float value. |
Reimplemented from erpcgen::AstWalker.
This function handles a constant definition.
[in] | node | AST node const type definition). |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle enum.
The function set enum variable m_currentEnum to null.
[in] | node | AST node type enum. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle enum.
The function set enum variable m_currentEnum to null.
[in] | node | AST node type enum. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle enum member.
The function set to enum member variable m_currentEnumMember to null.
[in] | node | AST node type enum member. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function start handle expression.
[in] | node | AST node type expression. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function start handle function.
The function add function to interface functions vector. Also initialize function parameters vector. For function is also set name and return type.
[in] | node | AST node type function. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle function.
The function set function parameters vector variable to null.
[in] | node | AST node type function. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function start handle interface.
The function add interface to symbol m_globals variable. Also initialize interface functions vector. For interface is also set name.
[in] | node | AST node type interface. |
nullptr | Always return null pointer. |
Throw | semantic error, when struct member data type name is same as struct name (nested structs). |
Reimplemented from erpcgen::AstWalker.
This function end handle interface.
The function set interface functions vector variable to null.
[in] | node | AST node type interface. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function start handle function parameter.
The function add function parameter to function parameters vector. The function also set name and data type to parameter.
[in] | node | AST node type parameter. |
nullptr | Always return null pointer. |
semantic_error | Thrown if given ast node has not child with token type TOK_IN, TOK_OUT, TOK_INOUT. |
Reimplemented from erpcgen::AstWalker.
This function end handle function parameter.
[in] | node | AST node type parameter. |
nullptr | Always return null pointer. |
semantic_error | Thrown if given ast node has not child with token type TOK_IN, TOK_OUT, TOK_INOUT. |
Reimplemented from erpcgen::AstWalker.
This function start handle program.
[in] | node | AST node program (type definition). |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function start handle program.
[in] | node | AST node program (type definition). |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function is called at the end of scanning.
[in] | node | Root node. |
Reimplemented from erpcgen::AstWalker.
This function start handle struct.
The function add struct to symbol scope variable m_globals. For struct is also set name and this struct is set to struct variable m_currentStruct.
[in] | node | AST node type struct. |
nullptr | Always return null pointer. |
semantic_error | Thrown if an given node has not children and is not alias (type definition). |
Reimplemented from erpcgen::AstWalker.
This function end handle struct.
The function set struct variable m_currentStruct to null.
[in] | node | AST node type struct. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle struct member.
The function add struct member to struct m_currentStruct variable. For struct member is also set name and data type.
[in] | node | AST node type struct member. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function start handle type.
The function set alias (type definition) to symbol scope variable m_globals. Also set name and data type to alias. Bool variable m_isInTypedef is set to true.
[in] | node | AST node type alias (type definition). |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle type.
The function set bool variable m_isInTypedef to false.
[in] | node | AST node type alias (type definition). |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle unary operator.
This function handle unary operator for integer and float value.
[in] | node | AST node. |
nullptr | Return null pointer, when value of AstNode token can't be cast to FloatValue or IntegerValue. |
internal_error | Thrown if is used unknown unary operator for integer or float value. |
semantic_error | Thrown if is used unary operator '~' on float value. |
Reimplemented from erpcgen::AstWalker.
Handles Union data type while traversing down the AST.
The function sets the variable m_currentUnion.
[in] | node | AST node type struct. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
Handles Union data type while traversing down the AST.
The function add m_currentUnion to m_currentStruct.
[in] | node | AST node type struct. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
[in] | node | AST node type struct member. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function end handle struct member.
The function add union cases to union m_currentUnion variable.
[in] | node | AST node type struct member. |
nullptr | Always return null pointer. |
Reimplemented from erpcgen::AstWalker.
This function returns pointer to new type object.
The function returns pointer to new data type object (array, list, alias, ...). Created data type depends on given node token.
[in] | typeNode | Node, which data type is searched. |
internal_error | Thrown if given ast node has not token type: TOK_IDENT, TOK_LIST, TOK_ARRAY. |
|
protected |
This function returns pointer to new type object.
The function returns pointer to new type object, which can be simple data type or alias.
[in] | tok | Token with data type name. |
[in] | scope | Scope determines searching area. |
[in] | recursive | Recursive searching given scope. |
semantic_error | Thrown if given token has not name located in symbol scope variable m_globals. |
semantic_error | Thrown if given token can not be transformed to data type. |
|
protected |
This function unregister union/structure declarations.
[in] | dataType | Union/structure data type. |
|
protected |
Determines if the right hand side of a constant declaration is an expression.
[in] | rhs | Node referring to the rhs expression. |
True | when given ast node is expression, else false. |
|
protected |
Determines if the right hand side of a constant declaration is a string literal.
[in] | rhs | Node referring to the rhs expression. |
True | when given ast node is string literal, else false. |
|
protected |
Controlling annotations used on structure members.
Struct members are examined for and annotations, and the length member is denoted. This function is also used on function parameters, since they are represented as structs.
|
protected |
set parameter direction: in, out, inout
[in] | param | Current parameter |
[in] | directionNode | Direction node in AST |
|
protected |
Contains pointer to alias when alias is handled.
|
protected |
Contains pointer to enumeration when enumeration is handled.
|
protected |
Contains pointer to interface when interface is handled.
|
protected |
Contains pointer to program when program was set in parsed file.
|
protected |
Contains pointer to structure when structure is handled.
|
protected |
Contains pointer to union when union is handled.
|
protected |
Vector of union cases.
|
protected |
To keep forward declarations.
|
protected |
SymbolScope contains information about generating data types, functions, and interfaces.