public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: Johnny Richard <johnny@johnnyrichard.com>
To: Carlos Maniero <carlos@maniero.me>
Cc: ~johnnyrichard/olang-devel@lists.sr.ht
Subject: Re: [PATCH olang v1 1/2] docs: spec: rename program to translation-unit
Date: Wed, 27 Mar 2024 22:20:02 +0100	[thread overview]
Message-ID: <34zmjbgj3m6wbmwccjp3prnf3l76jwbpdati5hi3xep35cka2c@lhcwkygn5jfl> (raw)
In-Reply-To: <20240327032128.406911-2-carlos@maniero.me>

On Wed, Mar 27, 2024 at 12:21:27AM -0300, Carlos Maniero wrote:
> We started to rename the program node in AST to translation-unit. This

Nitpick:  Perhaps we can highlight the problem and solution better?

    Today, the AST node "program" serves as the main entry point for the
    grammar, potentially leading to confusion as the program ultimately
    becomes the final ELF binary after linking all .o files. Therefore, we
    have collectively decided to replace it with "translation-unit," which
    more accurately conveys the concept of a singular unit being translated
    into a single binary. This adjustment enables us to assert that a
    translation-unit corresponds directly to the .ol source file on a
    one-to-one basis.

> commit also makes a few refactors on spec such as:
> 
> - Makes EOF a end-of-statement

This patch does the opposite.  Make a end-of-statement a EOF as well,
which I not agree.  See following comments...

> - create global-statements section to accommodate upcoming global
>   definitions.
> 
> Signed-off-by: Carlos Maniero <carlos@maniero.me>
> ---
>  docs/pages/language-specification.md | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/docs/pages/language-specification.md b/docs/pages/language-specification.md
> index 5769d95..4541ba8 100644
> --- a/docs/pages/language-specification.md
> +++ b/docs/pages/language-specification.md
> @@ -22,7 +22,9 @@ language.
>  
>  ```
>  (* Entry Point *)
> -<program>             ::= <ows> <function-definition> <ows> <end-of-file>
> +<translation-unit>    ::= <ows> (<global-statements> <end-of-statement>)*

This change expect that every followed new statement has no optional
white space. According to your change the following expression is invalid:

    |fn add(): u32 {
    |  return 0;
    |}
    |
     ^~~ this is a line-break (syntax error according to your grammar)
    | fn main(): u32 {
     ^~~ this is a linear-space (syntax error according to your grammar)
    |  return 0;
    |}


suggestion: This change fixes the problem.

    <translation-unit>    ::= (<ows> <global-statements> <ows> (<end-of-statement> | <end-of-file>))*

> +
> +<global-statements>   ::= <function-definition>

This doesn't need to be plural if it has a single "statement".

>  
>  (* Functions *)
>  <function-definition> ::= 'fn' <ws> <function-name> <ows>
> @@ -35,7 +37,7 @@ language.
>  (* Statements *)
>  <block>               ::= '{' <ows> <statement> <ows> (<end-of-statement>
>  <ows> <statement> <ows>)* <end-of-statement>? <ows> '}'
> -<end-of-statement>    ::= ';' | <line-break>
> +<end-of-statement>    ::= ';' | <line-break> | <end-of-file>

Hmmm... this is not true, this means the every end-of-statement can be a
end-of-file.

  reply	other threads:[~2024-03-27 20:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-27  3:21 [PATCH olang v1 0/2] docs: variables specification Carlos Maniero
2024-03-27  3:21 ` [PATCH olang v1 1/2] docs: spec: rename program to translation-unit Carlos Maniero
2024-03-27 21:20   ` Johnny Richard [this message]
2024-03-28 13:50     ` Carlos Maniero
2024-03-27  3:21 ` [PATCH olang v1 2/2] docs: spec: add variables and constants specification Carlos Maniero
2024-03-27  3:22   ` [olang/patches/.build.yml] build failed builds.sr.ht
2024-03-27 21:37   ` [PATCH olang v1 2/2] docs: spec: add variables and constants specification Johnny Richard
2024-03-28 14:11     ` Carlos Maniero
2024-04-01 17:48       ` Johnny Richard
2024-03-30  1:14     ` Carlos Maniero
2024-04-01 17:54       ` Johnny Richard
2024-04-11 22:39     ` [PATCH] fixup! " ricardo_kagawa
2024-04-12 22:36       ` Johnny Richard
2024-04-13  2:18         ` Carlos Maniero
2024-04-16 19:01         ` 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=34zmjbgj3m6wbmwccjp3prnf3l76jwbpdati5hi3xep35cka2c@lhcwkygn5jfl \
    --to=johnny@johnnyrichard.com \
    --cc=carlos@maniero.me \
    --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