diff --git a/p4-16/spec/P4-16-spec.mdk b/p4-16/spec/P4-16-spec.mdk index 00fbd58c72..38258debc9 100644 --- a/p4-16/spec/P4-16-spec.mdk +++ b/p4-16/spec/P4-16-spec.mdk @@ -2151,6 +2151,7 @@ to a `set` type. These types are used during type-checking. typeDeclaration : derivedTypeDeclaration | typedefDeclaration + | newtypeDeclaration | parserTypeDeclaration ';' | controlTypeDeclaration ';' | packageTypeDeclaration ';' @@ -2992,7 +2993,8 @@ Similarly to `typedef`, the keyword `type` can be used to introduce a new type. ~ Begin P4Grammar - | optAnnotations TYPE typeRef name +newtypeDeclaration + : optAnnotations TYPE typeRef name | optAnnotations TYPE derivedTypeDeclaration name ~ End P4Grammar @@ -5160,10 +5162,10 @@ emptyStatement ## Block statement { #sec-block-stmt } -A block statement is denoted by curly braces. It contains a -sequence of statements and declarations, which are executed -sequentially. The variables and constants within a -block statement are only visible within the block. +A block statement is denoted by curly braces. It contains a sequence +of statements and declarations, which are executed sequentially. The +variables, constants, typedefs, and instantiations within a block +statement are only visible within the block. ~ Begin P4Grammar blockStatement @@ -5178,6 +5180,7 @@ statOrDeclList statementOrDeclaration : variableDeclaration | constantDeclaration + | typedefDeclaration | statement ; ~ End P4Grammar diff --git a/p4-16/spec/grammar.mdk b/p4-16/spec/grammar.mdk index 7e6c35d301..23fe7bd5a2 100644 --- a/p4-16/spec/grammar.mdk +++ b/p4-16/spec/grammar.mdk @@ -378,6 +378,7 @@ typeArgumentList typeDeclaration : derivedTypeDeclaration | typedefDeclaration + | newtypeDeclaration | parserTypeDeclaration ';' | controlTypeDeclaration ';' | packageTypeDeclaration ';' @@ -441,6 +442,9 @@ specifiedIdentifier typedefDeclaration : optAnnotations TYPEDEF typeRef name ';' | optAnnotations TYPEDEF derivedTypeDeclaration name ';' + ; + +newtypeDeclaration | optAnnotations TYPE typeRef name ';' | optAnnotations TYPE derivedTypeDeclaration name ';' ; @@ -518,6 +522,7 @@ switchLabel statementOrDeclaration : variableDeclaration | constantDeclaration + | typedefDeclaration | statement ;