~subsetpark/pantagruel-web

5631886dee3f232b374843b9af501e3da9c019d9 — Zach Smith 1 year, 2 months ago 730d2e3
Update for v0.5.0
4 files changed, 57 insertions(+), 19 deletions(-)

M index.janet
M index.pant
M index.temple
M static/style.css
M index.janet => index.janet +7 -3
@@ 1,5 1,6 @@
(defn render-pantagruel
  [pant]

  (defn replace-unicode
    [line]
    (->> line


@@ 8,13 9,16 @@
         (string/replace-all "=>" "⇒")
         (string/replace-all "<=" "⇐")
         (string/replace-all "->" "→")
         (string/replace-all "---" "<hr>")
         (string/replace-all ";" "<hr><hr>")))
         (string/replace-all "---" `<hr class=chapter-separator>`)
         (string/replace-all ";" `<hr class=where>`)
         (string/replace-all "\t" "&emsp;")))

  (defn render-line
    [line]
    (if-not (string/has-prefix? "//" line)
      (string (replace-unicode line) "<br>")
      (let [replaced (replace-unicode line)
            line-end (if (string/has-suffix? ">" replaced) "" "<br>")]
        (string replaced line-end))
      (bagatto/markdown->html (string "> " (string/trim line "/")))))

  (as-> pant .

M index.pant => index.pant +39 -14
@@ 1,5 1,5 @@
Thought.
Specification <= [String].
Specification = [String].

// Pantagruel is a language for writing *system specifications*.



@@ 8,9 8,9 @@ pantagruel thoughts: [Thought] => Specification.

// It's a computer language, but not as you might think of it.

// The effects of evaluating a specification are *nil*---Pantagruel has no semantics.
// The effects of evaluating a specification are *nil*---Pantagruel has no execution semantics.

eval spec = Nil.
eval spec = null.

;



@@ 21,24 21,49 @@ check spec: Specification => Bool.
// However, Pantagruel specifications can be checked to ensure that certain conditions have been met.

// For instance, that you've defined all your terms by the end of your document.
check spec = all symbol: invoked_symbols spec =>
        symbol in (head spec) -> bound_as_of? symbol (first_appearance symbol)
        symbol in (body spec) -> bound_as_of? symbol (next_chapter (first_appearance symbol)).
(all s <: invoked_symbols spec =>
	first_invoked_in_head? s spec -> bound_as_of? s (first_appearance s spec)
	and
	first_invoked_in_body? s spec -> bound_as_of? s (next_chapter (first_appearance s spec))) -> check spec.

;

(Head, Body) <= [String].
Chapter <= [Head, Body].
Specification <= [Chapter].
(Head, Body) = [String].
Chapter = (Head, Body).
Specification = [Chapter].

// This allows a structured form of description where terms can be explained in gradually greater detail.

invoked_symbols <= {String}.
chapter head: Head, body: Body => Chapter.
first_appearance symbol: String => Nat.
bound_as_of? symbol: String, Nat => Bool.
first_invoked_in_head? symbol: String, spec: Specification => Bool.
first_invoked_in_body? symbol: String, spec: Specification => Bool.

//

invoked_symbols spec: Specification => {String}.
first_appearance symbol: String, spec: Specification => Nat.

//

bound_as_of? symbol: String, position: Nat => Bool.

next_chapter n: Nat => Nat.
---

invoked_symbols spec = {all s: String => s in spec}.
invoked_symbols spec =
	[all chapter <: spec, head_s <: (chapter 0) => head_s] +
	[all chapter <: spec, body_s <: (chapter 1) => body_s].

;

Expression.

// Specifications can also be type-checked to ensure that your logic is consistent.
type_checks? expr: Expression => Bool.
---

(all expr <: expressions spec => type_checks? expr) -> check spec.

;

expressions spec: Specification => [Expression].
---

M index.temple => index.temple +4 -1
@@ 36,12 36,15 @@
  <a href="https://github.com/subsetpark/pantagruel">Pantagruel on GitHub</a>
  </p>
  <p>
  <a href="https://github.com/subsetpark/pantagruel/blob/master/priv/reference.md">Pantagruel Language Reference</a>
  </p>
  <p>
  <a href="https://blog.zdsmith.com/posts/a-specification-of-a-note-taking-program.html">A Specification of a Note-Taking Program</a>
  </p>
</div>

<div class="footer">
        <div class="narrow">Z. D. Smith, 2021.</div>
        <div class="narrow">Z. D. Smith, 2022.</div>
        <div class="column">&nbsp;</div>
        <div class="narrow">Built with <a href="https://bagatto.co">Bagatto</a>.</div>
</div>

M static/style.css => static/style.css +7 -1
@@ 96,5 96,11 @@ h2 {
  }
}

.where {
	border: 1px solid black;
	margin: 4em;
}


.chapter-separator {
	border: 1px dashed black;
}