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

Public Types | |
| typedef char | char_type |
| Type of character in flex. | |
| typedef int | size_type |
| Type of size in flex. | |
Public Member Functions | |
| virtual | ~concat (void) |
| Finalizes object. | |
| size_type | yy_input (char_type *cbuf, size_type max) |
| Stores next characters for YY_INPUT. | |
| ptr< token_sequence > | process (const ptr< pp_token > &left, const ptr< pp_token > &right) |
| Performs token concatenation. | |
Static Public Member Functions | |
| static ptr< concat > | instance (void) |
| Returns the only instance. | |
Protected Member Functions | |
| concat (void) | |
| Creates the object. | |
| virtual void | gc_mark (void) |
| Marks the object. | |
Private Types | |
| typedef concat_guts::yy_buffer_state * | yy_buffer_type |
| Type of flex buffer. | |
Private Member Functions | |
| concat (const concat ©) | |
| Hides copy constructor. | |
| concat & | operator= (const concat &rhs) |
| Hides assignment operator. | |
Private Attributes | |
| yy_buffer_type | yy_buffer |
| Flex buffer. | |
| ucn_string | value |
| Current value of input string. | |
| ucn_string::size_type | index |
| Current index in the input. | |
| ucn_string::size_type | length |
| Current length of the input. | |
Static Private Attributes | |
| static ptr< concat > | singleton |
| The only instance. | |
Performs token concatenation. Handles integration with concat_guts flexer.
Definition at line 61 of file concat.hh.
| typedef char lestes::lang::cplus::lex::concat::char_type |
| typedef int lestes::lang::cplus::lex::concat::size_type |
typedef struct concat_guts::yy_buffer_state* lestes::lang::cplus::lex::concat::yy_buffer_type [read, private] |
| lestes::lang::cplus::lex::concat::~concat | ( | void | ) | [virtual] |
Finalizes object.
Finalizes the object, releases flex buffer.
Definition at line 67 of file concat.cc.
References yy_buffer, and yy_delete_buffer().
00068 { 00069 concat_guts::yy_delete_buffer(yy_buffer); 00070 }
| lestes::lang::cplus::lex::concat::concat | ( | void | ) | [protected] |
Creates the object.
Creates the object, allocates flex buffer.
Definition at line 58 of file concat.cc.
References yy_buffer, and yy_switch_to_buffer().
Referenced by instance().
00058 : 00059 yy_buffer(concat_guts::yy_new_buffer(NULL,YY_BUF_SIZE)) 00060 { 00061 concat_guts::yy_switch_to_buffer(yy_buffer); 00062 }
| lestes::lang::cplus::lex::concat::concat | ( | const concat & | copy | ) | [private] |
Hides copy constructor.
| concat::size_type lestes::lang::cplus::lex::concat::yy_input | ( | char_type * | cbuf, | |
| size_type | max | |||
| ) |
Stores next characters for YY_INPUT.
Fills buffer with characters from current input string. Called through YY_INPUT flex macro.
| cbuf | The buffer to fill. | |
| max | Maximum count of characters to fill. |
Definition at line 125 of file concat.cc.
References index, length, lestes::lang::cplus::lex::ucn_token::TOK_EOF, lestes::lang::cplus::lex::ucn_token::TOK_TRANSLATED, u, value, and YY_NULL.
00126 { 00127 size_type cnt; 00128 00129 if (index == length) return YY_NULL; 00130 00131 // put all tokens up to max into buffer 00132 for (cnt = 0; cnt < max; cnt++) { 00133 if (index == length) { 00134 *cbuf++ = static_cast<char_type>(ucn_token::TOK_EOF); 00135 cnt++; 00136 break; 00137 } 00138 ucn u = value[index++]; 00139 if (character::is_basic(u)) { 00140 *cbuf++ = static_cast<char_type>(character::extract_value(u)); 00141 } else { 00142 *cbuf++ = static_cast<char_type>(ucn_token::TOK_TRANSLATED); 00143 } 00144 } 00145 00146 return cnt; 00147 }
| ptr< token_sequence > lestes::lang::cplus::lex::concat::process | ( | const ptr< pp_token > & | left, | |
| const ptr< pp_token > & | right | |||
| ) |
Performs token concatenation.
Atttempts to concatenate two tokens.
| left | The left token to concatenate. | |
| right | The right token to concatenate. |
Definition at line 79 of file concat.cc.
References concat_parse(), lestes::lang::cplus::lex::token_value::create(), lestes::lang::cplus::lex::token_sequence::create(), index, lassert, length, lestes::report, lestes::lang::cplus::lex::unable_to_concatenate, value, and yyrestart().
00080 { 00081 lassert(left || right); 00082 00083 ptr<token_sequence> result = token_sequence::create(); 00084 ptr<source_location> loc; 00085 00086 value = ""; 00087 00088 if (left) { 00089 loc = left->location_get(); 00090 value += left->spelling_get(); 00091 } else { 00092 loc = right->location_get(); 00093 } 00094 00095 if (right) { 00096 value += right->spelling_get(); 00097 } 00098 00099 length = value.length(); 00100 index = 0; 00101 00102 // pretend having a new file 00103 concat_guts::yyrestart(NULL); 00104 ptr<pp_token> tok = concat_guts::concat_parse(loc,token_value::create(value)); 00105 00106 if (!tok) { 00107 // concatenation failed 00108 report << unable_to_concatenate << loc; 00109 if (left) result->add_back(left); 00110 if (right) result->add_back(right); 00111 } else { 00112 // successful attempt 00113 result->add_back(tok); 00114 } 00115 return result; 00116 }
| ptr< concat > lestes::lang::cplus::lex::concat::instance | ( | void | ) | [static] |
Returns the only instance.
Returns the only instance of the object.
Definition at line 161 of file concat.cc.
References concat(), and singleton.
Referenced by lestes::lang::cplus::lex::macro_body::expand().
00162 { 00163 if (!singleton) { 00164 singleton = new concat(); 00165 } 00166 return singleton; 00167 }
| void lestes::lang::cplus::lex::concat::gc_mark | ( | void | ) | [protected, virtual] |
Marks the object.
Marks the object.
Reimplemented from lestes::std::mem::keystone.
Definition at line 152 of file concat.cc.
References lestes::std::mem::keystone::gc_mark().
00153 { 00154 ::lestes::std::object::gc_mark(); 00155 }
Hides assignment operator.
ucn_string lestes::lang::cplus::lex::concat::value [private] |
Current value of input string.
Definition at line 86 of file concat.hh.
Referenced by process(), and yy_input().
Current index in the input.
Definition at line 88 of file concat.hh.
Referenced by process(), and yy_input().
Current length of the input.
Definition at line 90 of file concat.hh.
Referenced by process(), and yy_input().
ptr< concat > lestes::lang::cplus::lex::concat::singleton [static, private] |
The only instance.
The only instance of the class, managing the associated flexer.
Definition at line 96 of file concat.hh.
Referenced by instance().
1.5.1-20070107