Skip to content

Commit

Permalink
Rewrite grammar and parser
Browse files Browse the repository at this point in the history
This commit is a complete rewrite of the Smithy IDL parser and grammar.
It is intended to clear up the intention of how the IDL works in
practice by making the grammar embed things like how control statements
come before metadata, which come before namespace, etc.. It also
clarifies how different node_value locations have different semantics
(e.g., keys in objects are not resolved against keywords like
true and do not perform relative shape ID resolution nor do they support
text blocks). Many other fixes have been made to the grammar too,
including specifying where whitespace is allowed and where line breaks
are required. This makes the grammar more verbose but also more accurate
and in line with what was already implemented.

With these changes, control statement keyus, metadata keys, and object keys
must now be quoted if they contain ".", "#", or "$". In practice, the
model parser already enforced these constraints in some places.
  • Loading branch information
mtdowling committed May 13, 2020
1 parent 42faf2f commit 1e2a417
Show file tree
Hide file tree
Showing 127 changed files with 2,498 additions and 2,241 deletions.
267 changes: 103 additions & 164 deletions docs/source/1.0/spec/core/lexical-structure.rst

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions docs/source/1.0/spec/core/model-metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ Model metadata
==============

:dfn:`Metadata` is a schema-less extensibility mechanism that can be applied
to a model using a :ref:`metadata statement <metadata-statement>`.
to a model using a :ref:`metadata statement <metadata-statement>`. For
example, metadata is used to define :ref:`validators <validation>` and
:ref:`suppressions <suppression-definition>` that are applied to the entire
model.

.. contents:: Table of contents
:depth: 1
Expand All @@ -19,26 +22,24 @@ to a model using a :ref:`metadata statement <metadata-statement>`.
Metadata statement
------------------

The metadata statement is used to attach arbitrary :ref:`metadata <metadata>`
to a model. Metadata statements MUST appear before a namespace statement
or any shapes are defined.
Metadata statements MUST appear before any namespace statement or any shapes
are defined. Metadata is defined by the following ABNF:

.. productionlist:: smithy
metadata_statement:"metadata" `metadata_key` "=" `metadata_value`
metadata_key:`text`
metadata_value:`node_value`
metadata_section :*(`metadata_statement`)
metadata_statement :"metadata" `ws` `node_object_key` `ws` "=" `ws` `node_value` `br`
.. code-block:: smithy
:caption: Example
metadata example.string1 = "hello there"
metadata example.string2 = 'hello there'
metadata example.bool1 = true
metadata example.bool2 = false
metadata example.number = 10
metadata example.array = [10, true, "hello"]
metadata example.object = {foo: "baz"}
metadata example.null = null
metadata exampleString = "hello there"
metadata "example.string2" = 'hello there'
metadata bool1 = true
metadata bool2 = false
metadata number = 10
metadata array = [10, true, "hello"]
metadata object = {foo: "baz"}
metadata null = null
.. _merging-metadata:
Expand Down
Loading

0 comments on commit 1e2a417

Please sign in to comment.