00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include <lestes/common.hh>
00035 #include <lestes/std/file_info.hh>
00036 #include <lestes/lang/cplus/lex/unit_part.hh>
00037 #include <lestes/lang/cplus/lex/pp_token.hh>
00038 #include <lestes/lang/cplus/lex/encoder.hh>
00039 #include <lestes/lang/cplus/lex/pre_lex.hh>
00040 #include <lestes/lang/cplus/lex/data_source.hh>
00041 #include <lestes/lang/cplus/lex/pp_lex.hh>
00042 #include <lestes/lang/cplus/lex/condition_stack.hh>
00043 #include <lestes/lang/cplus/lex/macro_storage.hh>
00044 #include <lestes/lang/cplus/lex/expander.hh>
00045 #include <lestes/lang/cplus/lex/line_control.hh>
00046
00047 package(lestes);
00048 package(lang);
00049 package(cplus);
00050 package(lex);
00051
00052 using namespace ::std;
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 unit_part::unit_part(const ptr<file_info> &a_file, const ptr<data_source> &a_data,
00066 const ptr<encoder> &a_encoder, const ptr<macro_storage> &a_macros):
00067 start(false),
00068 conditions(condition_stack::create()),
00069 enc(checked(a_encoder)),
00070 ds(checked(a_data)),
00071 plx(pre_lex::create(ds,enc)),
00072 lic(line_control::create(checked(a_file))),
00073 ppl(pp_lex::create(plx,lic)),
00074 exp(expander::create(this,checked(a_macros)))
00075 {
00076 }
00077
00078
00079 #if 0
00080 void unit_part::activate(void)
00081 {
00082 ppl->activate();
00083 }
00084 #endif
00085
00086
00087
00088
00089
00090 void unit_part::start_of_line(void)
00091 {
00092 start = true;
00093 }
00094
00095
00096
00097
00098
00099 ptr<condition_stack> unit_part::conditions_get(void) const
00100 {
00101 return conditions;
00102 }
00103
00104
00105
00106
00107
00108 ptr<expander> unit_part::expander_get(void) const
00109 {
00110 return exp;
00111 }
00112
00113
00114
00115
00116
00117
00118 ptr<line_control> unit_part::line_control_get(void) const
00119 {
00120 return lic;
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 ptr<pp_token> unit_part::read(void)
00145 {
00146
00147
00148
00149
00150
00151
00152 ptr<pp_token> tok = ppl->read(start);
00153 start = false;
00154
00155
00156
00157
00158
00159 return tok;
00160 }
00161
00162
00163
00164
00165 void unit_part::gc_mark(void)
00166 {
00167 conditions.gc_mark();
00168 enc.gc_mark();
00169 ds.gc_mark();
00170 plx.gc_mark();
00171 lic.gc_mark();
00172 ppl.gc_mark();
00173 exp.gc_mark();
00174 pp_filter::gc_mark();
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 ptr<unit_part> unit_part::create(const ptr<file_info> &a_file,
00186 const ptr<data_source> &a_data, const ptr<encoder> &a_encoder,
00187 const ptr<macro_storage> &a_macros)
00188 {
00189 return new unit_part(a_file,a_data,a_encoder,a_macros);
00190 }
00191
00192 end_package(lex);
00193 end_package(cplus);
00194 end_package(lang);
00195 end_package(lestes);
00196
00197