lestes::lang::cplus::lex::macro_argument Class Reference

Macro argument. More...

#include <macro_argument.hh>

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

Inheritance graph
[legend]
List of all members.

Public Types

enum  state_type { BEGIN, PARSED, DEAD }
 Type of internal state. More...
enum  result_type { CONTINUE, LAST, ERROR, EMPTY }
 Parse result type. More...

Public Member Functions

result_type parse (const ptr< token_input > &input, bool first)
 Parses argument.
state_type state_get (void) const
 Returns internal state.
ptr< token_sequencenonexpanded_get (void) const
 Returns nonexpanded argument.
ptr< token_sequenceexpanded_get (const ptr< macro_storage > &macros)
 Returns expanded argument.
ptr< token_sequencestringified_get (void)
 Returns stringified argument.
bool equals (const ptr< macro_argument > &other) const
 Test equality.

Static Public Member Functions

static ptr< macro_argumentcreate (void)
 Returns new instance.

Protected Member Functions

 macro_argument (void)
 Creates empty object.
virtual void gc_mark (void)
 Marks the object.

Private Attributes

state_type state
 Internal state of the object.
srp< token_sequencenonexpanded
 The nonexpanded sequence.
srp< token_sequenceexpanded
 The expanded sequence, lazy evaluated.
srp< token_sequencestringified
 The stringified sequence as a token in sequence, lazy evaluated.

Detailed Description

Macro argument.

Encapsulates macro argument with lazy evaluation. Provides nonexpanded, expanded and stringified representation of the argument.


Member Enumeration Documentation

enum lestes::lang::cplus::lex::macro_argument::state_type

Type of internal state.

Enumerator:
BEGIN 
PARSED 
DEAD 

enum lestes::lang::cplus::lex::macro_argument::result_type

Parse result type.

Enumerator:
CONTINUE  The arguments will continue.
LAST  The last argument in the list.
ERROR  Error in argument.
EMPTY  The first argument is empty.


Constructor & Destructor Documentation

lestes::lang::cplus::lex::macro_argument::macro_argument ( void   )  [protected]

Creates empty object.

Creates empty macro argument.

Postcondition:
state == BEGIN

nonexpanded == NULL

expanded == NULL

stringified == NULL


Member Function Documentation

macro_argument::result_type lestes::lang::cplus::lex::macro_argument::parse ( const ptr< token_input > &  input,
bool  first 
)

Parses argument.

Parses single argument of macro. Front and back whitespace is discarded, newlines are converted to spaces. Value is stored into nonexpanded.

Precondition:
parse() was not called yet.
Postcondition:
state == DEAD || nonexpanded == contents of front part of input
Parameters:
input The source for arguments, parsed tokens (including terminating ones) are removed.
first true If the argument is first in the argument list.
Returns:
macro_argument::LAST When top level right parenthesis was encountered.

macro_argument::EMPTY When first argument was empty.

macro_argument::CONTINUE When top level comma was encountered.

macro_argument::ERROR For end of file inside input.

macro_argument::state_type lestes::lang::cplus::lex::macro_argument::state_get ( void   )  const

Returns internal state.

Returns internal state of the object.

Returns:
The internal state of the object.

ptr< token_sequence > lestes::lang::cplus::lex::macro_argument::nonexpanded_get ( void   )  const

Returns nonexpanded argument.

Returns the nonexpanded macro argument.

Precondition:
parse() != ERROR
Returns:
The nonexpanded token sequence.

ptr< token_sequence > lestes::lang::cplus::lex::macro_argument::expanded_get ( const ptr< macro_storage > &  macros  ) 

Returns expanded argument.

Returns the completely expanded macro argument. Expansion is performed only once.

Precondition:
parse() != ERROR
Returns:
The completely expanded token sequence.

ptr< token_sequence > lestes::lang::cplus::lex::macro_argument::stringified_get ( void   ) 

Returns stringified argument.

Returns stringified macro argument. Stringification is performed only once.

Precondition:
parse() != ERROR
Returns:
Token sequence containing single token with value equal to the stringified token sequence.

bool lestes::lang::cplus::lex::macro_argument::equals ( const ptr< macro_argument > &  other  )  const

Test equality.

Tests equality to other macro argument. Only the nonexpanded sequences are compared.

Parameters:
other The macro argument to compare with.
Returns:
true If both the objects are equal.

ptr< macro_argument > lestes::lang::cplus::lex::macro_argument::create ( void   )  [static]

Returns new instance.

Returns new empty macro argument.

Postcondition:
state == BEGIN

nonexpanded == NULL

expanded == NULL

stringified == NULL

Returns:
New instance of the object.

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

Marks the object.

Marks the object.

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


Member Data Documentation

state_type lestes::lang::cplus::lex::macro_argument::state [private]

Internal state of the object.

srp<token_sequence> lestes::lang::cplus::lex::macro_argument::nonexpanded [private]

The nonexpanded sequence.

srp<token_sequence> lestes::lang::cplus::lex::macro_argument::expanded [private]

The expanded sequence, lazy evaluated.

srp<token_sequence> lestes::lang::cplus::lex::macro_argument::stringified [private]

The stringified sequence as a token in sequence, lazy evaluated.


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