public inbox for ~johnnyrichard/olang-devel@lists.sr.ht
 help / color / mirror / code / Atom feed
From: "Carlos Maniero" <carlos@maniero.me>
To: "Johnny Richard" <johnny@johnnyrichard.com>,
	<~johnnyrichard/olang-devel@lists.sr.ht>
Subject: Re: [RFC PATCH olang v1] docs: create zero programming language specification
Date: Sat, 09 Mar 2024 02:09:30 -0300	[thread overview]
Message-ID: <CZOYKP85KUIA.3RK1ED16RAFY7@maniero.me> (raw)
In-Reply-To: <20240309000855.1059007-1-johnny@johnnyrichard.com>

> This grammar adds the token SEMICOLON (';') for every statement.  I know we
> agreed make it optional, but the SEMICOLON makes the parser much more
> convenient to implement.
> 
> And this is the first topic I would like to discuss. Let me know if you
> agree otherwise I can adapt the grammar to make SEMICOLON optional.

I understand that using line feed (LF) as an end of statement (EOS)
marker can simplify the parsing process. However, at the top of my mind
I see two main downsides in using LF as EOS:

1. It could increase the number of tokens that the lexer produces,
   requiring the parser to ignore some of them.
2. It requires an strategy to skip LF for enable multi-line statements.

While the second point does add some complexity, I believe the first one
only slightly alters the implementation without significantly increasing
its complexity. Therefore, I'm curious about your statement that using a
semicolon makes the parser much more convenient to implement. Could you
elaborate on this? Have you encountered any new considerations that might
complicate the implementation?

> The grammar was made by using a EBNF evaluator tool[1].
> 
> [1]: https://mdkrajnak.github.io/ebnftest/

I would add this link at the markdown, so then people can play with it.

Furthermore, I was playing with the grammar you send and I did a few
adjusts:

- I introduced the <end-of-statement> to make SEMICOLON optional;
- It seams it has a pattern in where you used DASH or UNDERLINE but IMO
  it reads better when standardized.
- I made a simplification on <identifier>.
- I reordered the non-terminal keeping the single chars and strings at
  the bottom.

  <program>               ::= <function-definition>
  <function-definition>   ::= <fn-keyword> <space>+ <identifier>+ <space>* <fn-args> <space>* <colon> <space>+ <type> <space>* <block>
  <identifier>            ::= <alpha>+ <number>* <identifier>*
  <fn-args>               ::= '(' <space>* ')'
  <block>                 ::= <ocurly> <space>* <statement> <space>* <ccurly>
  <statement>             ::= <return-statement> <end-of-statement>+
  <return-statement>      ::= <return-keyword> <space>* <number>+ <space>*
  <end-of-statement>      ::= <semicolon>* <space>* '\n'
  <fn-keyword>            ::= 'fn'
  <return-keyword>        ::= 'return'
  <type>                  ::= 'u32'
  <alpha>                 ::= #'[a-zA-Z_]'
  <number>                ::= #'[0-9]'
  <space>                 ::= #'[ \t\r\n]'
  <semicolon>             ::= ';'
  <ocurly>                ::= '{'
  <ccurly>                ::= '}'
  <colon>                 ::= ':'

Other than that I would like to say thank you to always been looking
forward and helping us to improve our process.

  parent reply	other threads:[~2024-03-09  5:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-09  0:05 Johnny Richard
2024-03-08 23:09 ` [olang/patches/.build.yml] build success builds.sr.ht
2024-03-14  4:29   ` Ricardo Kagawa
2024-03-14 22:43     ` Johnny Richard
2024-03-09  0:36 ` [RFC PATCH olang v1] docs: create zero programming language specification Johnny Richard
2024-03-09  5:09 ` Carlos Maniero [this message]
2024-03-19 20:21 ` Johnny Richard
2024-03-23 23:31 ` Carlos Maniero
2024-03-15 20:54 Ricardo Kagawa
2024-03-17 15:41 ` Carlos Maniero
2024-03-18  9:58 ` 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=CZOYKP85KUIA.3RK1ED16RAFY7@maniero.me \
    --to=carlos@maniero.me \
    --cc=johnny@johnnyrichard.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