From 082715930e3f04862bffee49df6641fcc152ef42 Mon Sep 17 00:00:00 2001 From: Miles Ziemer <45497130+milesziemer@users.noreply.github.com> Date: Tue, 20 Sep 2022 14:09:38 -0400 Subject: [PATCH] Fix apply statement parsing and ABNF (#1414) This fixes an issue where `applySomeShape @someTrait` was valid, without any space between the apply and shape name. The fix makes it so spacing is required, not line breaks as was the case in the old ABNF, to be consistent with other shapes grammar (see [SimpleShapeStatement](https://awslabs.github.io/smithy/2.0/spec/idl.html#grammar-token-smithy-SimpleShapeStatement)) --- docs/source-1.0/spec/core/idl.rst | 2 +- docs/source-2.0/spec/idl.rst | 2 +- .../software/amazon/smithy/model/loader/IdlModelParser.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source-1.0/spec/core/idl.rst b/docs/source-1.0/spec/core/idl.rst index b0d01e25127..af66f425079 100644 --- a/docs/source-1.0/spec/core/idl.rst +++ b/docs/source-1.0/spec/core/idl.rst @@ -235,7 +235,7 @@ string support defined in `RFC 5234 `_. : *(`Comma` `TraitStructureKvp` *`WS`) : `TrailingComma` TraitStructureKvp :`NodeObjectKey` *`WS` ":" *`WS` `NodeValue` - ApplyStatement :%s"apply" `WS` `ShapeId` `WS` `Trait` `BR` + ApplyStatement :%s"apply" `SP` `ShapeId` `WS` `Trait` `BR` .. rubric:: Shape ID diff --git a/docs/source-2.0/spec/idl.rst b/docs/source-2.0/spec/idl.rst index f6e24a7b192..3f500c6472d 100644 --- a/docs/source-2.0/spec/idl.rst +++ b/docs/source-2.0/spec/idl.rst @@ -237,7 +237,7 @@ string support defined in `RFC 5234 `_. TraitStructure :`TraitStructureKvp` *(*`WS` `TraitStructureKvp`) TraitStructureKvp :`NodeObjectKey` *`WS` ":" *`WS` `NodeValue` ApplyStatement :(`ApplyStatementSingular` / `ApplyStatementBlock`) - ApplyStatementSingular :%s"apply" `WS` `ShapeId` `WS` `Trait` `BR` + ApplyStatementSingular :%s"apply" `SP` `ShapeId` `WS` `Trait` `BR` ApplyStatementBlock :%s"apply" `SP` `ShapeId` `WS` "{" `TraitStatements` "}" `BR` .. rubric:: Shape ID diff --git a/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelParser.java b/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelParser.java index c8c60faf7f6..12b46e6da8e 100644 --- a/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelParser.java +++ b/smithy-model/src/main/java/software/amazon/smithy/model/loader/IdlModelParser.java @@ -1126,7 +1126,7 @@ private void parseApplyStatement() { expect('p'); expect('l'); expect('y'); - sp(); + rsp(); String name = ParserUtils.parseShapeId(this); rws();