@@ -234,14 +234,14 @@ def p_statement_attributes_group(self, p):
234234 p [0 ] = []
235235
236236 def p_statement_typedef_union (self , p ):
237- 'typedef : UNION ID COLON NEWLINE INDENT docsection field_list example_list DEDENT'
237+ 'typedef : UNION ID NEWLINE INDENT docsection field_list example_list DEDENT'
238238 p [0 ] = BabelTypeDef (p [1 ], p [2 ])
239- if p [6 ]:
240- p [0 ].set_doc (self ._normalize_docstring (p [6 ]))
241- if p [7 ] is not None :
242- p [0 ].set_fields (p [7 ])
243- if p [8 ]:
244- for label , text , example in p [8 ]:
239+ if p [5 ]:
240+ p [0 ].set_doc (self ._normalize_docstring (p [5 ]))
241+ if p [6 ] is not None :
242+ p [0 ].set_fields (p [6 ])
243+ if p [7 ]:
244+ for label , text , example in p [7 ]:
245245 p [0 ].add_example (label , text , example )
246246
247247 def p_inheritance (self , p ):
@@ -251,60 +251,54 @@ def p_inheritance(self, p):
251251 p [0 ] = p [2 ]
252252
253253 def p_statement_typedef_struct (self , p ):
254- 'typedef : STRUCT ID inheritance COLON NEWLINE INDENT docsection field_list example_list DEDENT'
254+ 'typedef : STRUCT ID inheritance NEWLINE INDENT docsection field_list example_list DEDENT'
255255 p [0 ] = BabelTypeDef (p [1 ], p [2 ], extends = p [3 ])
256- if p [7 ]:
257- p [0 ].set_doc (self ._normalize_docstring (p [7 ]))
256+ if p [6 ]:
257+ p [0 ].set_doc (self ._normalize_docstring (p [6 ]))
258+ if p [7 ] is not None :
259+ p [0 ].set_fields (p [7 ])
258260 if p [8 ] is not None :
259- p [0 ].set_fields (p [8 ])
260- if p [9 ] is not None :
261- for label , text , example in p [9 ]:
261+ for label , text , example in p [8 ]:
262262 p [0 ].add_example (label , text , example )
263263
264264 def p_statement_request_section (self , p ):
265- """reqsection : REQUEST COLON NEWLINE INDENT field_list DEDENT"""
266- p [0 ] = p [5 ]
265+ """reqsection : REQUEST NEWLINE INDENT field_list DEDENT"""
266+ p [0 ] = p [4 ]
267267
268268 def p_statement_response_section (self , p ):
269- """respsection : RESPONSE COLON NEWLINE INDENT field_list DEDENT"""
270- p [0 ] = p [5 ]
269+ """respsection : RESPONSE NEWLINE INDENT field_list DEDENT"""
270+ p [0 ] = p [4 ]
271271
272272 def p_statement_error_section (self , p ):
273- """errorsection : ERROR COLON NEWLINE INDENT ID NEWLINE DEDENT
273+ """errorsection : ERROR NEWLINE INDENT ID NEWLINE DEDENT
274274 | empty"""
275275 if p [1 ]:
276- p [0 ] = p [5 ]
276+ p [0 ] = p [4 ]
277277
278278 def p_statement_extras_section (self , p ):
279- """extrassection : EXTRAS COLON NEWLINE INDENT example_field_list DEDENT
279+ """extrassection : EXTRAS NEWLINE INDENT example_field_list DEDENT
280280 | empty"""
281281 if p [1 ]:
282- p [0 ] = p [5 ]
282+ p [0 ] = p [4 ]
283+
284+ def p_path (self , p ):
285+ """path_option : PATH
286+ | empty"""
287+ p [0 ] = p [1 ]
283288
284289 def p_statement_opdef (self , p ):
285- """opdef : OP ID COLON NEWLINE INDENT docsection reqsection respsection errorsection extrassection DEDENT
286- | OP ID PATH COLON NEWLINE INDENT docsection reqsection respsection errorsection extrassection DEDENT"""
287- if p [3 ] == ':' :
288- p [0 ] = BabelOpDef (p [2 ])
289- p [0 ].set_doc (self ._normalize_docstring (p [6 ]))
290- p [0 ].set_request_segmentation (p [7 ])
291- p [0 ].set_response_segmentation (p [8 ])
292- if p [9 ]:
293- p [0 ].set_error_data_type_name (p [9 ])
294- if p [10 ]:
295- p [0 ].set_extras (dict (p [10 ]))
296- else :
297- p [0 ] = BabelOpDef (p [2 ], p [3 ])
298- p [0 ].set_doc (self ._normalize_docstring (p [7 ]))
299- p [0 ].set_request_segmentation (p [8 ])
300- p [0 ].set_response_segmentation (p [9 ])
301- if p [10 ]:
302- p [0 ].set_error_data_type_name (p [10 ])
303- if p [11 ]:
304- p [0 ].set_extras (dict (p [11 ]))
290+ 'opdef : OP ID path_option NEWLINE INDENT docsection reqsection respsection errorsection extrassection DEDENT'
291+ p [0 ] = BabelOpDef (p [2 ], p [3 ])
292+ p [0 ].set_doc (self ._normalize_docstring (p [6 ]))
293+ p [0 ].set_request_segmentation (p [7 ])
294+ p [0 ].set_response_segmentation (p [8 ])
295+ if p [9 ]:
296+ p [0 ].set_error_data_type_name (p [9 ])
297+ if p [10 ]:
298+ p [0 ].set_extras (dict (p [10 ]))
305299
306300 def p_statement_add_doc (self , p ):
307- """docsection : KEYWORD DOUBLE_COLON docstring DEDENT
301+ """docsection : KEYWORD COLON docstring DEDENT
308302 | empty"""
309303 if p [1 ]:
310304 if p [1 ] != 'doc' :
@@ -371,7 +365,7 @@ def p_default_option(self, p):
371365 p [0 ] = p [1 ]
372366
373367 def p_statement_field (self , p ):
374- """field : ID ID attributes_group nullable default_option presence deprecation DOUBLE_COLON docstring DEDENT
368+ """field : ID ID attributes_group nullable default_option presence deprecation COLON docstring DEDENT
375369 | ID ID attributes_group nullable default_option presence deprecation NEWLINE"""
376370 has_docstring = (p [8 ] == '::' )
377371 p [0 ] = BabelField (p [1 ], p [2 ], p [3 ], p [4 ], p [6 ], p [7 ])
@@ -384,15 +378,15 @@ def p_statement_field(self, p):
384378 p [0 ].set_doc (self ._normalize_docstring (p [9 ]))
385379
386380 def p_statement_field_symbol (self , p ):
387- 'field : ID DOUBLE_COLON docstring DEDENT'
381+ 'field : ID COLON docstring DEDENT'
388382 p [0 ] = BabelSymbol (p [1 ])
389383 if p [3 ]:
390384 p [0 ].set_doc (self ._normalize_docstring (p [3 ]))
391385
392386 def p_statement_example (self , p ):
393- """example : KEYWORD ID STRING COLON NEWLINE INDENT example_field_list DEDENT
394- | KEYWORD ID empty COLON NEWLINE INDENT example_field_list DEDENT"""
395- p [0 ] = (p [2 ], p [3 ], p [7 ])
387+ """example : KEYWORD ID STRING NEWLINE INDENT example_field_list DEDENT
388+ | KEYWORD ID empty NEWLINE INDENT example_field_list DEDENT"""
389+ p [0 ] = (p [2 ], p [3 ], p [6 ])
396390
397391 def p_statement_example_field_list (self , p ):
398392 """example_field_list : example_field
0 commit comments