Skip to content

Commit cecea3a

Browse files
committed
Handle empty sections
1 parent 318eaca commit cecea3a

File tree

2 files changed

+112
-100
lines changed

2 files changed

+112
-100
lines changed

src/robot/parsing/newparser/parser.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ def p_section(self, p):
3232
p[0] = p[1]
3333

3434
def p_setting_section(self, p):
35-
'''setting_section : SETTING_HEADER EOS settings'''
36-
p[0] = SettingSection(p[3])
35+
'''setting_section : SETTING_HEADER EOS
36+
| SETTING_HEADER EOS settings'''
37+
if len(p) == 4:
38+
p[0] = SettingSection(p[3])
3739

3840
def p_settings(self, p):
3941
'''settings : setting
@@ -152,8 +154,10 @@ def p_return(self, p):
152154
p[0] = ReturnSetting(p[2])
153155

154156
def p_variable_section(self, p):
155-
'''variable_section : VARIABLE_HEADER EOS variables'''
156-
p[0] = VariableSection(p[3])
157+
'''variable_section : VARIABLE_HEADER EOS
158+
| VARIABLE_HEADER EOS variables'''
159+
if len(p) == 4:
160+
p[0] = VariableSection(p[3])
157161

158162
def p_variables(self, p):
159163
'''variables : variable
@@ -167,12 +171,16 @@ def p_variable(self, p):
167171
p[0] = Variable(p[1], arguments)
168172

169173
def p_testcase_section(self, p):
170-
'''testcase_section : TESTCASE_HEADER EOS tests'''
171-
p[0] = TestCaseSection(p[3])
174+
'''testcase_section : TESTCASE_HEADER EOS
175+
| TESTCASE_HEADER EOS tests'''
176+
if len(p) == 4:
177+
p[0] = TestCaseSection(p[3])
172178

173179
def p_keyword_section(self, p):
174-
'''keyword_section : KEYWORD_HEADER EOS keywords'''
175-
p[0] = KeywordSection(p[3])
180+
'''keyword_section : KEYWORD_HEADER EOS
181+
| KEYWORD_HEADER EOS keywords'''
182+
if len(p) == 4:
183+
p[0] = KeywordSection(p[3])
176184

177185
def p_tests(self, p):
178186
'''tests : test

0 commit comments

Comments
 (0)