Header frame

Top  Previous  Next

Code generation > Code frames > Header frame

 

The unmodified frame for the header is as follows:

 

 

//----------------------------------------------------------

//   ttparser_h.frm

//   TextTransformer C++ Support Frame

//   Author: Dr. Detlef Meyer-Eltz

//   http://www.texttransformer.de

//   http://www.texttransformer.com

//   Meyer-Eltz@t-online.de

//

//   March, 2006  Version 1.1.0

//----------------------------------------------------------

 

 

#ifndef -->ParserHeaderSentinel

#define -->ParserHeaderSentinel

              

              

#ifndef tt_parserH               

#include "tt_parser.h"

#endif

 

#ifndef tt_symbolentryH

#include "tt_symbolentry.h"

#endif

 

// the following includes and the according typedefs can be removed,

// if you don't use them

 

#include "boost/format.hpp"

 

#ifndef tt_mapH

#include "tt_map.h"

#endif

 

#ifndef tt_vectorH

#include "tt_vector.h"

#endif

 

#ifndef tt_nodeH

#include "tt_node.h"

#endif

 

       

namespace tetra

{

 

class -->ParserClassName : public CTT_Parser< -->CharType, -->PluginType >

{   

typedef CTT_Parser< -->CharType, -->PluginType >  inherited;                       

public:

 

typedef CTT_Node<char_type>          node;

typedef CTT_Map<str, bool >          mstrbool;

typedef CTT_Map<str, int >           mstrint;

typedef CTT_Map<str, unsigned int >  mstruint;

typedef CTT_Map<str, char >          mstrchar;

typedef CTT_Map<str, str >           mstrstr;

typedef CTT_Map<str, node >          mstrnode;

typedef CTT_Vector< bool >           vbool;

typedef CTT_Vector< int >            vint;

typedef CTT_Vector< unsigned int >   vuint;

typedef CTT_Vector< char >           vchar;

typedef CTT_Vector< str >            vstr;

typedef CTT_Vector< node >           vnode;

 

 

-->ScannerEnum

 

-->ParserClassName(); 

 

-->StartRuleDeclaration

-->InterfaceDeclarations

 

private:

     

-->ParserRuleDeclarations       

-->InitProcDeclaration

 

};

 

} // namespace tetra

 

 

#endif // -->ParserHeaderSentinel

 

 

The arrow "-->" and the following key word indicate the positions, where the TextTransformer will write the code.

 

-->ParserHeaderSentinel will be replaced by an expression, which is constructed from the name of the start rule of the parser. For example, if this name is "Pascal" the sentinel will look as follows:

 

#ifndef PascalparserH

#define PascalparserH

...

#endif // PascalparserH

 

 

-->ScannerEnum denotes the position, where some enumeration types are defined. The values of the enumerations are indices for the differen mini-scanner.

 

-->ParserClassName is a dummy for the name of the parser class.

 

The second occurrence of -->ParserClassName denotes the constructor of the parser class. Into the following parenthesis additional parameters can be inserted.

 

 

StartRuleDeclaration denotes the public function to call the parser. The name of this function is constructed from the name of the start rule. For example:

 

"void Pascal(cts xtBegin, cts xtEnd);"

 

cts is a typedef for std::string::const_iterator

 

InitProcDeclaration will be replaced by:

 

void Init();

 

This is the declaration of a procedure, by which the member variables are initialized.

 

InterfaceDeclarations is a dummy for the sequence of declarations of functions, by which the parser can be called (beneath the start rule). In the local options create interface must be activated, to stimulate the creation of these functions. The declarations have the same form as the declaration for the start rule.

 

ParserRuleDeclarations denotes the position, where the list of declarations for the productions and sub-classes to scan the input are inserted. So for each production, there will be a function of the same name. Especially the start rule will be declared here:

 

"void Pascal(tetra::sps& xState);"

 

sps is a typedef for CTT_ParserState, a class, which represents the state (especially the positions) of the parsing process, and which is passed and actualized from rule to rule.



This page belongs to the TextTransformer Documentation

Home  Content  German