From 2dd336f404674b7cb4c106d9b6bf98de071130a9 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Tue, 20 May 2025 12:46:28 +0200 Subject: group syntax diagrams; add AnnotatedWordsX SEMPREFIX SemWords --- _markdown.qmd | 72 ++++++++++++++++++++++++++++++++------------------ def_AnnotatedWordsX.py | 23 ++++++++++++++++ def_SEMPREFIX.py | 13 +++++++++ def_SemWords.py | 24 +++++++++++++++++ 4 files changed, 106 insertions(+), 26 deletions(-) create mode 100755 def_AnnotatedWordsX.py create mode 100755 def_SEMPREFIX.py create mode 100755 def_SemWords.py 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. -![Markdown](def_Markdown.svg){#fig-def-Markdown} +![Syntax of `Markdown`.](def_Markdown.svg){#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. -![Block](def_Block.svg){#fig-def-Block} +::: {#fig-def-blocks} -![Header](def_Header.svg){#fig-def-Header} +![](def_Block.svg) -![Paragraph](def_Paragraph.svg){#fig-def-Paragraph} +![](def_Header.svg) + +![](def_Paragraph.svg) + +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} -![StyledWords](def_StyledWords.svg){#fig-def-StyledWords} +![](def_StyledWords.svg) -![LinkedWords](def_LinkedWords.svg){#fig-def-LinkedWords} +![](def_LinkedWords.svg) -![AnnotatedWords](def_AnnotatedWords.svg){#fig-def-AnnotatedWords} +![](def_AnnotatedWords.svg) -![PlainWords](def_PlainWords.svg){#fig-def-PlainWords} +![](def_PlainWords.svg) + +Syntax of `StyledWords`, `LinkedWords`, `AnnotatedWords` and `PlainWords`. + +::: @@ -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. - -![AnnotatedWordsX](def_AnnotatedWordsX.svg){#fig-def-AnnotatedWordsX} +as in @fig-def-extensions. *FIXME: mention and draw extended LinkedWordsX as well.* +::: {#fig-def-extensions} + +![](def_AnnotatedWordsX.svg) + +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`* -![SemWords](def_SemWords.svg){#fig-def-SemWords} +::: {#fig-def-additions} + +![](def_SemWords.svg) + +![](def_SEMPREFIX.svg) + +Syntax of `SemWords`, `Curie`, `SEMPREFIX` and `NAME`. -![SEMPREFIX](def_SEMPREFIX.svg){#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 +# 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 +# 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 +# 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) -- cgit v1.2.3