Generates NED code from a NED object tree. More...
#include <ned1generator.h>
Public Member Functions | |
NED1Generator (NEDErrorStore *errors) | |
~NED1Generator () | |
void | setIndentSize (int indentsize) |
void | generate (std::ostream &out, NEDElement *node, const char *indent) |
std::string | generate (NEDElement *node, const char *indent) |
Protected Member Functions | |
void | generateNedItem (NEDElement *node, const char *indent, bool islast, const char *arg=NULL) |
void | generateChildren (NEDElement *node, const char *indent, const char *arg=NULL) |
void | generateChildrenWithType (NEDElement *node, int tagcode, const char *indent, const char *arg=0) |
void | generateChildrenWithTypes (NEDElement *node, int tagcodes[], const char *indent, const char *arg=0) |
Change indentation level | |
const char * | increaseIndent (const char *indent) |
const char * | decreaseIndent (const char *indent) |
Utilities | |
void | printInheritance (NEDElement *node, const char *indent) |
bool | hasExpression (NEDElement *node, const char *attr) |
void | printExpression (NEDElement *node, const char *attr, const char *indent) |
void | printOptVector (NEDElement *node, const char *attr, const char *indent) |
std::string | getDisplayStringOf (NEDElement *node, PropertyElement *&outDisplayProp) |
const char * | getPromptTextOf (ParamElement *param) |
Getters for comments | |
std::string | concatInnerComments (NEDElement *node) |
std::string | getBannerComment (NEDElement *node, const char *indent) |
std::string | getRightComment (NEDElement *node) |
std::string | getInlineRightComment (NEDElement *node) |
std::string | getTrailingComment (NEDElement *node) |
Generate NED code from the given element | |
void | doNedfiles (FilesElement *node, const char *indent, bool islast, const char *) |
void | doNedfile (NedFileElement *node, const char *indent, bool islast, const char *) |
void | doImport (ImportElement *node, const char *indent, bool islast, const char *) |
void | doPropertyDecl (PropertyDeclElement *node, const char *indent, bool islast, const char *) |
void | doExtends (ExtendsElement *node, const char *indent, bool islast, const char *) |
void | doInterfaceName (InterfaceNameElement *node, const char *indent, bool islast, const char *) |
void | doSimpleModule (SimpleModuleElement *node, const char *indent, bool islast, const char *) |
void | doModuleInterface (ModuleInterfaceElement *node, const char *indent, bool islast, const char *) |
void | doCompoundModule (CompoundModuleElement *node, const char *indent, bool islast, const char *) |
void | doChannelInterface (ChannelInterfaceElement *node, const char *indent, bool islast, const char *) |
void | doChannel (ChannelElement *node, const char *indent, bool islast, const char *) |
void | doParameters (ParametersElement *node, const char *indent, bool islast, const char *) |
void | doModuleParameters (ParametersElement *node, const char *indent) |
void | doChannelParameters (ParametersElement *node, const char *indent) |
void | doSubstParameters (ParametersElement *node, const char *indent) |
void | doConnectionAttributes (ParametersElement *node, const char *indent) |
void | doParam (ParamElement *node, const char *indent, bool islast, const char *) |
void | doModuleParam (ParamElement *node, const char *indent, bool islast, const char *) |
void | doSubstParam (ParamElement *node, const char *indent, bool islast, const char *) |
void | doChannelParam (ParamElement *node, const char *indent) |
void | doProperty (PropertyElement *node, const char *indent, bool islast, const char *) |
void | doPropertyKey (PropertyKeyElement *node, const char *indent, bool islast, const char *) |
void | doGates (GatesElement *node, const char *indent, bool islast, const char *) |
void | doModuleGates (GatesElement *node, const char *indent) |
void | doSubmoduleGatesizes (GatesElement *node, const char *indent) |
void | doGate (GateElement *node, const char *indent, bool islast, const char *) |
void | doModuleGate (GateElement *node, const char *indent, bool islast, const char *) |
void | doGatesize (GateElement *node, const char *indent, bool islast, const char *) |
void | doTypes (TypesElement *node, const char *indent, bool islast, const char *) |
void | doSubmodules (SubmodulesElement *node, const char *indent, bool islast, const char *) |
void | doSubmodule (SubmoduleElement *node, const char *indent, bool islast, const char *) |
void | doConnections (ConnectionsElement *node, const char *indent, bool islast, const char *) |
void | doConnection (ConnectionElement *node, const char *indent, bool islast, const char *) |
void | doConnectionGroup (ConnectionGroupElement *node, const char *indent, bool islast, const char *) |
void | doLoop (LoopElement *node, const char *indent, bool islast, const char *) |
void | doCondition (ConditionElement *node, const char *indent, bool islast, const char *) |
void | printConnectionGate (NEDElement *conn, const char *modname, const char *modindexattr, const char *gatename, const char *gateindexattr, bool isplusplus, int gatesubg, const char *indent) |
void | doExpression (ExpressionElement *node, const char *indent, bool islast, const char *) |
int | getOperatorPrecedence (const char *op, int args) |
bool | isOperatorLeftAssoc (const char *op) |
void | doOperator (OperatorElement *node, const char *indent, bool islast, const char *) |
void | doFunction (FunctionElement *node, const char *indent, bool islast, const char *) |
void | doIdent (IdentElement *node, const char *indent, bool islast, const char *) |
void | doLiteral (LiteralElement *node, const char *indent, bool islast, const char *) |
Protected Attributes | |
int | indentsize |
std::ostream * | outp |
NEDErrorStore * | errors |
Generates NED code from a NED object tree.
Assumes object tree has already passed all validation stages (DTD, syntax, semantic).
NED1Generator::NED1Generator | ( | NEDErrorStore * | errors | ) |
Constructor.
NED1Generator::~NED1Generator | ( | ) |
Destructor.
std::string NED1Generator::concatInnerComments | ( | NEDElement * | node | ) | [protected] |
const char* NED1Generator::decreaseIndent | ( | const char * | indent | ) | [protected] |
void NED1Generator::doChannel | ( | ChannelElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doChannelInterface | ( | ChannelInterfaceElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doChannelParam | ( | ParamElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::doChannelParameters | ( | ParametersElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::doCompoundModule | ( | CompoundModuleElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doCondition | ( | ConditionElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doConnection | ( | ConnectionElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doConnectionAttributes | ( | ParametersElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::doConnectionGroup | ( | ConnectionGroupElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doConnections | ( | ConnectionsElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doExpression | ( | ExpressionElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doExtends | ( | ExtendsElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doFunction | ( | FunctionElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doGate | ( | GateElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doGates | ( | GatesElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doGatesize | ( | GateElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doIdent | ( | IdentElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doImport | ( | ImportElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doInterfaceName | ( | InterfaceNameElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doLiteral | ( | LiteralElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doLoop | ( | LoopElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doModuleGate | ( | GateElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doModuleGates | ( | GatesElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::doModuleInterface | ( | ModuleInterfaceElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doModuleParam | ( | ParamElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doModuleParameters | ( | ParametersElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::doNedfile | ( | NedFileElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doNedfiles | ( | FilesElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doOperator | ( | OperatorElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doParam | ( | ParamElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doParameters | ( | ParametersElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doProperty | ( | PropertyElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doPropertyDecl | ( | PropertyDeclElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doPropertyKey | ( | PropertyKeyElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doSimpleModule | ( | SimpleModuleElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doSubmodule | ( | SubmoduleElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doSubmoduleGatesizes | ( | GatesElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::doSubmodules | ( | SubmodulesElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doSubstParam | ( | ParamElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
void NED1Generator::doSubstParameters | ( | ParametersElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::doTypes | ( | TypesElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | ||||
) | [protected] |
std::string NED1Generator::generate | ( | NEDElement * | node, | |
const char * | indent | |||
) |
Generates NED code and returns it as a string.
void NED1Generator::generate | ( | std::ostream & | out, | |
NEDElement * | node, | |||
const char * | indent | |||
) |
Generates NED code.
Takes an output stream where the generated NED code will be written, the object tree and the base indentation.
void NED1Generator::generateChildren | ( | NEDElement * | node, | |
const char * | indent, | |||
const char * | arg = NULL | |||
) | [protected] |
Invoke generateNedItem() on all children.
void NED1Generator::generateChildrenWithType | ( | NEDElement * | node, | |
int | tagcode, | |||
const char * | indent, | |||
const char * | arg = 0 | |||
) | [protected] |
Invoke generateNedItem() on all children of the given tagcode.
void NED1Generator::generateChildrenWithTypes | ( | NEDElement * | node, | |
int | tagcodes[], | |||
const char * | indent, | |||
const char * | arg = 0 | |||
) | [protected] |
Invoke generateNedItem() on children of the given tagcodes (NED_NULL-terminated array).
void NED1Generator::generateNedItem | ( | NEDElement * | node, | |
const char * | indent, | |||
bool | islast, | |||
const char * | arg = NULL | |||
) | [protected] |
Dispatch to various doXXX() methods according to node type.
std::string NED1Generator::getBannerComment | ( | NEDElement * | node, | |
const char * | indent | |||
) | [protected] |
std::string NED1Generator::getDisplayStringOf | ( | NEDElement * | node, | |
PropertyElement *& | outDisplayProp | |||
) | [protected] |
std::string NED1Generator::getInlineRightComment | ( | NEDElement * | node | ) | [protected] |
int NED1Generator::getOperatorPrecedence | ( | const char * | op, | |
int | args | |||
) | [protected] |
const char* NED1Generator::getPromptTextOf | ( | ParamElement * | param | ) | [protected] |
std::string NED1Generator::getRightComment | ( | NEDElement * | node | ) | [protected] |
std::string NED1Generator::getTrailingComment | ( | NEDElement * | node | ) | [protected] |
bool NED1Generator::hasExpression | ( | NEDElement * | node, | |
const char * | attr | |||
) | [protected] |
const char* NED1Generator::increaseIndent | ( | const char * | indent | ) | [protected] |
bool NED1Generator::isOperatorLeftAssoc | ( | const char * | op | ) | [protected] |
void NED1Generator::printConnectionGate | ( | NEDElement * | conn, | |
const char * | modname, | |||
const char * | modindexattr, | |||
const char * | gatename, | |||
const char * | gateindexattr, | |||
bool | isplusplus, | |||
int | gatesubg, | |||
const char * | indent | |||
) | [protected] |
void NED1Generator::printExpression | ( | NEDElement * | node, | |
const char * | attr, | |||
const char * | indent | |||
) | [protected] |
void NED1Generator::printInheritance | ( | NEDElement * | node, | |
const char * | indent | |||
) | [protected] |
void NED1Generator::printOptVector | ( | NEDElement * | node, | |
const char * | attr, | |||
const char * | indent | |||
) | [protected] |
void NED1Generator::setIndentSize | ( | int | indentsize | ) |
Sets the indent size in the generated NED code.
Default is 4 spaces.
NEDErrorStore* NED1Generator::errors [protected] |
int NED1Generator::indentsize [protected] |
std::ostream* NED1Generator::outp [protected] |