Puma Reference Manual | Puma: Puma::CUnit Class Reference |
Specialized token unit for C/C++ tokens. More...
#include <Puma/CUnit.h>
Inherits Puma::Unit.
Inherited by Puma::TemplateInstanceUnit.
Public Member Functions | |
CUnit (ErrorSink &err) | |
Constructor. | |
virtual | ~CUnit () |
Destructor. | |
CScanner & | scanner () const |
Get the scanner used to scan the string stream. | |
void | scan () |
Scan the stream now. |
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;
Puma::CUnit::CUnit | ( | ErrorSink & | err | ) | [inline] |
Constructor.
err | The error stream on which to report errors. |
virtual Puma::CUnit::~CUnit | ( | ) | [inline, virtual] |
Destructor.
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.