Implementation frame

Top  Previous  Next

Code generation > Code frames > Implementation frame

 

The unmodified frame for the implementation of a parser class is as follows:

 

 

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

//   ttparser_cpp.frm

//   TextTransformer C++ Support Frame

//   Copyright: Dr. Detlef Meyer-Eltz

//   http://www.texttransformer.de

//   http://www.texttransformer.com

//   Meyer-Eltz@t-online.de

//

//   March, 2006  Version 1.1.0

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

 

 

#ifdef __BORLANDC__

#pragma hdrstop

#endif

 

 

#include "-->ParserHeaderName"

#include <iostream>

#include "tt_exception.h"

#include "tt_guard.h"

#include "tt_localscanner.h"

#include "tt_parsestateplugin.h"

#include "tt_scanner.h"

 

#define indent xState.GetPlugin()->GetIndentPtr()                          

                                                  

using namespace std;

using namespace tetra;

// return types

typedef -->ParserClassName::node node;

typedef -->ParserClassName::str str;

 

 

-->TokenList

                               

             

-->ParserClassName::-->ParserClassName()

-->MemberInitialization

{

try

{

   CreateScannerArray(eScannerLast);

   Init();

}

catch(boost::regex_error& xErr)

{

   cleanup();

   throw CTT_Message(xErr.what());

}

catch(CTT_Message& eMsg)

{

   cleanup();

   // did you use the actual token file?

   throw eMsg;

}

catch(...)   // std::bad_alloc

{

   cleanup();

   // did you use the actual token file?

   throw CTT_Message("parser creation failed");

}

}

 

-->StartRuleHeading

{

-->StartRule

}

        

-->InitProcImplementation

 

-->InterfaceImplementations

  

-->ParserRules

 

 

 

-->ParserHeaderName becomes to Pascalparser.h, remaining at the example of the previous page.

 

-->TokenList will be replaced by a list of the names and definitions of the tokens. This list helps to understand the following code.

 

-->ParserClassName has the same meaning as explained above. Inside the parenthesis behind the second occurrence of this dummy, you can write declarations of parameters according to those in the header.

 

-->MemberInitialization, is used to for the initialization of member variables, as e.g. functions tables.

 

-->StartRuleHeading corresponds to ParserCallDeclaration of the header frame. This is the heading of the public function to call the parser.

 

-->StartRule is a placeholder for the function block of the function, by which the parser is called. You can include it by a try catch block, if desired.

 

-->InitProcImplementation is the place, where the procedure will be inserted, by which the class variables are initialized.

 

-->InterfaceImplementations is the dummy of the sequence of interface methods, created because of the activation in the local options.

 

 

-->ParserRules finally is the position, where the implementations of the functions will be written, which are corresponding to the productions.

 



This page belongs to the TextTransformer Documentation

Home  Content  German