Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
arbor-sim
arbor
Commits
89a2f041
Unverified
Commit
89a2f041
authored
Feb 11, 2021
by
Nora Abi Akar
Committed by
GitHub
Feb 11, 2021
Browse files
Options
Downloads
Patches
Plain Diff
Modcc: parse the unit of `FUNCTION` (#1361)
* add function unit parsing * add unit tests
parent
2adcd65c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
modcc/parser.cpp
+8
-0
8 additions, 0 deletions
modcc/parser.cpp
test/unit-modcc/test_parser.cpp
+39
-10
39 additions, 10 deletions
test/unit-modcc/test_parser.cpp
with
47 additions
and
10 deletions
modcc/parser.cpp
+
8
−
0
View file @
89a2f041
...
@@ -973,6 +973,14 @@ symbol_ptr Parser::parse_function() {
...
@@ -973,6 +973,14 @@ symbol_ptr Parser::parse_function() {
auto
p
=
parse_prototype
();
auto
p
=
parse_prototype
();
if
(
p
==
nullptr
)
return
nullptr
;
if
(
p
==
nullptr
)
return
nullptr
;
// Functions may have a unit attached
if
(
token_
.
type
==
tok
::
lparen
)
{
unit_description
();
if
(
status_
==
lexerStatus
::
error
)
{
return
{};
}
}
// check for opening left brace {
// check for opening left brace {
if
(
!
expect
(
tok
::
lbrace
))
return
nullptr
;
if
(
!
expect
(
tok
::
lbrace
))
return
nullptr
;
...
...
This diff is collapsed.
Click to expand it.
test/unit-modcc/test_parser.cpp
+
39
−
10
View file @
89a2f041
...
@@ -205,6 +205,7 @@ TEST(Parser, net_receive) {
...
@@ -205,6 +205,7 @@ TEST(Parser, net_receive) {
}
}
TEST
(
Parser
,
function
)
{
TEST
(
Parser
,
function
)
{
{
char
str
[]
=
char
str
[]
=
"FUNCTION foo(x, y) {"
"FUNCTION foo(x, y) {"
" LOCAL a
\n
"
" LOCAL a
\n
"
...
@@ -217,6 +218,34 @@ TEST(Parser, function) {
...
@@ -217,6 +218,34 @@ TEST(Parser, function) {
std
::
unique_ptr
<
Symbol
>
sym
;
std
::
unique_ptr
<
Symbol
>
sym
;
EXPECT_TRUE
(
check_parse
(
sym
,
&
Parser
::
parse_function
,
str
));
EXPECT_TRUE
(
check_parse
(
sym
,
&
Parser
::
parse_function
,
str
));
}
}
{
char
str
[]
=
"FUNCTION foo(x (mv), y (/mA)) {"
" foo = x * y
\n
"
"}"
;
std
::
unique_ptr
<
Symbol
>
sym
;
EXPECT_TRUE
(
check_parse
(
sym
,
&
Parser
::
parse_function
,
str
));
}
{
char
str
[]
=
"FUNCTION foo(x (mv), y (/mA)) (mv/mA) {"
" foo = x * y
\n
"
"}"
;
std
::
unique_ptr
<
Symbol
>
sym
;
EXPECT_TRUE
(
check_parse
(
sym
,
&
Parser
::
parse_function
,
str
));
}
{
char
str
[]
=
"FUNCTION foo(x (mv), y (/mA)) (mv-mA) {"
" foo = x * y
\n
"
"}"
;
std
::
unique_ptr
<
Symbol
>
sym
;
EXPECT_FALSE
(
check_parse
(
sym
,
&
Parser
::
parse_function
,
str
));
}
}
TEST
(
Parser
,
parse_solve
)
{
TEST
(
Parser
,
parse_solve
)
{
std
::
unique_ptr
<
SolveExpression
>
s
;
std
::
unique_ptr
<
SolveExpression
>
s
;
...
...
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