---
# System prepended metadata

title: SPO Lecture 4 Exercises

---

# SPO Lecture 4 Exercises

## Exercise 2
![](https://i.imgur.com/0fMbbpn.png)

### Original
$Assign \rightarrow Id = Expr$
$Id \rightarrow A | B | C$
$Expr \rightarrow Expr + Term | Term$
$Term \rightarrow Term * Factor | Factor$
$Factor \rightarrow ( Expr ) | Id$
Tree:
$Factor \rightarrow $

### Right associativity
$Assign \rightarrow Id = Expr$
$Id \rightarrow A | B | C$
$Expr \rightarrow Term + Expr | Term$
$Term \rightarrow Term * Factor | Factor$
$Factor \rightarrow ( Expr ) | Id$


### + precedence
$Assign \rightarrow Id = Term$
$Id \rightarrow A | B | C$
$Expr \rightarrow Expr + Factor | Term$
$Term \rightarrow Term * Expr | Factor$
$Factor \rightarrow ( Expr ) | Id$

## Exercise 3
![](https://i.imgur.com/IEn7l6k.png)

$A = A * (B + (C * A))$
$Assign$
$Id = Expr$
$Id = Id * Expr$
$Id = Id * ( Expr )$
$Id = Id * ( Id + Expr )$
$Id = Id * ( Id + ( Expr ) )$
$Id = Id * ( Id + ( Id * Expr ) )$
$Id = Id * ( Id + ( Id * Id ) )$


## Exercise 4
![](https://i.imgur.com/ngUt7e4.png)

OBS: There are no parenthesis in the language. They are instead used to denote how operations are grouped
$a + b + c$
$S$
$A$
$A + A$
$(A + A) + A \text{ or } A + (A + A)$
$(Id + Id) + Id \text{ or } Id + (Id + Id)$
Because the addition operation is associative in math, nothing seems to happen, however working with programming, this property might not hold.

## Exercise 5

No support
There were probably some problems with the language definition

## Exercise 6

There were more browsers, so they needed to make sure that everything worked the same on every browser.