Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stack>
- #include <list>
- using namespace std;
- class Component
- {
- };
- class Atom:Component
- {
- private:
- string data;
- public:
- Atom(string a):data(a)
- {
- }
- };
- class Complex: Component
- {
- private:
- list<Component> list;
- list<*Complex> temp_list;
- };
- Atom* Parse(string in, int p)
- {
- string result = " ";
- int i = p;
- while (in[i] == '(')
- {
- temp_list = new Component();
- temp_list.Add(new Atom(result));
- Parse(in, p - 1);
- }
- while (in[i] != ',')
- {
- result += in[i];
- i++;
- }
- Atom a(result);
- Parse(in, i++);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement