Start =
[UsingStatements], (NamespaceDeclaration | TypeDeclaration);
TypeDeclaration =
ClassDeclaration
| StructDeclaration
| InterfaceDeclaration
| EnumDeclaration
| DelegateDeclaration;
This topic describes how to improve EBNF file readability.
The following topics are prerequisites to understanding this topic:
The following are some techniques for improving your EBNF code readability:
Begin each non-terminal symbol on its own line at the left side with each root-level choice on its own indented line:
Start =
[UsingStatements], (NamespaceDeclaration | TypeDeclaration);
TypeDeclaration =
ClassDeclaration
| StructDeclaration
| InterfaceDeclaration
| EnumDeclaration
| DelegateDeclaration;
If one of those root level choices consists of a long series of concatenations, move part of the series to the next line and insert another indent being careful to ensure that each term remains on 1 line:
ClassDeclaration =
[Attributes], [Modifiers], [PartialKeyword], ClassKeyword, Identifier,
[TypeParameterList], [BaseList], [TypeParameterConstraintClauses],
OpenBrace, ClassMembers, CloseBrace, [Semicolon]
| …
| …;
The following topics provide additional information related to this topic.