E : T E'
E' : + T E'
E' : - T E'
E' : ε
T : ( E )
T : id
T : num
Production | Semantic Rules |
---|---|
E |
E.node = new Node('+', E |
E |
E.node = new Node('-', E |
E |
E.node = T.node |
T |
T.node = E.node |
T |
T.node = new Leaf(id, id.entry) |
T |
T.node = new Leaf(num, num.val) |
Parse Tree | SDD | AST |
---|---|---|
![]() |
![]() |
![]() |
Parse Tree | SDD | AST |
---|---|---|
![]() |
![]() |
![]() |
Parse Tree | SDD | AST |
---|---|---|
![]() |
Production | Semantic Rules |
---|---|
E |
(1) E.node = E |
E |
(1) E |
E |
(1) E |
E |
E |
T |
T.node = E.node |
T |
T.node = new Leaf(id, id.entry) |
T |
T.node = new Leaf(num, num.val) |
Parse Tree | SDD | AST Construction Flow |
---|---|---|
![]() |
![]() |
![]() |
\Tree [.E [.E [.E [.T id ] ] $-$ [.T num ] ] $+$ [.T id ] ]
\Tree [.E(int:Type) [.E(int:Type) [.E(int:Type) [.T(int:Type) id(int:Type) ] ] $-$ [.T(int:Type) num(int:Type) ] ] $+$ [.T(int:Type) id(int:Type) ] ]
\Tree [.E($+$:Op) [.E($-$:Op) id(a:Name) num(4:Val) ] id(c:Name) ]
\Tree [.E [.T id ] [.E' $-$ [.T num ] [.E' $+$ [.T id ] [.E' $\epsilon$ ] ] ] ]