#include <macro_item.hh>
Inheritance diagram for lestes::lang::cplus::lex::macro_item:

Public Types | |
| enum | action_type { LITERAL, EXPANSION, COPY, STR, CONCAT } |
| Type of action performed within the item. More... | |
| typedef ulint | index_type |
| Type of index of macro parameter. | |
Public Member Functions | |
| action_type | action_get (void) const |
| Returns action to be performed. | |
| ptr< token_sequence > | value_get (void) const |
| Returns value of literal or glue token. | |
| index_type | index_get (void) const |
| Returns index of referenced macro parameter. | |
| bool | blank_get (void) const |
| Returns blank flag. | |
| bool | equals (const ptr< macro_item > &other) const |
| Tests equality. | |
Static Public Member Functions | |
| static ptr< macro_item > | create_literal (const ptr< token_sequence > &a_value) |
| Returns literal macro item. | |
| static ptr< macro_item > | create_expansion (index_type a_index) |
| Returns expansion macro item. | |
| static ptr< macro_item > | create_copy (index_type a_index) |
| Returns copy macro item. | |
| static ptr< macro_item > | create_str (index_type a_index, const ptr< token_sequence > &a_value) |
| Returns stringification macro item. | |
| static ptr< macro_item > | create_concat (const ptr< token_sequence > &a_value) |
| Returns concatenation macro item. | |
Protected Member Functions | |
| macro_item (action_type a_action, index_type a_index, const ptr< token_sequence > &a_value) | |
| Creates item. | |
| virtual void | gc_mark (void) |
| Marks the object. | |
Private Attributes | |
| action_type | action |
| Action to be performed. | |
| index_type | index |
| Index of referenced macro parameter. | |
| srp< token_sequence > | value |
| Value of literal or operation token wrapped in sequence. | |
Represents of part of macro expansion list. Used as an element in macro_body.
Definition at line 54 of file macro_item.hh.
| typedef ulint lestes::lang::cplus::lex::macro_item::index_type |
Type of action performed within the item.
| LITERAL | Insert literal value. |
| EXPANSION | Insert expanded parameter. |
| COPY | Insert copy of parameter. |
| STR | Insert stringification of parameter. |
| CONCAT | Insert concatenation of adjacent tokens. |
Definition at line 57 of file macro_item.hh.
00057 { 00058 //! Insert literal value. 00059 LITERAL, 00060 //! Insert expanded parameter. 00061 EXPANSION, 00062 //! Insert copy of parameter. 00063 COPY, 00064 //! Insert stringification of parameter. 00065 STR, 00066 //! Insert concatenation of adjacent tokens. 00067 CONCAT 00068 } action_type;
| lestes::lang::cplus::lex::macro_item::macro_item | ( | action_type | a_action, | |
| index_type | a_index, | |||
| const ptr< token_sequence > & | a_value | |||
| ) | [protected] |
Creates item.
Creates item object, not all parameters are valid for every action type. No checks of consistency are done on this level.
| a_action | The action represented by the item. | |
| a_index | The index of parameter for expand, nonexpand and stringify actions. | |
| a_value | The value of item for literal and operators. |
Definition at line 117 of file macro_item.cc.
Referenced by create_concat(), create_copy(), create_expansion(), create_literal(), and create_str().
| macro_item::action_type lestes::lang::cplus::lex::macro_item::action_get | ( | void | ) | const |
Returns action to be performed.
Returns action of the macro item.
Definition at line 128 of file macro_item.cc.
Referenced by equals(), index_get(), and value_get().
00129 { 00130 return action; 00131 }
| ptr< token_sequence > lestes::lang::cplus::lex::macro_item::value_get | ( | void | ) | const |
Returns value of literal or glue token.
Returns value of stored token sequence literal.
Definition at line 138 of file macro_item.cc.
References action_get(), COPY, EXPANSION, lassert, and value.
00139 { 00140 lassert(action_get() != EXPANSION && action_get() != COPY); 00141 return value->clone(); 00142 }
| macro_item::index_type lestes::lang::cplus::lex::macro_item::index_get | ( | void | ) | const |
Returns index of referenced macro parameter.
Returns index of the macro parameter.
Definition at line 149 of file macro_item.cc.
References action_get(), COPY, EXPANSION, index, lassert, and STR.
Referenced by equals().
00150 { 00151 lassert(action_get() == EXPANSION || action_get() == COPY || action_get() == STR); 00152 return index; 00153 }
| bool lestes::lang::cplus::lex::macro_item::blank_get | ( | void | ) | const |
Returns blank flag.
| bool lestes::lang::cplus::lex::macro_item::equals | ( | const ptr< macro_item > & | other | ) | const |
Tests equality.
Tests equality to other macro item. Only fields relevant for selected actions are compared.
| other | The macro item to compare with. |
Definition at line 160 of file macro_item.cc.
References action_get(), CONCAT, COPY, EXPANSION, index_get(), lestes::is_equal(), lassert2, LITERAL, STR, and value.
00161 { 00162 if (!other || action_get() != other->action_get()) return false; 00163 00164 // TODO pt make resembles back equals 00165 switch (action_get()) { 00166 case LITERAL: 00167 return value->congruent(other->value); 00168 case EXPANSION: 00169 case COPY: 00170 return is_equal(index_get(),other->index_get()); 00171 case STR: 00172 return is_equal(index_get(),other->index_get()) && value->congruent(other->value); 00173 case CONCAT: 00174 return value->congruent(other->value); 00175 default: 00176 lassert2(false,"You should never get here"); 00177 } 00178 return false; 00179 }
| ptr< macro_item > lestes::lang::cplus::lex::macro_item::create_literal | ( | const ptr< token_sequence > & | a_value | ) | [static] |
Returns literal macro item.
Returns literal macro item, initializes with a_value.
| a_value | The initialization value. |
Definition at line 53 of file macro_item.cc.
References lassert, LITERAL, and macro_item().
Referenced by lestes::lang::cplus::lex::macro_body::parse().
00054 { 00055 lassert(a_value); 00056 // the index and blank is not used 00057 return new macro_item(LITERAL,0,a_value->clone()); 00058 }
| ptr< macro_item > lestes::lang::cplus::lex::macro_item::create_expansion | ( | index_type | a_index | ) | [static] |
Returns expansion macro item.
Returns expansion macro item, initializes with a_index.
| a_index | The index of referenced parameter. |
Definition at line 65 of file macro_item.cc.
References EXPANSION, and macro_item().
Referenced by lestes::lang::cplus::lex::macro_body::parse().
00066 { 00067 // the value parameter is not used 00068 return new macro_item(EXPANSION,a_index,NULL); 00069 }
| ptr< macro_item > lestes::lang::cplus::lex::macro_item::create_copy | ( | index_type | a_index | ) | [static] |
Returns copy macro item.
Returns copy macro item, initializes with a_index.
| a_index | The index of referenced parameter. |
Definition at line 76 of file macro_item.cc.
References COPY, and macro_item().
Referenced by lestes::lang::cplus::lex::macro_body::parse().
00077 { 00078 // the value and blank is not used 00079 return new macro_item(COPY,a_index,NULL); 00080 }
| ptr< macro_item > lestes::lang::cplus::lex::macro_item::create_str | ( | index_type | a_index, | |
| const ptr< token_sequence > & | a_value | |||
| ) | [static] |
Returns stringification macro item.
Returns stringification macro item, initializes with index and blank flag.
| a_index | The index of referenced parameter. | |
| a_value | The stringification operator with optional space. |
Definition at line 89 of file macro_item.cc.
References lassert, macro_item(), and STR.
Referenced by lestes::lang::cplus::lex::macro_body::parse().
00090 { 00091 lassert(a_value); 00092 // the value is not used 00093 return new macro_item(STR,a_index,a_value->clone()); 00094 }
| ptr< macro_item > lestes::lang::cplus::lex::macro_item::create_concat | ( | const ptr< token_sequence > & | a_value | ) | [static] |
Returns concatenation macro item.
Returns concatenation macro item, initializes with sequence containing a_token.
| a_value | The concatenation operator. |
Definition at line 102 of file macro_item.cc.
References CONCAT, lassert, and macro_item().
Referenced by lestes::lang::cplus::lex::macro_body::parse().
00103 { 00104 lassert(a_value); 00105 00106 // the index and blank is not used 00107 return new macro_item(CONCAT,0,a_value->clone()); 00108 }
| void lestes::lang::cplus::lex::macro_item::gc_mark | ( | void | ) | [protected, virtual] |
Marks the object.
Marks the object.
Reimplemented from lestes::std::mem::keystone.
Definition at line 184 of file macro_item.cc.
References value.
00185 { 00186 value.gc_mark(); 00187 object::gc_mark(); 00188 }
Index of referenced macro parameter.
Definition at line 100 of file macro_item.hh.
Referenced by index_get().
srp<token_sequence> lestes::lang::cplus::lex::macro_item::value [private] |
Value of literal or operation token wrapped in sequence.
Definition at line 102 of file macro_item.hh.
Referenced by equals(), gc_mark(), and value_get().
1.5.1-20070107