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

Public Member Functions | |
| bool | parse (const ptr< token_input > &input) |
| Parses argument list. | |
| ulint | length (void) const |
| Returns length of the list. | |
| ptr< macro_argument > | argument_get (ulint index) const |
| Returns argument at specified index. | |
| bool | check (ulint pars_length) const |
| Checks if the arguments match parameter list length. | |
Static Public Member Functions | |
| static ptr< macro_arguments > | create (void) |
| Returns empty list. | |
Protected Member Functions | |
| macro_arguments (void) | |
| Creates empty list. | |
| virtual void | gc_mark (void) |
| Marks the object. | |
Private Types | |
| enum | state_type { BEGIN, PARSED, PARSED_EMPTY, DEAD } |
| Type of internal state. More... | |
| typedef vector< srp< macro_argument > > | arguments_type |
| Type of list of macro arguments. | |
Private Attributes | |
| state_type | state |
| Internal state of the object. | |
| srp< arguments_type > | arguments |
| List of macro arguments. | |
Represents list of macro arguments. Arguments can be empty, which introduces certain ambiguity when dealing with single empty argument, which is the same as no argument at all. Such argument list has state == PARSED_EMPTY, length() == 1 and one empty argument.
Definition at line 56 of file macro_arguments.hh.
typedef vector< srp<macro_argument> > lestes::lang::cplus::lex::macro_arguments::arguments_type [private] |
enum lestes::lang::cplus::lex::macro_arguments::state_type [private] |
Type of internal state.
Definition at line 75 of file macro_arguments.hh.
00075 { BEGIN, PARSED, PARSED_EMPTY, DEAD } state_type;
| lestes::lang::cplus::lex::macro_arguments::macro_arguments | ( | void | ) | [protected] |
| bool lestes::lang::cplus::lex::macro_arguments::parse | ( | const ptr< token_input > & | input | ) |
Parses argument list.
Parses macro argument list in parentheses.
| input | The source for arguments, starting with '(' token. |
Definition at line 62 of file macro_arguments.cc.
References arguments, BEGIN, lestes::lang::cplus::lex::macro_argument::CONTINUE, lestes::lang::cplus::lex::macro_argument::create(), DEAD, lestes::lang::cplus::lex::macro_argument::EMPTY, lassert, lestes::lang::cplus::lex::macro_argument::LAST, PARSED, PARSED_EMPTY, state, and lestes::lang::cplus::lex::pp_token::TOK_LEFT_PAR.
00063 { 00064 lassert(state == BEGIN); 00065 00066 ptr<pp_token> t; 00067 t = input->read_front(); 00068 00069 lassert(t->type_get() == pp_token::TOK_LEFT_PAR); 00070 00071 bool first = true; 00072 macro_argument::result_type result; 00073 00074 do { 00075 ptr<macro_argument> ma = macro_argument::create(); 00076 result = ma->parse(input,first); 00077 first = false; 00078 00079 arguments->push_back(ma); 00080 00081 if (result == macro_argument::EMPTY) { 00082 state = PARSED_EMPTY; 00083 return true; 00084 } 00085 00086 } while (result == macro_argument::CONTINUE); 00087 00088 if (result == macro_argument::LAST) { 00089 state = PARSED; 00090 return true; 00091 } 00092 00093 // else result == macro_argument::ERROR 00094 state = DEAD; 00095 return false; 00096 }
| ulint lestes::lang::cplus::lex::macro_arguments::length | ( | void | ) | const |
Returns length of the list.
Returns length of the argument list.
Definition at line 103 of file macro_arguments.cc.
References arguments, lassert, PARSED, PARSED_EMPTY, and state.
Referenced by argument_get(), and check().
00104 { 00105 lassert(state == PARSED || state == PARSED_EMPTY); 00106 return arguments->size(); 00107 }
| ptr< macro_argument > lestes::lang::cplus::lex::macro_arguments::argument_get | ( | ulint | index | ) | const |
Returns argument at specified index.
Returns argument at specified position.
index < length()
| index | The index of the desired argument. |
Definition at line 129 of file macro_arguments.cc.
References arguments, lassert, length(), PARSED, PARSED_EMPTY, and state.
00130 { 00131 lassert(state == PARSED || state == PARSED_EMPTY); 00132 lassert(index < length()); 00133 return arguments->at(index); 00134 }
| bool lestes::lang::cplus::lex::macro_arguments::check | ( | ulint | pars_length | ) | const |
Checks if the arguments match parameter list length.
Checks whether the arguments match the length of a parameter list. Either the lengths are the same, or there is no parameters and the argument list is empty.
Definition at line 116 of file macro_arguments.cc.
References lassert, length(), PARSED, PARSED_EMPTY, and state.
00117 { 00118 lassert(state == PARSED || state == PARSED_EMPTY); 00119 return length() == pars_length || (pars_length == 0 && state == PARSED_EMPTY); 00120 }
| ptr< macro_arguments > lestes::lang::cplus::lex::macro_arguments::create | ( | void | ) | [static] |
Returns empty list.
Returns new empty argument list.
length() == 0
Definition at line 150 of file macro_arguments.cc.
References macro_arguments().
Referenced by lestes::lang::cplus::lex::macro::expand().
00151 { 00152 return new macro_arguments(); 00153 }
| void lestes::lang::cplus::lex::macro_arguments::gc_mark | ( | void | ) | [protected, virtual] |
Marks the object.
Marks the object.
Reimplemented from lestes::std::mem::keystone.
Definition at line 139 of file macro_arguments.cc.
References arguments, and lestes::std::mem::keystone::gc_mark().
00140 { 00141 arguments.gc_mark(); 00142 ::lestes::std::object::gc_mark(); 00143 }
Internal state of the object.
Definition at line 77 of file macro_arguments.hh.
Referenced by argument_get(), check(), length(), and parse().
List of macro arguments.
Definition at line 81 of file macro_arguments.hh.
Referenced by argument_get(), gc_mark(), length(), and parse().
1.5.1-20070107