Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
muppet-strings
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Hörnquist
muppet-strings
Commits
8e24c6a5
Commit
8e24c6a5
authored
1 year ago
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Allow trailing comma in invoke:
parent
4d8814c7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
muppet/puppet/format/parser.py
+1
-1
1 addition, 1 deletion
muppet/puppet/format/parser.py
tests/test_parse_elsif.py
+36
-3
36 additions, 3 deletions
tests/test_parse_elsif.py
with
37 additions
and
4 deletions
muppet/puppet/format/parser.py
+
1
−
1
View file @
8e24c6a5
...
...
@@ -433,7 +433,7 @@ class ParserFormatter(Serializer[ParseDirective]):
parser
&=
ws
&
self
.
s
(
x
)
for
x
in
xs
:
parser
&=
ws
&
'
,
'
&
ws
&
self
.
s
(
x
)
parser
&=
optional
(
ws
&
'
)
'
)
parser
&=
optional
(
ws
&
'
,
'
)
&
optional
(
ws
&
'
)
'
)
return
parser
@override
...
...
This diff is collapsed.
Click to expand it.
tests/test_parse_elsif.py
+
36
−
3
View file @
8e24c6a5
...
...
@@ -4,6 +4,7 @@ from muppet.puppet.format.parser import ParserFormatter
from
muppet.puppet.ast
import
build_ast
from
muppet.puppet.parser
import
puppet_parser
from
muppet.parser_combinator
import
ParserCombinator
from
pprint
import
pprint
def
test_parse_else_if
():
...
...
@@ -57,9 +58,6 @@ def test_parse_elsif():
# '}']
from
pprint
import
pprint
def
test_chained
():
s
=
"
x.filter().join()
"
ast
=
build_ast
(
puppet_parser
(
s
))
...
...
@@ -88,3 +86,38 @@ def test_chained_and_lambda():
print
(
"
parser:
\n
"
+
str
(
parser
))
match_objects
=
ParserCombinator
(
s
,
"
s
"
).
get
(
parser
)
pprint
(
match_objects
)
def
test_invoke
():
s
=
"""
assert_type(
Enum[
'
always
'
,
'
daily
'
,
'
weekly
'
,
'
reluctantly
'
],
$update[
'
frequency
'
],
)
"""
ast
=
build_ast
(
puppet_parser
(
s
))
pprint
(
ast
)
parser
=
ParserFormatter
(
s
,
"
s
"
).
serialize
(
ast
)
print
(
"
parser:
\n
"
+
str
(
parser
))
match_objects
=
ParserCombinator
(
s
,
"
s
"
).
get
(
parser
)
pprint
(
match_objects
)
def
test_invoke_inside_if
():
# This previously failed due to invoke not handling trailing
# commas. The above example (test_invoke) apparently worked,
# because reasons.
s
=
"""
if $update[
'
frequency
'
] {
assert_type(
Enum[
'
always
'
,
'
daily
'
,
'
weekly
'
,
'
reluctantly
'
],
$update[
'
frequency
'
],
)
}
"""
ast
=
build_ast
(
puppet_parser
(
s
))
pprint
(
ast
)
parser
=
ParserFormatter
(
s
,
"
s
"
).
serialize
(
ast
)
print
(
"
parser:
\n
"
+
str
(
parser
))
match_objects
=
ParserCombinator
(
s
,
"
s
"
).
get
(
parser
)
pprint
(
match_objects
)
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
register
or
sign in
to comment