Skip to content

Commit

Permalink
Try to parse inline comment in blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
buglloc committed Sep 28, 2018
1 parent 0e03260 commit 84f79a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gixy/parser/raw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def script(self):
if_block << (
Keyword("if") +
Group(condition) +
Suppress(Optional(comment)) +
Group(
left_bracket +
Optional(sub_block) +
Expand All @@ -137,6 +138,7 @@ def script(self):
Group(
Optional(space + location_modifier) +
Optional(space) + value) +
Suppress(Optional(comment)) +
Group(
left_bracket +
Optional(sub_block) +
Expand All @@ -155,6 +157,7 @@ def script(self):
generic_block << (
keyword +
Group(ZeroOrMore(space + value)) +
Suppress(Optional(comment)) +
Group(
left_bracket +
Optional(sub_block) +
Expand Down
8 changes: 8 additions & 0 deletions tests/parser/test_raw_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ def test_comments():
#
add_header X-Blank-Comment blank;
if (1) # Comment
{
add_header X-Inline blank;
}
'''

expected = [
Expand All @@ -499,6 +504,9 @@ def test_comments():
['add_header', 'X-Padding-Comment', 'padding'],
[''],
['add_header', 'X-Blank-Comment', 'blank'],
['if', ['1'], [
['add_header', 'X-Inline', 'blank'],
]],
]

assert_config(config, expected)
Expand Down

0 comments on commit 84f79a3

Please sign in to comment.