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

- How do you find intervals of: a. |x|< 2 b. |x-5| > 1 c. |x-4| < 7 Please show step by step how to do these 3 questions and depict them on a number line or

- Please refer to the attachment to answer this question. This question was created from Marketing quiz ETS.

- Please refer to the attachment to answer this question. This question was created from Marketing quiz ETS.