@@ -115,7 +115,6 @@ def __init__(self,
115115 name ,
116116 data_type_name ,
117117 data_type_attrs ,
118- nullable ,
119118 optional ,
120119 deprecated ):
121120 """
@@ -125,7 +124,6 @@ def __init__(self,
125124 self .data_type_name = data_type_name
126125 self .data_type_attrs = data_type_attrs
127126 self .doc = None
128- self .nullable = nullable
129127 self .has_default = False
130128 self .default = None
131129 self .optional = optional
@@ -372,25 +370,10 @@ def p_field_list_extend(self, p):
372370 p [0 ] = p [1 ]
373371 p [0 ].append (p [2 ])
374372
375- def p_field_nullable (self , p ):
376- """nullable : PIPE ID
373+ def p_field_optional (self , p ):
374+ """optional : Q
377375 | empty"""
378- if p [1 ] is not None :
379- if p [2 ] != 'Null' :
380- raise ValueError ('Only Null can be specified in a union' )
381- else :
382- p [0 ] = True
383- else :
384- p [0 ] = False
385-
386- def p_field_presence (self , p ):
387- """presence : REQUIRED
388- | OPTIONAL
389- | empty"""
390- if bool (p [1 ]):
391- p [0 ] = (p [1 ] == 'optional' )
392- else :
393- p [0 ] = False
376+ p [0 ] = p [1 ] == '?'
394377
395378 def p_field_deprecation (self , p ):
396379 """deprecation : DEPRECATED
@@ -411,22 +394,17 @@ def p_default_option(self, p):
411394 p [0 ] = p [1 ]
412395
413396 def p_statement_field (self , p ):
414- """field : ID ID attributes_group nullable default_option presence deprecation COLON docstring DEDENT
415- | ID ID attributes_group nullable default_option presence deprecation NEWLINE INDENT docstring NEWLINE DEDENT
416- | ID ID attributes_group nullable default_option presence deprecation NEWLINE"""
417-
418- has_old_style_docstring = (p [8 ] == ':' )
419- has_new_style_docstring = not has_old_style_docstring and len (p ) > 9
420- p [0 ] = BabelField (p [1 ], p [2 ], p [3 ], p [4 ], p [6 ], p [7 ])
397+ """field : ID ID attributes_group optional default_option deprecation NEWLINE INDENT docstring NEWLINE DEDENT
398+ | ID ID attributes_group optional default_option deprecation NEWLINE"""
399+ has_docstring = len (p ) > 9
400+ p [0 ] = BabelField (p [1 ], p [2 ], p [3 ], p [4 ], p [6 ])
421401 if p [5 ] is not None :
422402 if p [5 ] is BabelNull :
423403 p [0 ].set_default (None )
424404 else :
425405 p [0 ].set_default (p [5 ])
426- if has_old_style_docstring :
427- p [0 ].set_doc (self ._normalize_docstring (p [9 ]))
428- elif has_new_style_docstring :
429- p [0 ].set_doc (p [10 ])
406+ elif has_docstring :
407+ p [0 ].set_doc (p [9 ])
430408
431409 def p_statement_field_symbol (self , p ):
432410 """field : ID COLON docstring DEDENT
0 commit comments