321-CL3 - t.Add(0 t2 else t[current&= x...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
global_procedure Get_Tree ( alters Text& tree_as_text, produces Tree_Of_Character& t ); /*! requires there exists x, y: string of character, t1: tree of character (#tree_as_text = x * y and x = PREFIX_DISPLAY (t1)) ensures #tree_as_text = PREFIX_DISPLAY (t) * tree_as_text !*/ { object Character x; t.Clear() object Character t2; if(tree-as-text.Length() > 0) { tree-as-text.Remove(0, x); if(x =='(') { if(tree-as-text.Length() > 0) { tree-as-text.Remove(0, x); if(x != '(' and ')') { t2[current] &= x; t.Add(0, t2); } } else if(x == '(') { if(tree-as-text.Length() > 0) { tree-as-text.Remove(0, x); if(x == ')') { if(tree-as-text.Length() > 0) { tree-as-text.Remove(0, x); if(x ! = '(' and ')') { t2[current] &= x;
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t.Add(0, t2); } } } } } else { t[current] &= x; } Get_Tree(tree-as-text, t2); t.Add(0, t2); } } global_procedure Put_Tree ( preserves Tree_Of_Character& t, alters Character_OStream& outs, preserves Integer indentation_factor ); /*! requires outs.is_open = true ensures outs.is_open = true and outs.ext_name = #outs.ext_name and outs.content = #outs.content * MULTILINE_DISPLAY (t, indentation_factor) !*/ { object Integer pos; outs << t[current] << '\n' << '\t'; while(pos < t.Number_Of_Children) { object Tree_Of_Character t2; t.Remove(pos, t2); Put_Tree(t2, outs, indentation_factor); t.Add(pos, t2); pos++; } }...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern