lestes::lang::cplus::lex::unit_part Class Reference

Part of translation unit. More...

#include <unit_part.hh>

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

lestes::lang::cplus::lex::pp_filter lestes::std::object lestes::std::mem::keystone List of all members.

Public Member Functions

void start_of_line (void)
 Sets start of line flag.
ptr< condition_stackconditions_get (void) const
 Returns associated condition stack.
ptr< expanderexpander_get (void) const
 Returs associated expander.
ptr< line_controlline_control_get (void) const
 Returs the line control.
ptr< pp_tokenread (void)
 Reads next token.

Static Public Member Functions

static ptr< unit_partcreate (const ptr< file_info > &a_file, const ptr< data_source > &a_data, const ptr< encoder > &a_encoder, const ptr< macro_storage > &a_macros)
 Returns new unit, initializes with file information, data source and encoder.

Protected Member Functions

 unit_part (const ptr< file_info > &a_file, const ptr< data_source > &a_data, const ptr< encoder > &a_encoder, const ptr< macro_storage > &a_macros)
 Creates new unit, initializes with file information, data source and encoding.
virtual void gc_mark (void)
 Marks the object.

Private Member Functions

 unit_part (const unit_part &)
 Hides copy constructor.
unit_partoperator= (const unit_part &)
 Hides assignment operator.

Private Attributes

bool start
 Start of line flag.
srp< condition_stackconditions
 Conditions stack.
srp< encoderenc
 Character set encoder.
srp< data_sourceds
 Data source.
srp< pre_lexplx
 Operations prior to lexical analysis.
srp< line_controllic
 Line control.
srp< pp_lexppl
 Flex wrapper.
srp< expanderexp
 Expander.

Detailed Description

Part of translation unit.

Represents a part of translation unit, which is either the original source file itself, or any file included by the source file.

Definition at line 69 of file unit_part.hh.


Constructor & Destructor Documentation

lestes::lang::cplus::lex::unit_part::unit_part ( const ptr< file_info > &  a_file,
const ptr< data_source > &  a_data,
const ptr< encoder > &  a_encoder,
const ptr< macro_storage > &  a_macros 
) [protected]

Creates new unit, initializes with file information, data source and encoding.

Creates the object.

Precondition:
a_file != NULL

a_data != NULL

a_encoder != NULL

a_macros != NULL

Parameters:
a_file The file information.
a_data The data source.
a_encoder The encoder for the source.
a_macros The defined macros.

Definition at line 65 of file unit_part.cc.

Referenced by create().

00066                                                                                   :
00067         start(false),
00068         conditions(condition_stack::create()),
00069         enc(checked(a_encoder)),
00070         ds(checked(a_data)),
00071         plx(pre_lex::create(ds,enc)),
00072         lic(line_control::create(checked(a_file))),
00073         ppl(pp_lex::create(plx,lic)),
00074         exp(expander::create(this,checked(a_macros)))
00075 {
00076 }

lestes::lang::cplus::lex::unit_part::unit_part ( const unit_part  )  [private]

Hides copy constructor.


Member Function Documentation

void lestes::lang::cplus::lex::unit_part::start_of_line ( void   ) 

Sets start of line flag.

Sets start of line flag to help pp_lex switch to read tokens within include. The flag is cleared automatically after first call to read().

Definition at line 90 of file unit_part.cc.

References start.

00091 {
00092         start = true;
00093 }

ptr< condition_stack > lestes::lang::cplus::lex::unit_part::conditions_get ( void   )  const

Returns associated condition stack.

Returns associated condition stack.

Returns:
The condition stack.

Definition at line 99 of file unit_part.cc.

References conditions.

00100 {
00101         return conditions;
00102 }

ptr< expander > lestes::lang::cplus::lex::unit_part::expander_get ( void   )  const

Returs associated expander.

Returns the associated expander.

Returns:
The expander connected to this unit part.

Definition at line 108 of file unit_part.cc.

References exp.

00109 {
00110         return exp;
00111 }

ptr< line_control > lestes::lang::cplus::lex::unit_part::line_control_get ( void   )  const

Returs the line control.

Returns the associated line control.

Returns:
The line control.

Definition at line 118 of file unit_part.cc.

References lic.

00119 {
00120         return lic;
00121 }

ptr< pp_token > lestes::lang::cplus::lex::unit_part::read ( void   )  [virtual]

Reads next token.

Reads next token from the unit part. Updates token location by the relative location.

Returns:
The next token in the unit part.

Implements lestes::lang::cplus::lex::pp_filter.

Definition at line 144 of file unit_part.cc.

References ppl, and start.

00145 {
00146         // TODO pt check and emit errors, with changed locations
00147         // if (ppl->has_errors()) {
00148         // ppl->errors_get();
00149         // process
00150         // }
00151         
00152         ptr<pp_token> tok = ppl->read(start);
00153         start = false;
00154 
00155         // TODO pt update location
00156         // what the hell ???
00157         // this is obsolete
00158 
00159         return tok;
00160 }

ptr< unit_part > lestes::lang::cplus::lex::unit_part::create ( const ptr< file_info > &  a_file,
const ptr< data_source > &  a_data,
const ptr< encoder > &  a_encoder,
const ptr< macro_storage > &  a_macros 
) [static]

Returns new unit, initializes with file information, data source and encoder.

Returns new instance, initializes with file information, stream and encoding.

Parameters:
a_file The file information for the unit part.
a_data The data source.
a_encoder The encoder for the source.
a_macros The defined macros.
Returns:
New instance of the class.

Definition at line 185 of file unit_part.cc.

References unit_part().

Referenced by lestes::lang::cplus::lex::evaluator::push_stream().

00188 {
00189         return new unit_part(a_file,a_data,a_encoder,a_macros);
00190 }

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

Marks the object.

Marks the object.

Reimplemented from lestes::lang::cplus::lex::pp_filter.

Definition at line 165 of file unit_part.cc.

References conditions, ds, enc, exp, lestes::lang::cplus::lex::pp_filter::gc_mark(), lic, plx, and ppl.

00166 {
00167         conditions.gc_mark();
00168         enc.gc_mark();
00169         ds.gc_mark();
00170         plx.gc_mark();
00171         lic.gc_mark();
00172         ppl.gc_mark();
00173         exp.gc_mark();
00174         pp_filter::gc_mark();
00175 }

unit_part& lestes::lang::cplus::lex::unit_part::operator= ( const unit_part  )  [private]

Hides assignment operator.


Member Data Documentation

bool lestes::lang::cplus::lex::unit_part::start [private]

Start of line flag.

Definition at line 105 of file unit_part.hh.

Referenced by read(), and start_of_line().

srp<condition_stack> lestes::lang::cplus::lex::unit_part::conditions [private]

Conditions stack.

Definition at line 107 of file unit_part.hh.

Referenced by conditions_get(), and gc_mark().

srp<encoder> lestes::lang::cplus::lex::unit_part::enc [private]

Character set encoder.

Definition at line 109 of file unit_part.hh.

Referenced by gc_mark().

srp<data_source> lestes::lang::cplus::lex::unit_part::ds [private]

Data source.

Definition at line 111 of file unit_part.hh.

Referenced by gc_mark().

srp<pre_lex> lestes::lang::cplus::lex::unit_part::plx [private]

Operations prior to lexical analysis.

Definition at line 113 of file unit_part.hh.

Referenced by gc_mark().

srp<line_control> lestes::lang::cplus::lex::unit_part::lic [private]

Line control.

Definition at line 115 of file unit_part.hh.

Referenced by gc_mark(), and line_control_get().

srp<pp_lex> lestes::lang::cplus::lex::unit_part::ppl [private]

Flex wrapper.

Definition at line 117 of file unit_part.hh.

Referenced by gc_mark(), and read().

srp<expander> lestes::lang::cplus::lex::unit_part::exp [private]

Expander.

Definition at line 119 of file unit_part.hh.

Referenced by expander_get(), and gc_mark().


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