Construção da Árvore Sintática
(Implementação)
.
..
int termo(FILE *code_file, int next_token, NextChar *next_char,
Node *tree){
printf("Enter <termo>\n");
Node *termonode = AddChild(tree, "termo", -1);
next_token = fator(code_file, next_token, next_char, termonode);
while (next_token == MULT_OP || next_token == DIV_OP)
{
if (next_token == MULT_OP)
AddChild(termonode, "*", next_token);
else if (next_token == DIV_OP)
AddChild(termonode, "/", next_token);
next_token = lex(code_file, next_char);
next_token = fator(code_file, next_token, next_char, termonode);
}
printf("Exit <termo>\n");
return next_token;
}
.
..