Could you code this assignment?

Guide lines are here.

---------------------------------------------

Implement the "read" function in C++, which can recognize expressions defined as follows.

<s-expr> := '(' {<s-expr> | <term>} ')'

<term> := ID | integer | '+' | '-' | '*' | '/'

The output of the function is a parse tree specified as follows. ID is any string of digits and letters that starts with a letter. Here "integer" is any string of digits whose first digit is nonzero.

Example

(a 1 2 (b 3 (+ 4 cx2) 5) 6 (7 8))

<E1> => (a 1 2 <E2> 6 <E4>)

<E2> => (b 3 <E3> 5)

<E3> => (+ 4 cx2)

<E4> => (7 8)

An <s-expr> is represented as <E#>. The expression number (#) starts from 1, and is determined by the order of appearance in the input expression. Print the expressions one per line, in the increasing order of the expression number.

Example in action

$ ./solb

> (a 1 2 (b 3 (+ 4 cx2) 5) 6 (7 8))

<E1> => (a 1 2 <E2> 6 <E4>)

<E2> => (b 3 <E3> 5)

<E3> => (+ 4 cx2)

<E4> => (7 8)

> [Ctrl-D]

$

Guide lines are here.

---------------------------------------------

Implement the "read" function in C++, which can recognize expressions defined as follows.

<s-expr> := '(' {<s-expr> | <term>} ')'

<term> := ID | integer | '+' | '-' | '*' | '/'

The output of the function is a parse tree specified as follows. ID is any string of digits and letters that starts with a letter. Here "integer" is any string of digits whose first digit is nonzero.

Example

(a 1 2 (b 3 (+ 4 cx2) 5) 6 (7 8))

<E1> => (a 1 2 <E2> 6 <E4>)

<E2> => (b 3 <E3> 5)

<E3> => (+ 4 cx2)

<E4> => (7 8)

An <s-expr> is represented as <E#>. The expression number (#) starts from 1, and is determined by the order of appearance in the input expression. Print the expressions one per line, in the increasing order of the expression number.

Example in action

$ ./solb

> (a 1 2 (b 3 (+ 4 cx2) 5) 6 (7 8))

<E1> => (a 1 2 <E2> 6 <E4>)

<E2> => (b 3 <E3> 5)

<E3> => (+ 4 cx2)

<E4> => (7 8)

> [Ctrl-D]

$

### Recently Asked Questions

- A voltaic cell that uses the reaction Tl3+(aq)+2Cr2+(aq)→Tl+(aq)+2Cr3+(aq) has a measured standard cell potential of +1.19 V. Part A: Write the two

- What role did blacks play in both winning the Civil War and in defining the war's consequences

- Please refer to the attachment to answer this question. This question was created from 2.3.pdf.