Puma Reference Manual Puma: Puma::CUnit Class Reference



Puma::CUnit Class Reference

Specialized token unit for C/C++ tokens. More...

#include <Puma/CUnit.h>

Inheritance diagram for Puma::CUnit:
Inheritance graph

List of all members.

Public Member Functions

 CUnit (ErrorSink &err)
 Constructor.
virtual ~CUnit ()
 Destructor.
CScannerscanner () const
 Get the scanner used to scan the string stream.
void scan ()
 Scan the stream now.

Detailed Description

Specialized token unit for C/C++ tokens.

Provides a streaming interface for easy scanning of C/C++ tokens using a Puma::CScanner object. The input stream is scanned either by calling Puma::CUnit::scan() or by using the stream manipulator Puma::endu.

Example:

 Puma::ErrorStream es;
 Puma::CUnit unit(es)
 unit << "int main() {" << std::endl;
 unit << "  int fac0 = 1;" << std::endl;
 for (int i = 1; i < 10; i++) {
   unit << "  int fac" << i << " = " << i 
        << " * fac" << (i-1) << ";" << std::endl;
 }
 unit << "}\n" << Puma::endu;

Constructor & Destructor Documentation

Puma::CUnit::CUnit ( ErrorSink err) [inline]

Constructor.

Parameters:
errThe error stream on which to report errors.
virtual Puma::CUnit::~CUnit ( ) [inline, virtual]

Destructor.


Member Function Documentation

void Puma::CUnit::scan ( )

Scan the stream now.

Produces the token chain.

CScanner& Puma::CUnit::scanner ( ) const [inline]

Get the scanner used to scan the string stream.