Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Parser.cc
r234 r260 169 169 170 170 171 void Parser::parse(std::istream& is, 172 std::vector<std::pair<std::string, std::string> >& codon) 173 { 174 // mode zero means we are currently not in a comment 175 // if mode!=0 comment is closed by codon[mode-1].second -> mode=0 176 // if codon[x-1].start is found and x >= mode -> mode=x 177 size_t mode = 0; 178 std::string str; 179 while(getline(is,str)) { 180 line_type lt=empty; 181 for (std::string::iterator iter=str.begin(); iter!=str.end(); ++iter){ 182 for (size_t i=mode; i<codon.size(); ++i) { 183 if (match_begin(iter, str.end(), codon[i].first)) { 184 mode = i+1; 185 break; 186 } 187 } 188 if (!mode && match_begin(iter,str.end(), codon[mode-1].second)){ 189 mode=0; 190 continue; 191 } 192 193 // A line of code or comment must contain at least one 194 // alphanumerical character. 195 if (isalnum(*iter)) { 196 if (!mode) 197 lt=code; 198 else if (mode!=code) 199 lt=comment; 200 } 201 } 202 if (!mode && codon[mode-1].second==std::string("\n")) 203 mode=0; 204 205 type_.push_back(lt); 206 } 207 } 208 209 171 210 void Parser::text_mode(std::istream& is) 172 211 { -
trunk/lib/Parser.h
r234 r260 75 75 void markup_mode(std::istream&); 76 76 77 void parse(std::istream& is, 78 std::vector<std::pair<std::string, std::string> >& codon); 79 77 80 void text_mode(std::istream&); 78 81
Note: See TracChangeset
for help on using the changeset viewer.