From aba01b80e7ea75438db7933f9430997bc853250f Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 26 May 2025 10:05:06 +0200 Subject: add syntax SemWord --- _markdown.qmd | 4 +++- _syntax.qmd | 2 ++ syntax/def.peg | 3 ++- syntax/def_SemWord.py | 22 ++++++++++++++++++++++ syntax/def_SemWords.py | 14 +++++--------- 5 files changed, 34 insertions(+), 11 deletions(-) create mode 100755 syntax/def_SemWord.py diff --git a/_markdown.qmd b/_markdown.qmd index 12a2180..d1aa5dd 100644 --- a/_markdown.qmd +++ b/_markdown.qmd @@ -246,9 +246,11 @@ See @fig-def-additions for their syntax diagrams. ![](syntax/def_SemWords.svg) +![](syntax/def_SemWord.svg) + ![](syntax/def_SEMPREFIX.svg) -Syntax of `SemWords`, `Curie`, `SEMPREFIX`. +Syntax of `SemWords`, `SemWord`, `Curie`, `SEMPREFIX`. ::: diff --git a/_syntax.qmd b/_syntax.qmd index e7b9d56..d8af814 100644 --- a/_syntax.qmd +++ b/_syntax.qmd @@ -32,6 +32,8 @@ regular expressions and the negative predicate from PEG notation. ![PlainWords](syntax/def_PlainWords.svg) +![SemWord](syntax/def_SemWord.svg) + ![Url](syntax/def_Uri.svg) ![HardBreak](syntax/def_HardBreak.svg) diff --git a/syntax/def.peg b/syntax/def.peg index 30157d2..11ce1ab 100644 --- a/syntax/def.peg +++ b/syntax/def.peg @@ -51,7 +51,8 @@ NEWLINE <- '\r\n' # @see AnnotatedWordsX <- '[' Words ']' ('{' (SemWords / ![{}] PlainWords) '}') -SemWords <- SEMPREFIX '<' ![<>] PRINTABLES '>' +SemWords <- SemWord (_ SemWord)* +SemWord <- SEMPREFIX '<' ![<>] PRINTABLES '>' / SEMPREFIX Curie SEMPREFIX <- [.=] diff --git a/syntax/def_SemWord.py b/syntax/def_SemWord.py new file mode 100755 index 0000000..d0768ad --- /dev/null +++ b/syntax/def_SemWord.py @@ -0,0 +1,22 @@ +#!/usr/bin/python3 + +# Copyright 2025, Jonas Smedegaard +# SPDX-License-Identifier: GPL-3+ + +from railroad import * + +Diagram( + Choice(0, + Sequence( + NonTerminal("SEMPREFIX"), + "<", + NonTerminal("![<>] PRINTABLES"), + ">", + ), + Sequence( + NonTerminal("SEMPREFIX"), + NonTerminal("CURIE"), + ) + ), + type="complex" +).writeStandalone(sys.stdout.write) diff --git a/syntax/def_SemWords.py b/syntax/def_SemWords.py index d0768ad..2a2af8f 100755 --- a/syntax/def_SemWords.py +++ b/syntax/def_SemWords.py @@ -6,17 +6,13 @@ from railroad import * Diagram( + NonTerminal("SemWord"), Choice(0, - Sequence( - NonTerminal("SEMPREFIX"), - "<", - NonTerminal("![<>] PRINTABLES"), - ">", + OneOrMore( + NonTerminal("_"), + NonTerminal("SemWord") ), - Sequence( - NonTerminal("SEMPREFIX"), - NonTerminal("CURIE"), - ) + Skip() ), type="complex" ).writeStandalone(sys.stdout.write) -- cgit v1.2.3