diff options
| author | Jonas Smedegaard <dr@jones.dk> | 2025-05-20 12:46:28 +0200 |
|---|---|---|
| committer | Jonas Smedegaard <dr@jones.dk> | 2025-05-20 12:46:28 +0200 |
| commit | 2dd336f404674b7cb4c106d9b6bf98de071130a9 (patch) | |
| tree | 8fa1b3ed8975f7189447cd648128572046f6455c | |
| parent | 4786783eef1708c19a25b69851047298986ef89c (diff) | |
group syntax diagrams; add AnnotatedWordsX SEMPREFIX SemWords
| -rw-r--r-- | _markdown.qmd | 72 | ||||
| -rwxr-xr-x | def_AnnotatedWordsX.py | 23 | ||||
| -rwxr-xr-x | def_SEMPREFIX.py | 13 | ||||
| -rwxr-xr-x | def_SemWords.py | 24 |
4 files changed, 106 insertions, 26 deletions
diff --git a/_markdown.qmd b/_markdown.qmd index adb82c9..778bf72 100644 --- a/_markdown.qmd +++ b/_markdown.qmd @@ -12,7 +12,7 @@ where the possible order of elements are laid out like trains on rails, as seen in @fig-def-Markdown. -{#fig-def-Markdown} +{#fig-def-Markdown} Here is an example: @@ -31,20 +31,24 @@ the syntax for the block types `Header` and `Paragraph` `Header` consists of space-delimited words followed a line break, and `Paragraph` consists of lines of space-delimited words followed by two or more line breaks. -See @fig-def-Block, @fig-def-Header and @fig-def-Paragraph -for syntax diagrams for those block types. +See @fig-def-blocks for syntax diagrams for those block types. -{#fig-def-Block} +::: {#fig-def-blocks} -{#fig-def-Header} + -{#fig-def-Paragraph} + + + + +Syntax of `Block`, `Header` and `Paragraph`. + +::: Reading order matters: The syntax diagrams should be read left-to-right and top-to-bottom, also at places with choice -- -e.g. the block type `Header` should be tried before `Paragraph` -(see @fig-def-Block). +e.g. the block type `Header` should be tried before `Paragraph`. Otherwise if `Paragraph` syntax was parsed first, then it would match both blocks because that block type begins with any words, @@ -60,23 +64,26 @@ is included as [Appendix @sec-def-peg]. Words are sets of printable characters (including punctuation and other printable characters). -They can be styled -(@fig-def-StyledWords), +They can be styled, have a hyperlink annotated -(@fig-def-LinkedWords) -and have CSS structure and styling annotated -(@fig-def-AnnotatedWords). +and have CSS structure and styling annotated. Each set can contain each other, -or a set of plain words -(@fig-def-PlainWords). +or a set of plain words. +Se @fig-def-words for their syntax diagrams. + +::: {#fig-def-words} -{#fig-def-StyledWords} + -{#fig-def-LinkedWords} + -{#fig-def-AnnotatedWords} + -{#fig-def-PlainWords} + + +Syntax of `StyledWords`, `LinkedWords`, `AnnotatedWords` and `PlainWords`. + +::: <!-- @@ -85,7 +92,7 @@ consisting of list items, each containing a block (@fig-def-List). -{#fig-def-List} +{#fig-def-List} --> @@ -110,24 +117,37 @@ but in practice expects CSS id or class definitions, which means alphanumeric-only words prefixed by either dot or hash. New higher prioritized syntaxes are added that should not clash with these, for URI and CURIE words, -as in @fig-def-AnnotatedWordsX, @fig-def-SemWords and @fig-def-SEMPREFIX. - -{#fig-def-AnnotatedWordsX} +as in @fig-def-extensions. *FIXME: mention and draw extended LinkedWordsX as well.* +::: {#fig-def-extensions} + + + +Syntax of `AnnotatedWords` and `LinkedWords`, extended with `SemWords`. + +::: + The new `SemWords` are components in the RDF language, which is described further in @sec-rdf either an angle-bracketed `Uri` or a `CURIE`. Each component has an optional prefix -to denote whether it is a subject, predicate or object. +to denote whether it is an RDF subject, predicate or object. (Again, these RDF terms are described further in @sec-rdf). +See @fig-def-additions for their syntax diagrams. *FIXME: mention and draw `Curie` and `NAME`* -{#fig-def-SemWords} +::: {#fig-def-additions} + + + + + +Syntax of `SemWords`, `Curie`, `SEMPREFIX` and `NAME`. -{#fig-def-SEMPREFIX} +::: ## Expectations of processors diff --git a/def_AnnotatedWordsX.py b/def_AnnotatedWordsX.py new file mode 100755 index 0000000..a90aaf6 --- /dev/null +++ b/def_AnnotatedWordsX.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 + +# Copyright 2025, Jonas Smedegaard <dr@jones.dk> +# SPDX-License-Identifier: GPL-3+ + +from os.path import basename, splitext +from railroad import * + +Diagram( + "[", + NonTerminal("Words"), + "]", + "{", + Choice(0, + Group( + NonTerminal('SemWords'), + ), + NonTerminal('![{}] PlainWords'), + ), + "}", + type="complex" +).writeStandalone( + open(splitext(basename(__file__))[0] + ".svg", "w").write) diff --git a/def_SEMPREFIX.py b/def_SEMPREFIX.py new file mode 100755 index 0000000..a7fc4a0 --- /dev/null +++ b/def_SEMPREFIX.py @@ -0,0 +1,13 @@ +#!/usr/bin/python3 + +# Copyright 2025, Jonas Smedegaard <dr@jones.dk> +# SPDX-License-Identifier: GPL-3+ + +from os.path import basename, splitext +from railroad import * + +Diagram( + "[.#]", + type="complex" +).writeStandalone( + open(splitext(basename(__file__))[0] + ".svg", "w").write) diff --git a/def_SemWords.py b/def_SemWords.py new file mode 100755 index 0000000..292e4b4 --- /dev/null +++ b/def_SemWords.py @@ -0,0 +1,24 @@ +#!/usr/bin/python3 + +# Copyright 2025, Jonas Smedegaard <dr@jones.dk> +# SPDX-License-Identifier: GPL-3+ + +from os.path import basename, splitext +from railroad import * + +Diagram( + Choice(0, + Sequence( + NonTerminal("SEMPREFIX"), + "<", + NonTerminal("![<>] PRINTABLES"), + ">", + ), + Sequence( + NonTerminal("SEMPREFIX"), + NonTerminal("CURIE"), + ) + ), + type="complex" +).writeStandalone( + open(splitext(basename(__file__))[0] + ".svg", "w").write) |
