http://kmlinux.fjfi.cvut.cz/~culik/zpro/lexer05 soubor list.h class List { ... void print (int level = 0); void section (ostream & f, int level); void html (ostream & f); ... }; class Item { public: string name; string info; List inner; ... }; soubor list.cpp void Indent(int level) { if (level > 0) cout << string(level * 4,' '); } void List::print (int level) { // #include Indent(level); cout << "[" << endl; Item * p = first; while (p != nullptr) { Indent(level); cout << " " << p->name << " " << p->info << endl; if (p->inner.first != nullptr) p->inner.print(level + 1); p = p->next; } Indent(level); cout << "]" << endl; } void indent (ostream & f, int level) { if (level > 0) f << string (level, ' '); } void List::section (ostream & f, int level) { indent (f, 4*level); f << "" << endl; } void List::html (ostream & f) { f << "" << endl; f << "" << endl; f << "" << endl; f << "Vystupni soubor " << endl; f << "" << endl; f << "" << endl; section (f, 1); f << "" << endl; f << "" << endl; } soubor lexer.cpp ... const char quote = '"'; ... else if (ch == quote) { kind = text; nextChar (); // skip quote while (ch != quote && ch != zero) { token = token + ch; nextChar (); } nextChar (); // skip quote } ... soubor main.cpp #include #include "lexer.h" #include "list.h" using namespace std; void ctiSeznam (Lexer & f, List & v); void ctiPrvek (Lexer & f, List & v) { string name = f.readIdent (); Item * p = new Item (name); v.linkLast (p); if (f.kind == text) { p->info = f.token; f.nextToken(); } if (f.isSeparator('{')) ctiSeznam (f, p->inner); } void ctiSeznam (Lexer & f, List & v) { f.checkSeparator('{'); if (! f.isSeparator('}')) { ctiPrvek (f, v); while (f.isSeparator (',')) { f.nextToken (); // skip ',' ctiPrvek (f, v); } } f.checkSeparator('}'); } int main() { List a; Lexer f ("../lexer05/abc.txt"); ctiSeznam (f, a); a.print(); a.html (cout); ofstream g ("../lexer05/output.html"); a.html (g); return 0; }