Geral
Compiladores
Semana 3
0

Questão

Dado o seguinte trecho de código em uma linguagem de programação: 

if (x > 5) { 

       y = 10; 

} 

Qual regra gramatical representa a estrutura condicional "if" no código acima? 

A)

<stmt> ::= if (<expr>) { <stmt> }

B)

<expr> ::= if (<stmt>) { <stmt> }

C)

<stmt> ::= if { <stmt> } else { <stmt> }

D)

<expr> ::= if (<stmt>)

E)

<stmt> ::= if (<expr>) { <stmt> } else { <stmt> }

function vote(questaoId, value) { window.location.href = "/accounts/login/?next=/questao/310/"; return; fetch(`/vote/questao/${questaoId}/`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRFToken': 'k7E9NKTqTjpyHFfVWn2htFkREfJla4njF74rnkciAYLxk6ik70VABXulfjgi2Wp9' }, body: JSON.stringify({ value: value }) }) .then(response => response.json()) .then(data => { if (data.success) { document.getElementById(`score-${questaoId}`).textContent = data.score; const upBtn = document.querySelector(`button[onclick="vote(${questaoId}, 1)"]`); const downBtn = document.querySelector(`button[onclick="vote(${questaoId}, -1)"]`); upBtn.classList.remove('active-up'); downBtn.classList.remove('active-down'); if (data.user_vote === 1) upBtn.classList.add('active-up'); if (data.user_vote === -1) downBtn.classList.add('active-down'); } }); }