Cheatsheets for pexprs
This commit is contained in:
parent
39bfeedb54
commit
ebd8b3f05b
|
@ -73,6 +73,7 @@ automatic, perfect-fidelity conversion between syntaxes.
|
||||||
|
|
||||||
## Additional resources
|
## Additional resources
|
||||||
|
|
||||||
|
- [Preserves Expressions (P-expressions, pexprs)](preserves-expressions.html)
|
||||||
- Some [conventions for common data types](conventions.html)
|
- Some [conventions for common data types](conventions.html)
|
||||||
- [Open questions](questions.html); see also the
|
- [Open questions](questions.html); see also the
|
||||||
[issues list]({{page.projectpages}}/issues)
|
[issues list]({{page.projectpages}}/issues)
|
||||||
|
|
|
@ -1,22 +1,21 @@
|
||||||
The definition of `Atom` is as given in the Preserves text syntax.
|
The definitions of `Atom`, `ws`, and `linecomment` are as given in the Preserves text syntax.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
Document := Expr* sp
|
Document := Expr* ws
|
||||||
Expr := sp (Atom | Compound | Punct | Embedded | Annotated)
|
Expr := ws (SimpleExpr | Punct)
|
||||||
|
SimpleExpr := Atom | Compound | Embedded | Annotated
|
||||||
Compound := Sequence | Record | Block | Group | Set
|
Compound := Sequence | Record | Block | Group | Set
|
||||||
Punct := `,` | `;` | `:`+
|
Punct := `,` | `;` | `:`+
|
||||||
|
|
||||||
sp := (space | tab | cr | lf)*
|
Sequence := `[` Expr* Trailer ws `]`
|
||||||
|
Record := `<` Expr* Trailer ws `>`
|
||||||
Sequence := `[` Expr* Trailer sp `]`
|
Block := `{` Expr* Trailer ws `}`
|
||||||
Record := `<` Expr* Trailer sp `>`
|
Group := `(` Expr* Trailer ws `)`
|
||||||
Block := `{` Expr* Trailer sp `}`
|
Set := `#{` Expr* Trailer ws `}`
|
||||||
Group := `(` Expr* Trailer sp `)`
|
|
||||||
Set := `#{` Expr* Trailer sp `}`
|
|
||||||
|
|
||||||
Trailer := Annotation*
|
Trailer := Annotation*
|
||||||
|
|
||||||
Embedded := `#!` Expr
|
Embedded := `#!` SimpleExpr
|
||||||
Annotated := Annotation Expr
|
Annotated := Annotation SimpleExpr
|
||||||
Annotation := `@` Expr | `#` ((space | tab) linecomment) (cr | lf)
|
Annotation := `@` SimpleExpr | `#` ((space | tab) linecomment) (cr | lf)
|
||||||
```
|
```
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
The definitions of `Atom`, `ws`, and `linecomment` are as given in the Preserves text syntax.
|
||||||
|
|
||||||
|
{:.postcard-grammar.textsyntax}
|
||||||
|
| *Document* | := | *Expr*<sup>⋆</sup> **ws**
|
||||||
|
| *Expr* | := | **ws** (*SimpleExpr* | *Punct*)
|
||||||
|
| *SimpleExpr* | := | *Atom* | *Compound* | *Embedded* | *Annotated*
|
||||||
|
| *Compound* | := | *Sequence* | *Record* | *Block* | *Group* | *Set*
|
||||||
|
| *Punct* | := | `,` | `;` | `:`<sup>+</sup>
|
||||||
|
|
||||||
|
{:.postcard-grammar.textsyntax}
|
||||||
|
| *Sequence* | := | `[` *Expr*<sup>⋆</sup> *Trailer* **ws** `]`
|
||||||
|
| *Record* | := | `<` *Expr*<sup>⋆</sup> *Trailer* **ws** `>`
|
||||||
|
| *Block* | := | `{` *Expr*<sup>⋆</sup> *Trailer* **ws** `}`
|
||||||
|
| *Group* | := | `(` *Expr*<sup>⋆</sup> *Trailer* **ws** `)`
|
||||||
|
| *Set* | := | `#{` *Expr*<sup>⋆</sup> *Trailer* **ws** `}`
|
||||||
|
|
||||||
|
{:.postcard-grammar.textsyntax}
|
||||||
|
| *Trailer* | := | *Annotation*<sup>⋆</sup>
|
||||||
|
|
||||||
|
{:.postcard-grammar.textsyntax}
|
||||||
|
| *Embedded* | := | `#!` *SimpleExpr*
|
||||||
|
| *Annotated* | := | *Annotation* *SimpleExpr*
|
||||||
|
| *Annotation* | := | `@` *SimpleExpr* | `#` ((**space** | **tab**) *linecomment*) (**cr** | **lf**)
|
|
@ -6,6 +6,20 @@ title: "Preserves Quick Reference (Plaintext)"
|
||||||
Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||||
{{ site.version_date }}. Version {{ site.version }}.
|
{{ site.version_date }}. Version {{ site.version }}.
|
||||||
|
|
||||||
|
These are non-normative "reference card" definitions. See also the normative [semantics]({{
|
||||||
|
site.baseurl }}/preserves.html), [text syntax specification]({{ site.baseurl
|
||||||
|
}}/preserves-text.html), and [machine-oriented syntax specification]({{ site.baseurl
|
||||||
|
}}/preserves-binary.html), and the experimental [P-expressions definition]({{ site.baseurl
|
||||||
|
}}/preserves-expressions.html).
|
||||||
|
|
||||||
|
## <a id="binary"></a>Machine-Oriented Binary Syntax
|
||||||
|
|
||||||
{% include cheatsheet-binary-plaintext.md %}
|
{% include cheatsheet-binary-plaintext.md %}
|
||||||
|
|
||||||
|
## <a id="text"></a>Human-Oriented Text Syntax
|
||||||
|
|
||||||
{% include cheatsheet-text-plaintext.md %}
|
{% include cheatsheet-text-plaintext.md %}
|
||||||
|
|
||||||
|
## <a id="pexprs"></a>P-expression Syntax
|
||||||
|
|
||||||
|
{% include cheatsheet-pexprs-plaintext.md %}
|
||||||
|
|
|
@ -8,8 +8,9 @@ Tony Garnock-Jones <tonyg@leastfixedpoint.com>
|
||||||
|
|
||||||
These are non-normative "reference card" definitions. See also the normative [semantics]({{
|
These are non-normative "reference card" definitions. See also the normative [semantics]({{
|
||||||
site.baseurl }}/preserves.html), [text syntax specification]({{ site.baseurl
|
site.baseurl }}/preserves.html), [text syntax specification]({{ site.baseurl
|
||||||
}}/preserves-text.html) and [machine-oriented syntax specification]({{ site.baseurl
|
}}/preserves-text.html), and [machine-oriented syntax specification]({{ site.baseurl
|
||||||
}}/preserves-binary.html).
|
}}/preserves-binary.html), and the experimental [P-expressions definition]({{ site.baseurl
|
||||||
|
}}/preserves-expressions.html).
|
||||||
|
|
||||||
## <a id="binary"></a>Machine-Oriented Binary Syntax
|
## <a id="binary"></a>Machine-Oriented Binary Syntax
|
||||||
|
|
||||||
|
@ -18,3 +19,7 @@ site.baseurl }}/preserves.html), [text syntax specification]({{ site.baseurl
|
||||||
## <a id="text"></a>Human-Oriented Text Syntax
|
## <a id="text"></a>Human-Oriented Text Syntax
|
||||||
|
|
||||||
{% include cheatsheet-text.md %}
|
{% include cheatsheet-text.md %}
|
||||||
|
|
||||||
|
## <a id="pexprs"></a>P-expression Syntax
|
||||||
|
|
||||||
|
{% include cheatsheet-pexprs.md %}
|
||||||
|
|
|
@ -7,6 +7,7 @@ October 2023. Version 0.3.0.
|
||||||
|
|
||||||
[text syntax]: preserves-text.html
|
[text syntax]: preserves-text.html
|
||||||
|
|
||||||
|
**Experimental.**
|
||||||
This document defines a grammar called *Preserves Expressions*
|
This document defines a grammar called *Preserves Expressions*
|
||||||
(*P-expressions*, *pexprs*) that includes [ordinary Preserves text
|
(*P-expressions*, *pexprs*) that includes [ordinary Preserves text
|
||||||
syntax][text syntax] but offers extensions sufficient to support a Lisp-
|
syntax][text syntax] but offers extensions sufficient to support a Lisp-
|
||||||
|
@ -49,8 +50,8 @@ a compound expression, special punctuation, an `Embedded` expression, or
|
||||||
an `Annotated` expression. The class `SimpleExpr` includes all of `Expr`
|
an `Annotated` expression. The class `SimpleExpr` includes all of `Expr`
|
||||||
except special punctuation.
|
except special punctuation.
|
||||||
|
|
||||||
Expr = ws (SimpleExpr | Punct)
|
Expr = ws (SimpleExpr / Punct)
|
||||||
SimpleExpr = Atom | Compound | Embedded | Annotated
|
SimpleExpr = Atom / Compound / Embedded / Annotated
|
||||||
|
|
||||||
Embedded and annotated values are as in the text syntax, differing only
|
Embedded and annotated values are as in the text syntax, differing only
|
||||||
in that uses of `Value` are replaced with `SimpleExpr`.
|
in that uses of `Value` are replaced with `SimpleExpr`.
|
||||||
|
@ -58,6 +59,7 @@ in that uses of `Value` are replaced with `SimpleExpr`.
|
||||||
Embedded = "#!" SimpleExpr
|
Embedded = "#!" SimpleExpr
|
||||||
Annotated = Annotation SimpleExpr
|
Annotated = Annotation SimpleExpr
|
||||||
Annotation = "@" SimpleExpr / "#" [(%x20 / %x09) linecomment] (CR / LF)
|
Annotation = "@" SimpleExpr / "#" [(%x20 / %x09) linecomment] (CR / LF)
|
||||||
|
linecomment = *<any unicode scalar value except CR or LF>
|
||||||
|
|
||||||
P-expression special punctuation marks are comma, semicolon, and sequences of one or more colons.
|
P-expression special punctuation marks are comma, semicolon, and sequences of one or more colons.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue