Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
code
pugs
Commits
876682da
Commit
876682da
authored
Nov 20, 2019
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Allow tuple affectations
`` R x=0; R y=3; (x,y) += (3,2); ``
parent
9e17aa66
No related branches found
No related tags found
1 merge request
!37
Feature/language
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/language/ASTSymbolInitializationChecker.cpp
+19
-8
19 additions, 8 deletions
src/language/ASTSymbolInitializationChecker.cpp
src/language/PEGGrammar.hpp
+3
-2
3 additions, 2 deletions
src/language/PEGGrammar.hpp
with
22 additions
and
10 deletions
src/language/ASTSymbolInitializationChecker.cpp
+
19
−
8
View file @
876682da
...
@@ -8,7 +8,7 @@ void
...
@@ -8,7 +8,7 @@ void
ASTSymbolInitializationChecker
::
_checkSymbolInitialization
(
ASTNode
&
node
)
ASTSymbolInitializationChecker
::
_checkSymbolInitialization
(
ASTNode
&
node
)
{
{
if
(
node
.
is_type
<
language
::
declaration
>
())
{
if
(
node
.
is_type
<
language
::
declaration
>
())
{
auto
set
_i
s
_initialized
=
[
&
](
ASTNode
&
name_node
)
{
auto
check
_i
f
_initialized
=
[
&
](
ASTNode
&
name_node
)
{
const
std
::
string
&
symbol
=
name_node
.
string
();
const
std
::
string
&
symbol
=
name_node
.
string
();
auto
[
i_symbol
,
found
]
=
node
.
m_symbol_table
->
find
(
symbol
,
name_node
.
begin
());
auto
[
i_symbol
,
found
]
=
node
.
m_symbol_table
->
find
(
symbol
,
name_node
.
begin
());
Assert
(
found
,
"unexpected error, should have been detected through declaration checking"
);
Assert
(
found
,
"unexpected error, should have been detected through declaration checking"
);
...
@@ -19,11 +19,11 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
...
@@ -19,11 +19,11 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
};
};
if
(
node
.
children
[
1
]
->
is_type
<
language
::
name
>
())
{
if
(
node
.
children
[
1
]
->
is_type
<
language
::
name
>
())
{
set
_i
s
_initialized
(
*
node
.
children
[
1
]);
check
_i
f
_initialized
(
*
node
.
children
[
1
]);
}
else
if
(
node
.
children
[
1
]
->
is_type
<
language
::
name_list
>
())
{
}
else
if
(
node
.
children
[
1
]
->
is_type
<
language
::
name_list
>
())
{
ASTNode
&
name_list_node
=
*
node
.
children
[
1
];
ASTNode
&
name_list_node
=
*
node
.
children
[
1
];
for
(
auto
&
child_node
:
name_list_node
.
children
)
{
for
(
auto
&
child_node
:
name_list_node
.
children
)
{
set
_i
s
_initialized
(
*
child_node
);
check
_i
f
_initialized
(
*
child_node
);
}
}
}
}
}
else
if
(
node
.
is_type
<
language
::
let_declaration
>
())
{
}
else
if
(
node
.
is_type
<
language
::
let_declaration
>
())
{
...
@@ -44,11 +44,22 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
...
@@ -44,11 +44,22 @@ ASTSymbolInitializationChecker::_checkSymbolInitialization(ASTNode& node)
}
else
if
(
node
.
is_type
<
language
::
eq_op
>
())
{
}
else
if
(
node
.
is_type
<
language
::
eq_op
>
())
{
// first checks for right hand side
// first checks for right hand side
this
->
_checkSymbolInitialization
(
*
node
.
children
[
1
]);
this
->
_checkSymbolInitialization
(
*
node
.
children
[
1
]);
// then marks left hand side as initialized
const
std
::
string
&
symbol
=
node
.
children
[
0
]
->
string
();
auto
set_is_initialized
=
[
&
](
ASTNode
&
name_node
)
{
auto
[
i_symbol
,
found
]
=
node
.
m_symbol_table
->
find
(
symbol
,
node
.
children
[
0
]
->
begin
());
const
std
::
string
&
symbol
=
name_node
.
string
();
auto
[
i_symbol
,
found
]
=
node
.
m_symbol_table
->
find
(
symbol
,
name_node
.
begin
());
Assert
(
found
,
"unexpected error, should have been detected through declaration checking"
);
Assert
(
found
,
"unexpected error, should have been detected through declaration checking"
);
i_symbol
->
attributes
().
setIsInitialized
();
i_symbol
->
attributes
().
setIsInitialized
();
};
if
(
node
.
children
[
0
]
->
is_type
<
language
::
name
>
())
{
set_is_initialized
(
*
node
.
children
[
0
]);
}
else
if
(
node
.
children
[
0
]
->
is_type
<
language
::
name_list
>
())
{
ASTNode
&
name_list_node
=
*
node
.
children
[
0
];
for
(
auto
&
child_node
:
name_list_node
.
children
)
{
set_is_initialized
(
*
child_node
);
}
}
}
else
if
(
node
.
is_type
<
language
::
name
>
())
{
}
else
if
(
node
.
is_type
<
language
::
name
>
())
{
auto
[
i_symbol
,
found
]
=
node
.
m_symbol_table
->
find
(
node
.
string
(),
node
.
begin
());
auto
[
i_symbol
,
found
]
=
node
.
m_symbol_table
->
find
(
node
.
string
(),
node
.
begin
());
Assert
(
found
,
"unexpected error, should have been detected through declaration checking"
);
Assert
(
found
,
"unexpected error, should have been detected through declaration checking"
);
...
...
This diff is collapsed.
Click to expand it.
src/language/PEGGrammar.hpp
+
3
−
2
View file @
876682da
...
@@ -211,9 +211,10 @@ struct expression_list : seq< open_parent, expression, plus< if_must< COMMA, exp
...
@@ -211,9 +211,10 @@ struct expression_list : seq< open_parent, expression, plus< if_must< COMMA, exp
struct
affect_op
:
sor
<
eq_op
,
multiplyeq_op
,
divideeq_op
,
pluseq_op
,
minuseq_op
>
{};
struct
affect_op
:
sor
<
eq_op
,
multiplyeq_op
,
divideeq_op
,
pluseq_op
,
minuseq_op
>
{};
struct
affectation
:
seq
<
NAME
,
if_must
<
affect_op
,
sor
<
expression_list
,
expression
>
>
>
{};
struct
name_list
;
struct
name_list
;
struct
affectation
:
seq
<
sor
<
NAME
,
name_list
>
,
if_must
<
affect_op
,
sor
<
expression_list
,
expression
>
>
>
{};
struct
declaration
:
if_must
<
type_expression
,
sor
<
NAME
,
name_list
>
,
opt
<
if_must
<
seq
<
one
<
'='
>
,
ignored
>
,
sor
<
expression_list
,
expression
>
>
>
>
{};
struct
declaration
:
if_must
<
type_expression
,
sor
<
NAME
,
name_list
>
,
opt
<
if_must
<
seq
<
one
<
'='
>
,
ignored
>
,
sor
<
expression_list
,
expression
>
>
>
>
{};
struct
type_mapping
:
seq
<
type_expression
,
RIGHT_ARROW
,
type_expression
>
{};
struct
type_mapping
:
seq
<
type_expression
,
RIGHT_ARROW
,
type_expression
>
{};
...
...
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