Skip to content
Snippets Groups Projects
Commit 5613f4b2 authored by marruiz's avatar marruiz :space_invader:
Browse files

Delimitadores de bloque diferenciados y bloques de sentencias

parent a957557a
Branches
No related tags found
No related merge requests found
......@@ -48,6 +48,7 @@ static ast_t ast = NULL;
%term WHILE
%type <s> PROGRAM PROGRAM_ELEMENT SENTENCE EXPR
%type <s> BLOCK
%%
......@@ -116,16 +117,21 @@ SENTENCE
$$.type = AST_NODE_id;
$$.u.node = newNode(READ, newLeafString(STR, $2.u.string), newLeafString(ID, $3.u.string))
}
| WHILE EXPR DEL_BL EXPR DEL_BL '\n'
| WHILE EXPR DEL_BL_A BLOCK DEL_BL_C '\n'
{
$$.type = AST_NODE;
$$.type = AST_NODE_id;
$$.u.node = newNode(WHILE, $2.u.node, $4.u.node);
}
| IF EXPR DEL_BL EXPR DEL_BL ELSE DEL_BL EXPR DEL_BL '\n'
| IF EXPR DEL_BL_A BLOCK DEL_BL_C ELSE DEL_BL_A BLOCK DEL_BL_C '\n'
{
$$.type = AST_NODE;
$$.type = AST_NODE_id;
$$.u.node = newNode(IF, $2.u.node, $4.u.node);
$$.u.node = newNode(ELSE, $2.u.node, $8.u.node);
}
| IF EXPR DEL_BL_A BLOCK DEL_BL_C '\n'
{
$$.type = AST_NODE_id;
$$.u.node = newNode(IF, $2.u.node, $4.u.node);
};
......@@ -229,6 +235,27 @@ EXPR
$$.u.node = newNode(LN, $3.u.node, NULL);
}
;
BLOCK
: SENTENCE '\n'
{
$$.type = AST_NODE_id;
$$.u.node = newRoot(';', NULL, $1.u.ast);
}
| '\n'
{
$$.type = AST_NODE_id;
$$.u.node = NULL;
}
| BODY SENTENCE '\n'
{
$$.type = AST_NODE_id;
$$.u.node = newRoot(';', $1.u.ast, $2.u.ast);
}
| BODY '\n'
{
$$ = $1;
}
;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment