(New page: == The Problem (in Portuguese) == Considere a seguinte gramárica (ε representa a produção nula), onde os operadores '''WRITE''' (não associativo), '''=''' (associativo à direita) e ...) |
|||
Line 17: | Line 17: | ||
expr -> INTEGER | ID | ID '=' expr | expr '+' expr | WRITE expr | expr -> INTEGER | ID | ID '=' expr | expr '+' expr | WRITE expr | ||
</text> | </text> | ||
+ | |||
+ | == Solution == | ||
+ | |||
+ | [[category:Compilers]] | ||
+ | [[category:Teaching]] |
Considere a seguinte gramárica (ε representa a produção nula), onde os operadores WRITE (não associativo), = (associativo à direita) e + (associativo à esquerda) têm precedências crescentes.
<text> prog -> decls exprs '.'
decls -> ε | decls decl ';'
decl -> INT ID | STR ID init
init -> ε | '=' STRING
exprs -> expr | exprs ',' expr
expr -> INTEGER | ID | ID '=' expr | expr '+' expr | WRITE expr </text>