lestes::lang::cplus::lex::expander Class Reference

Macro expander. More...

#include <expander.hh>

Inheritance diagram for lestes::lang::cplus::lex::expander:

lestes::std::object lestes::std::mem::keystone List of all members.

Public Types

enum  mode_type { NORMAL, DIRECTIVE, FILE_END }
 The modes of input. More...

Public Member Functions

ptr< token_sequenceread_line (void)
 Reads line from input.
ptr< token_sequenceread_expanded (void)
 Reads expanded line from input.
mode_type mode_get (void)
 Returns input mode.

Static Public Member Functions

static ptr< expandercreate (const ptr< pp_filter > &a_input, const ptr< macro_storage > &a_macros)
 Returns new expander.

Protected Member Functions

 expander (const ptr< pp_filter > &a_input, const ptr< macro_storage > &a_macros)
 Creates new expander.
virtual void gc_mark (void)
 Marks the object.

Private Attributes

srp< macro_storagemacros
 The macro storage for expansion.
srp< token_streamstream
 The stream connected to input.

Detailed Description

Macro expander.

Performs reading of possibly expanded lines of tokens.

Definition at line 54 of file expander.hh.


Member Enumeration Documentation

enum lestes::lang::cplus::lex::expander::mode_type

The modes of input.

Enumerator:
NORMAL  Normal mode.
DIRECTIVE  Directive.
FILE_END  End of file.

Definition at line 57 of file expander.hh.

00057                      {
00058                 //! Normal mode.
00059                 NORMAL,
00060                 //! Directive.
00061                 DIRECTIVE,
00062                 //! End of file.
00063                 FILE_END
00064         } mode_type;


Constructor & Destructor Documentation

lestes::lang::cplus::lex::expander::expander ( const ptr< pp_filter > &  a_input,
const ptr< macro_storage > &  a_macros 
) [protected]

Creates new expander.

Creates new expander.

Precondition:
a_input != NULL

a_macros != NULL

Parameters:
a_input The input into the expander.
a_macros The macro storage for macro expansion.

Definition at line 54 of file expander.cc.

Referenced by create().

00054                                                                                    :
00055         macros(checked(a_macros)),
00056         stream(token_stream::create(checked(a_input)))
00057 {
00058 }


Member Function Documentation

ptr< token_sequence > lestes::lang::cplus::lex::expander::read_line ( void   ) 

Reads line from input.

Returns the next line without expansion.

Returns:
The next line.

Definition at line 83 of file expander.cc.

References stream.

00084 {
00085         return stream->read_line();
00086 }

ptr< token_sequence > lestes::lang::cplus::lex::expander::read_expanded ( void   ) 

Reads expanded line from input.

Returs the next line expanded.

Returns:
The expanded line.

Definition at line 92 of file expander.cc.

References macros, and stream.

00093 {
00094         ptr<token_sequence> ts = stream->expand_line(macros);
00095         return ts;
00096 }

expander::mode_type lestes::lang::cplus::lex::expander::mode_get ( void   ) 

Returns input mode.

Returns current mode of the input.

Returns:
The mode of input.

Definition at line 64 of file expander.cc.

References DIRECTIVE, FILE_END, NORMAL, stream, lestes::lang::cplus::lex::pp_token::TOK_HASH, and lestes::lang::cplus::lex::pp_token::TOK_TERMINATOR.

00065 {
00066         ptr<pp_token> tok = stream->peek_front();
00067 
00068         switch (tok->type_get()) {
00069                 case pp_token::TOK_HASH:
00070                         return DIRECTIVE;
00071                 case pp_token::TOK_TERMINATOR:
00072                         return FILE_END;
00073                 default:
00074                         break;
00075         }
00076         return NORMAL;
00077 }

ptr< expander > lestes::lang::cplus::lex::expander::create ( const ptr< pp_filter > &  a_input,
const ptr< macro_storage > &  a_macros 
) [static]

Returns new expander.

Returns new expander.

Precondition:
a_input != NULL

a_macros != NULL

Parameters:
a_input The input into the expander.
a_macros The macro storage for macro expansion.

Definition at line 105 of file expander.cc.

References expander().

00106 {
00107         return new expander(a_input,a_macros);
00108 }

void lestes::lang::cplus::lex::expander::gc_mark ( void   )  [protected, virtual]

Marks the object.

Marks the object.

Reimplemented from lestes::std::mem::keystone.

Definition at line 113 of file expander.cc.

References macros, and stream.

00114 {
00115         macros.gc_mark();
00116         stream.gc_mark();
00117         object::gc_mark();
00118 }


Member Data Documentation

srp<macro_storage> lestes::lang::cplus::lex::expander::macros [private]

The macro storage for expansion.

Definition at line 80 of file expander.hh.

Referenced by gc_mark(), and read_expanded().

srp<token_stream> lestes::lang::cplus::lex::expander::stream [private]

The stream connected to input.

Definition at line 82 of file expander.hh.

Referenced by gc_mark(), mode_get(), read_expanded(), and read_line().


The documentation for this class was generated from the following files:
Generated on Mon Feb 12 18:24:16 2007 for lestes by doxygen 1.5.1-20070107