lestes::lang::cplus::lex::macro Class Reference

Preprocessor macro. More...

#include <macro.hh>

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

Inheritance graph
[legend]
List of all members.

Public Member Functions

ptr< source_location > location_get (void) const
 Returns definition location.
ptr< token_valuename_get (void) const
 Returns macro name.
bool funlike_get (void) const
 Returns function-like flag.
bool predefined_get (void) const
 Returns predefined flag.
ptr< token_sequenceexpand (const ptr< pp_token > &name, const ptr< token_input > &input, const ptr< macro_storage > &macros)
 Expands macro.
bool parse (const ptr< token_input > &ts)
 Parses the macro definition.
bool equals (const ptr< macro > &other) const
 Tests equality.

Static Public Member Functions

static ptr< macrocreate (void)
 Creates empty object.
static ptr< macrocreate_predefined (void)
 Creates predefined macro.

Protected Member Functions

 macro (void)
 Constructs empty object.
virtual void gc_mark (void)
 Marks the object.

Private Types

enum  state_type { BEGIN, PARSED, DEAD }
 Type of internal state. More...

Private Member Functions

bool parse_name (const ptr< token_input > &input)
 Parses name.
bool parse_head (const ptr< token_input > &input)
 Parses parameter list.
bool parse_body (const ptr< token_input > &input)
 Parses expansion list.

Private Attributes

state_type state
 Internal state of the object.
srp< source_location > location
 Location of definition.
srp< token_valuename
 Name of the macro.
bool funlike
 Flag designating function-like macro.
bool predefined
 Flag designating predefined macro.
srp< macro_headhead
 Parameter list of the macro.
srp< macro_bodybody
 Expansion list of the macro.

Detailed Description

Preprocessor macro.

Represents stored preprocessor macro.


Member Enumeration Documentation

enum lestes::lang::cplus::lex::macro::state_type [private]

Type of internal state.

Enumerator:
BEGIN 
PARSED 
DEAD 


Constructor & Destructor Documentation

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

Constructs empty object.

Creates new empty macro object.

Postcondition:
state == BEGIN


Member Function Documentation

ptr< source_location > lestes::lang::cplus::lex::macro::location_get ( void   )  const

Returns definition location.

Returns the location of definition.

Precondition:
state == PARSED
Returns:
The location of the macro name in the define.

ptr< token_value > lestes::lang::cplus::lex::macro::name_get ( void   )  const

Returns macro name.

Returns the name of the macro.

Precondition:
state == PARSED
Returns:
The name of the macro.

bool lestes::lang::cplus::lex::macro::funlike_get ( void   )  const

Returns function-like flag.

Returns whether the macro is function-like.

Precondition:
state == PARSED
Returns:
true If the macro is function-like.

bool lestes::lang::cplus::lex::macro::predefined_get ( void   )  const

Returns predefined flag.

Returns predefined flag.

Precondition:
state == PARSED
Returns:
true If the macro is predefined.

ptr< token_sequence > lestes::lang::cplus::lex::macro::expand ( const ptr< pp_token > &  a_name,
const ptr< token_input > &  input,
const ptr< macro_storage > &  macros 
)

Expands macro.

Expands this macro, if the call matches the definition, taking possible arguments from input.

Parameters:
input The source of possible arguments, starting at macro name.
loc The location of the macro expansion.
Returns:
The sequence containing the token denoting the name if the call did not match.

The expanded, but not rescanned sequence if the call matched the definition.

NULL in case of nested error.

bool lestes::lang::cplus::lex::macro::parse ( const ptr< token_input > &  input  ) 

Parses the macro definition.

Parses macro definition and stores data into self.

Precondition:
state == BEGIN
Parameters:
input The source for tokens, starting before macro name.
Returns:
false In case of parse error.

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

Tests equality.

Returns whether macro definitions are equal.

Parameters:
other The macro to compare with.
Returns:
true If the definition is equal to other.

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

Creates empty object.

Returns empty macro.

Postcondition:
state == BEGIN
Returns:
A new empty instance of macro.

static ptr<macro> lestes::lang::cplus::lex::macro::create_predefined ( void   )  [static]

Creates predefined macro.

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

Marks the object.

Marks the object.

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

bool lestes::lang::cplus::lex::macro::parse_name ( const ptr< token_input > &  input  )  [private]

Parses name.

Parses macro name and stores into self.

Parameters:
input The source for tokens, starting before macro name.
Returns:
false In case of parse error.

bool lestes::lang::cplus::lex::macro::parse_head ( const ptr< token_input > &  input  )  [private]

Parses parameter list.

Parses macro parameter list, sets funlike and stores parameters into self.

Parameters:
input The source for tokens, starting after macro name.
Returns:
false In case of duplicate parameters or unterminated parameter list.

bool lestes::lang::cplus::lex::macro::parse_body ( const ptr< token_input > &  input  )  [private]

Parses expansion list.

Parses macro replacement list and stores values into self.

Parameters:
input The source for tokens, starting at the beginning of the replacement list.
Returns:
false If the replacement list was ill-formed.


Member Data Documentation

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

Internal state of the object.

srp<source_location> lestes::lang::cplus::lex::macro::location [private]

Location of definition.

srp<token_value> lestes::lang::cplus::lex::macro::name [private]

Name of the macro.

bool lestes::lang::cplus::lex::macro::funlike [private]

Flag designating function-like macro.

bool lestes::lang::cplus::lex::macro::predefined [private]

Flag designating predefined macro.

srp<macro_head> lestes::lang::cplus::lex::macro::head [private]

Parameter list of the macro.

srp<macro_body> lestes::lang::cplus::lex::macro::body [private]

Expansion list of the macro.


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