From 18ac8481e5bcfe376bddfc1b79e61fe0a6ceef2b Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Wed, 14 Mar 2018 12:12:42 -0400 Subject: [PATCH 1/2] replace BNF grammar with ANTL grammar The BNF grammar rendering was quite messy. Antlr provides a much more clear rendering on the current engine. --- .../specifying-fully-qualified-type-names.md | 102 ++++++++++++++---- 1 file changed, 81 insertions(+), 21 deletions(-) diff --git a/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md b/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md index 0fb0dc973c8b6..0f184587a7a83 100644 --- a/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md +++ b/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md @@ -33,27 +33,87 @@ ms.workload: # Specifying Fully Qualified Type Names You must specify type names to have valid input to various reflection operations. A fully qualified type name consists of an assembly name specification, a namespace specification, and a type name. Type name specifications are used by methods such as , , , and . -## Backus-Naur Form Grammar for Type Names - The Backus-Naur form (BNF) defines the syntax of formal languages. The following table lists BNF lexical rules that describe how to recognize a valid input. Terminals (those elements that are not further reducible) are shown in all uppercase letters. Nonterminals (those elements that are further reducible) are shown in mixed-case or singly quoted strings, but the single quote (') is not a part of the syntax itself. The pipe character (|) denotes rules that have subrules. - -|BNF grammar of fully qualified type names| -|-----------------------------------------------| -|TypeSpec := ReferenceTypeSpec

| SimpleTypeSpec| -|ReferenceTypeSpec := SimpleTypeSpec '&'| -|SimpleTypeSpec := PointerTypeSpec

| ArrayTypeSpec

| TypeName| -|PointerTypeSpec := SimpleTypeSpec '*'| -|ArrayTypeSpec := SimpleTypeSpec '[ReflectionDimension]'

| SimpleTypeSpec '[ReflectionEmitDimension]'| -|ReflectionDimension := '*'

| ReflectionDimension ',' ReflectionDimension

| NOTOKEN| -|ReflectionEmitDimension := '*'

| Number '..' Number

| Number '…'

| ReflectionDimension ',' ReflectionDimension

| NOTOKEN| -|Number := [0-9]+| -|TypeName := NamespaceTypeName

| NamespaceTypeName ',' AssemblyNameSpec| -|NamespaceTypeName := NestedTypeName

| NamespaceSpec '.' NestedTypeName| -|NestedTypeName := IDENTIFIER

| NestedTypeName '+' IDENTIFIER| -|NamespaceSpec := IDENTIFIER

| NamespaceSpec '.' IDENTIFIER| -|AssemblyNameSpec := IDENTIFIER

| IDENTIFIER ',' AssemblyProperties| -|AssemblyProperties := AssemblyProperty

| AssemblyProperties ',' AssemblyProperty| -|AssemblyProperty := AssemblyPropertyName '=' AssemblyPropertyValue| - +## Grammar for Type Names + The grammar defines the syntax of formal languages. The following table lists lexical rules that describe how to recognize a valid input. Terminals (those elements that are not further reducible) are shown in all uppercase letters. Nonterminals (those elements that are further reducible) are shown in mixed-case or singly quoted strings, but the single quote (') is not a part of the syntax itself. The pipe character (|) denotes rules that have subrules. + +```antlr +TypeSpec + : ReferenceTypeSpec + | SimpleTypeSpec + ; + +ReferenceTypeSpec + : SimpleTypeSpec '&' + ; + +SimpleTypeSpec + : PointerTypeSpec + | ArrayTypeSpec + | TypeName + ; + +PointerTypeSpec + : SimpleTypeSpec '*' + ; + +ArrayTypeSpec + : SimpleTypeSpec '[ReflectionDimension]' + | SimpleTypeSpec '[ReflectionEmitDimension]' + ; + +ReflectionDimension + : '*' + | ReflectionDimension ',' ReflectionDimension + | NOTOKEN + ; + +ReflectionEmitDimension + : '*' + | Number '..' Numero + | Number '…' + | ReflectionDimension ',' ReflectionDimension + | NOTOKEN + ; + +Number + : [0-9]+ + ; + +TypeName + : NamespaceTypeName + | NamespaceTypeName ',' AssemblyNameSpec + ; + +NamespaceTypeName + : NestedTypeName + | NamespaceSpec '.' NestedTypeName + ; + +NestedTypeName + : IDENTIFIER + | NestedTypeName '+' IDENTIFIER + ; + +NamespaceSpec + : IDENTIFIER + | NamespaceSpec '.' IDENTIFIER + ; + +AssemblyNameSpec + : IDENTIFIER + | IDENTIFIER ',' AssemblyProperties + ; + +AssemblyProperties + : AssemblyProperty + | AssemblyProperties ',' AssemblyProperty + ; + +AssemblyProperty + : AssemblyPropertyName '=' AssemblyPropertyValue + ; +``` + ## Specifying Special Characters In a type name, IDENTIFIER is any valid name determined by the rules of a language. From 7569aaf6918ddef69ce62303cde5e3ebd7505db0 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Wed, 14 Mar 2018 13:32:27 -0400 Subject: [PATCH 2/2] fix typo and update metadata --- .../specifying-fully-qualified-type-names.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md b/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md index 0f184587a7a83..4da8a1b3b7361 100644 --- a/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md +++ b/docs/framework/reflection-and-codedom/specifying-fully-qualified-type-names.md @@ -1,7 +1,7 @@ --- title: "Specifying Fully Qualified Type Names" ms.custom: "" -ms.date: "03/30/2017" +ms.date: "03/14/2018" ms.prod: ".net-framework" ms.reviewer: "" ms.suite: "" @@ -16,8 +16,7 @@ helpviewer_keywords: - "tokens" - "BNF" - "assemblies [.NET Framework], names" - - "Backus-Naur form" - - "languages, BNF grammar" + - "languages, grammar" - "fully qualified type names" - "type names" - "special characters" @@ -69,7 +68,7 @@ ReflectionDimension ReflectionEmitDimension : '*' - | Number '..' Numero + | Number '..' Number | Number '…' | ReflectionDimension ',' ReflectionDimension | NOTOKEN