Hello, I am writing a small interpreter to show an example of Backus-Naur form and i would like to ask for help representing some data.
<statement> : <assignment> | HALT | PRINT(<variable>)
<assignment> : <variable> = <expression>
<expression> : <term> | <term><operator><expression>
<term> : <number> | <variable>
<variable> : x | y | z
<operator> : + | -
<number> : 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
As you can see everything is encapsulated in a statement. An then there assignments and expression. An expression encapsulates a term, which encapsulate a number and a variable. An assignment encapsulates a variable and a expression. My question is what data structure do i use to represent all of this? I am thinking it should be a set, but then that raises the question should i have nested sets?