Fix bugs wrt pexpr trailers

This commit is contained in:
Tony Garnock-Jones 2023-11-01 15:35:59 +01:00
parent d638555239
commit 85b3e513f9
3 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
The definitions of `Atom`, `ws`, and `linecomment` are as given in the Preserves text syntax.
```text
Document := Expr* ws
Document := Expr* Trailer ws
Expr := ws (SimpleExpr | Punct)
SimpleExpr := Compound | Embedded | Annotated | Atom
Compound := Sequence | Record | Block | Group | Set
@ -13,7 +13,7 @@ Block := `{` Expr* Trailer ws `}`
Group := `(` Expr* Trailer ws `)`
Set := `#{` Expr* Trailer ws `}`
Trailer := Annotation*
Trailer := (ws Annotation)*
Embedded := `#!` SimpleExpr
Annotated := Annotation SimpleExpr

View File

@ -1,7 +1,7 @@
The definitions of `Atom`, `ws`, and `linecomment` are as given in the Preserves text syntax.
{:.postcard-grammar.textsyntax}
| *Document* | := | *Expr*<sup></sup> **ws**
| *Document* | := | *Expr*<sup></sup> *Trailer* **ws**
| *Expr* | := | **ws** (*SimpleExpr* &#124; *Punct*)
| *SimpleExpr* | := | *Compound* &#124; *Embedded* &#124; *Annotated* &#124; *Atom*
| *Compound* | := | *Sequence* &#124; *Record* &#124; *Block* &#124; *Group* &#124; *Set*
@ -15,7 +15,7 @@ The definitions of `Atom`, `ws`, and `linecomment` are as given in the Preserves
| *Set* | := | `#{` *Expr*<sup></sup> *Trailer* **ws** `}`
{:.postcard-grammar.textsyntax}
| *Trailer* | := | *Annotation*<sup></sup>
| *Trailer* | := | (**ws** *Annotation*)<sup></sup>
{:.postcard-grammar.textsyntax}
| *Embedded* | := | `#!` *SimpleExpr*

View File

@ -41,9 +41,9 @@ below](#reading-preserves)).
## Grammar
Standalone documents containing P-expressions are sequences of
individual `Expr`s, followed by trailing whitespace.
individual `Expr`s, followed by annotations, comments, and/or whitespace.
Document = *Expr ws
Document = *Expr Trailer ws
A single P-expression `Expr` can be an `Atom` from the [text syntax][],
a compound expression, special punctuation, an `Embedded` expression, or
@ -81,7 +81,7 @@ common in programming notations to allow comments at the end of a file
or other sequential construct. The ordinary text syntax forbids comments
in these positions, but P-expressions allow them.
Trailer = *Annotation
Trailer = *(ws Annotation)
## <a id="encoding-pexprs"></a>Encoding P-expressions as Preserves