#include <prefixer.hh>
Public Types | |
| enum | mode_type { PREFIX_OFF, PREFIX_ON } |
| typedef ::lestes::lang::cplus::lex::preprocessor | preprocessor |
Static Public Member Functions | |
| static ptr< bison_token > | yylex () |
| handles user hints (prefixes): they are stored in the user_hint field of the returned token | |
| static void | init (mode_type, ptr< preprocessor >) |
| static mode_type | mode_get () |
Static Protected Member Functions | |
| static ptr< bison_token > | internal_yylex () |
| used internally to actually call the lex scanner | |
| static bison_token::hint_type | prefix2hint (const ucn_string &) |
| given ucn_string, returns corresponding hint; when the string is not a valid prefix, HINT_NONE is returned | |
Private Member Functions | |
| prefixer () | |
| Do no allow instantiating this class. | |
| prefixer (const prefixer &) | |
| Hide copy-constructor. | |
Static Private Attributes | |
| static mode_type | mode |
| static ptr< preprocessor > | pp |
Definition at line 42 of file prefixer.hh.
Definition at line 44 of file prefixer.hh.
| lestes::lang::cplus::syn::prefixer::prefixer | ( | ) | [private] |
Do no allow instantiating this class.
| lestes::lang::cplus::syn::prefixer::prefixer | ( | const prefixer & | ) | [private] |
Hide copy-constructor.
| ptr< bison_token > lestes::lang::cplus::syn::prefixer::yylex | ( | ) | [static] |
handles user hints (prefixes): they are stored in the user_hint field of the returned token
Definition at line 95 of file prefixer.cc.
References lestes::lang::cplus::syn::bison_token::HINT_BITFIELD, lestes::lang::cplus::syn::bison_token::HINT_CTOR, lestes::lang::cplus::syn::bison_token::HINT_NO_BITFIELD, lestes::lang::cplus::syn::bison_token::HINT_NO_CTOR, lestes::lang::cplus::syn::bison_token::HINT_NONE, internal_yylex(), llog, mode, prefix2hint(), PREFIX_OFF, TOK_COLON, TOK_IDENT, and TOK_LEFT_PAR.
00096 { 00097 ptr<bison_token> tok1 = internal_yylex(); 00098 // when we are off, do not bother examining the token 00099 if (mode == PREFIX_OFF) 00100 return tok1; 00101 bison_token::hint_type hint; 00102 ptr<bison_token> tok2; 00103 do { 00104 // the prefixes are always identifiers 00105 if (tok1->type_get() != bison_token::TOK_IDENT) 00106 return tok1; 00107 hint = prefix2hint( tok1->value_get() ); 00108 if (hint == bison_token::HINT_NONE) 00109 return tok1; 00110 tok2 = internal_yylex(); 00111 // if the following token is not an identifier 00112 // (or left parenthesis or colon, where appropriate), 00113 // ignore the hint completely, warn, and try again 00114 // also ignore two or more hints in a row 00115 if (hint == bison_token::HINT_CTOR || 00116 hint == bison_token::HINT_NO_CTOR) { 00117 if (tok2->type_get() == bison_token::TOK_LEFT_PAR) 00118 break; 00119 } else if (hint == bison_token::HINT_BITFIELD || 00120 hint == bison_token::HINT_NO_BITFIELD) { 00121 if (tok2->type_get() == bison_token::TOK_COLON) 00122 break; 00123 } else if (tok2->type_get() == bison_token::TOK_IDENT) { 00124 if (prefix2hint(tok2->value_get()) == bison_token::HINT_NONE) 00125 break; 00126 else 00127 ; // hint before another hint 00128 } 00129 llog(prl) << "user-specified hint (\"" << tok1->value_get() << 00130 "\") irrelevant, discarding\n"; 00131 tok1 = tok2; 00132 } while (true); 00133 // now we have the user hint (in hint) and the hinted token (in tok2) 00134 tok2->user_hint_set(hint); 00135 return tok2; 00136 }
| void lestes::lang::cplus::syn::prefixer::init | ( | mode_type | , | |
| ptr< preprocessor > | ||||
| ) | [static] |
| prefixer::mode_type lestes::lang::cplus::syn::prefixer::mode_get | ( | ) | [static] |
| ptr< bison_token > lestes::lang::cplus::syn::prefixer::internal_yylex | ( | ) | [static, protected] |
used internally to actually call the lex scanner
Definition at line 59 of file prefixer.cc.
References lestes::intercode::intercode::create(), and pp.
Referenced by yylex().
00060 { 00061 return bison_token::create( pp->read() ); 00062 }
| bison_token::hint_type lestes::lang::cplus::syn::prefixer::prefix2hint | ( | const ucn_string & | ) | [static, protected] |
given ucn_string, returns corresponding hint; when the string is not a valid prefix, HINT_NONE is returned
Definition at line 86 of file prefixer.cc.
References lestes::lang::cplus::syn::prefix2hint_map_item::hint, lestes::lang::cplus::syn::prefix2hint_map, and lestes::lang::cplus::syn::prefix2hint_map_item::value.
Referenced by yylex().
00087 { 00088 const struct prefix2hint_map_item * it = prefix2hint_map; 00089 // try to match the strings, stop at the end of the array where the string is empty 00090 while (!(it->value.empty()) && str != it->value) 00091 ++it; 00092 return it->hint; 00093 }
prefixer::mode_type lestes::lang::cplus::syn::prefixer::mode [static, private] |
ptr< prefixer::preprocessor > lestes::lang::cplus::syn::prefixer::pp [static, private] |
1.5.1-20070107