ensure primitive types can be used as root of schema
This commit is contained in:
parent
5ef33fbd5c
commit
766ec56642
1 changed files with 4 additions and 1 deletions
|
@ -90,7 +90,10 @@ class SchemaConverter:
|
||||||
|
|
||||||
else:
|
else:
|
||||||
assert schema_type in PRIMITIVE_RULES, f'Unrecognized schema: {schema}'
|
assert schema_type in PRIMITIVE_RULES, f'Unrecognized schema: {schema}'
|
||||||
return self._add_rule(schema_type, PRIMITIVE_RULES[schema_type])
|
return self._add_rule(
|
||||||
|
'root' if rule_name == 'root' else schema_type,
|
||||||
|
PRIMITIVE_RULES[schema_type]
|
||||||
|
)
|
||||||
|
|
||||||
def format_grammar(self):
|
def format_grammar(self):
|
||||||
return '\n'.join((f'{name} ::= {rule}' for name, rule in self._rules.items()))
|
return '\n'.join((f'{name} ::= {rule}' for name, rule in self._rules.items()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue