Ybadoo - Soluções em Software Livre
Tutoriais
Compiladores

Apresente a árvore de sintaxe da expressão aritmética d = a * b * c + a * b - b * c, sobre a gramática livre de contexto apresentada a seguir.

Notação Algébrica:

G = ({A, E, T, F, V}, {a, b, c, d, =, +, -, *, /, (, )}, P, A)
P = {A → V=E
     E → E+T | E-T | T
     T → T*F | T/F | F
     F → (E) | V
     V → a | b | c | d}

Notação de Backus-Naur (BNF):

G = ({atr, exp, ter, fat, var}, {a, b, c, d, =, +, -, *, /, (, )}, P, atr)
P = {<atr> ::= <var>=<exp>
     <exp> ::= <exp>+<ter> | <exp>-<ter> | <ter>
     <ter> ::= <ter>*<fat> | <ter>/<fat> | <fat>
     <fat> ::= (<exp>) | <var>
     <var> ::= a | b | c | d}