Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GLF Proyecto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Automate
Agent sessions
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
marruiz
GLF Proyecto
Commits
5613f4b2
Commit
5613f4b2
authored
Jun 9, 2020
by
marruiz
Browse files
Options
Downloads
Patches
Plain Diff
Delimitadores de bloque diferenciados y bloques de sentencias
parent
a957557a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
a.y
+32
-5
32 additions, 5 deletions
a.y
with
32 additions
and
5 deletions
a.y
+
32
−
5
View file @
5613f4b2
...
...
@@ -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;
}
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment