public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: Johnny Richard <johnny@johnnyrichard.com>
To: ~johnnyrichard/olang-devel@lists.sr.ht
Cc: Johnny Richard <johnny@johnnyrichard.com>,
	Ricardo Kagawa <ricardo.kagawa@gmail.com>
Subject: [PATCH olang v3] docs: create o programming language spec
Date: Sun, 24 Mar 2024 17:12:00 +0100	[thread overview]
Message-ID: <20240324161530.407168-2-johnny@johnnyrichard.com> (raw)

This document specifies the semantics and behavior of the O Programming
Language for compiler designers be informed on how the language is designed.

This document will help newcomers to understand how the language looks
like and also as a DRAFT guide to drive design discussions.

The grammar was made by using a EBNF evaluator tool[1].

[1]: The live example https://mdkrajnak.github.io/ebnftest/ and a locked
     version https://github.com/Engelberg/instaparse/tree/v1.4.12 as
     reference.

Signed-off-by: Johnny Richard <johnny@johnnyrichard.com>
Co-authored-by: Ricardo Kagawa <ricardo.kagawa@gmail.com>
---
V3: 
  - fix markdown reference link
  - add Pandoc metadata to fix page header
  - add spec link to layout header
  - fix page max-width to avoid EBNF of wrapping lines on big screens

 docs/pages/language-specification.md | 64 ++++++++++++++++++++++++++++
 docs/template.html                   |  3 +-
 2 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 docs/pages/language-specification.md

diff --git a/docs/pages/language-specification.md b/docs/pages/language-specification.md
new file mode 100644
index 0000000..5769d95
--- /dev/null
+++ b/docs/pages/language-specification.md
@@ -0,0 +1,64 @@
+% O programming language specification
+
+Abstract
+--------
+
+This document specifies the semantics and behavior of the O Programming
+Language for compiler designers be informed how the language is designed.
+
+This specification is a DRAFT and will be the discussions drive over olang-dev
+mailing list.
+
+Language Syntax
+---------------
+
+This is the O Programming Language EBNF grammar specification[^1]
+
+[^1]: EBNF variant https://github.com/Engelberg/instaparse/tree/v1.4.12 and live
+      test can be accessed here https://mdkrajnak.github.io/ebnftest/
+
+NOTE: This grammar spec is a DRAFT and it covers only a small portion of the
+language.
+
+```
+(* Entry Point *)
+<program>             ::= <ows> <function-definition> <ows> <end-of-file>
+
+(* Functions *)
+<function-definition> ::= 'fn' <ws> <function-name> <ows>
+<function-parameters> <ows> ':' <ows> <return-type> <ows> <function-body>
+<function-name>       ::= <identifier>
+<function-parameters> ::= '(' <ows> ')'
+<return-type>         ::= <type>
+<function-body>       ::= <block>
+
+(* Statements *)
+<block>               ::= '{' <ows> <statement> <ows> (<end-of-statement>
+<ows> <statement> <ows>)* <end-of-statement>? <ows> '}'
+<end-of-statement>    ::= ';' | <line-break>
+<statement>           ::= <return-statement>
+<return-statement>    ::= 'return' <ws> <expression>
+
+(* Expressions *)
+<expression>          ::= <integer>
+
+(* Identifiers *)
+<type>                ::= 'u32'
+<identifier>          ::= (<alpha> | '_') (<alpha> | <digit> | '_')*
+
+(* Literals *)
+<integer>             ::= <integer-base10> | <integer-base16>
+<integer-base10>      ::= #'[1-9]' (<digit> | '_')* | '0'
+<integer-base16>      ::= #'0[Xx]' <hex-digit> (<hex-digit> | '_')*
+
+(* Utilities *)
+<ws>                  ::= <white-space>+
+<ows>                 ::= <white-space>*
+<white-space>         ::= <linear-space> | <line-break>
+<line-break>          ::= #'[\n\v\f\r]' | '\r\n'
+<linear-space>        ::= #'[ \t]'
+<alpha>               ::= #'[a-zA-Z]'
+<digit>               ::= #'[0-9]'
+<hex-digit>           ::= <digit> | #'[a-fA-F]'
+<end-of-file>         ::= #'$'
+```
diff --git a/docs/template.html b/docs/template.html
index 4e066d1..52a22d1 100644
--- a/docs/template.html
+++ b/docs/template.html
@@ -30,7 +30,7 @@
       color: var(--link-color);
     }
     article, nav, header, footer {
-      max-width: 820px;
+      max-width: 1024px;
       margin: 10px auto;
     }
     header, footer {
@@ -56,6 +56,7 @@
     <nav>
       <a href="/">Index</a> |
       <a href="/pages/getting-started.html">Getting started (WIP)</a> |
+      <a href="/pages/language-specification.html">Specification</a> |
       <a href="/pages/hacking.html">Hacking</a> |
       <a href="https://sr.ht/~johnnyrichard/olang/sources" target="_blank">Sources ↗</a> |
       <a href="https://sr.ht/~johnnyrichard/olang/lists" target="_blank">Mailing list ↗</a>
-- 
2.44.0


             reply	other threads:[~2024-03-24 15:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 16:12 Johnny Richard [this message]
2024-03-24 15:16 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-03-24 15:56 ` [PATCH olang v3] docs: create o programming language spec Carlos Maniero
2024-03-24 17:43 ` Johnny Richard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240324161530.407168-2-johnny@johnnyrichard.com \
    --to=johnny@johnnyrichard.com \
    --cc=ricardo.kagawa@gmail.com \
    --cc=~johnnyrichard/olang-devel@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.johnnyrichard.com/olang.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox