From: Prasad Pandit <pjp@fedoraproject.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: "linux-kbuild@vger.kernel.org" <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH v1] kconfig: add config and source entry details
Date: Wed, 24 Apr 2024 05:25:55 +0000 (UTC) [thread overview]
Message-ID: <978513013.1900588.1713936355848@mail.yahoo.com> (raw)
In-Reply-To: <CAK7LNAShU0GS4e=wRupgwUDHhxMR5SVmkWn4mTZMU6r+Vng0Xg@mail.gmail.com>
Hi,
On Tuesday, 23 April, 2024 at 03:41:35 pm IST, Masahiro Yamada <masahiroy@kernel.org> wrote:
>EOL is a statement separator.
* Right. So are semi-colon (;), braces (}{) and colon (:) in case of C and Python.
===
$ cat t.c
#include <stdio.h>
int main (void)
{ printf("Hello, world!\n");$
$
$ cc -xc -o t t.c
t.c: In function ‘main’:
t.c:6:1: error: expected declaration or statement at end of input
6 | { printf("Hello, world!\n");
| ^
---
$ cat t.py
#!/usr/bin/python
if (x == 10)$
$
$ python t.py
File "/tmp/im/t.py", line 3
if (x == 10)
^
SyntaxError: expected ':'
===
* In above examples, files terminate without completing the statement and/or function definition (missing closing brace '}'), which is being treated as an error.
>Could you give me an example programming language
>that errors out when \n is missing at the end of the
>source file?
* It is not about '\n' at the end of file, but '\n' at the end of the Kconfig statement/record. Because Kconfig language uses EOL as a separator.
> I do not think requiring EOL at the end of file would help simplify the lexer/parser.
* It does, because on the parser side you don't have to define rule(s) with EOF to parse statements.
>When the lexer is encountered with EOF, it must
>tell the parser to finish the current statement
>and go back to the previous source file.
>So, EOF implies the end of the statement anyway.
* No, EOF does not imply end of a statement. The errors reported by gcc(1) and Python above clearly confirm that EOF is not end of statement.
* In their case colon(':') or brace ('}') are the required terminators, whereas in Kconfig's case EOL ('\n') is the required terminator.
* Because Kconfig language uses EOL ('\n') as statement separator/terminator, IMHO it should display an error when that condition is not met, because such statement remains incomplete.
Thank you.
---
-Prasad
next prev parent reply other threads:[~2024-04-24 5:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-07 7:29 [PATCH v1] kconfig: add config and source entry details Prasad Pandit
2024-04-16 6:50 ` Prasad Pandit
2024-04-16 11:48 ` Masahiro Yamada
2024-04-17 6:29 ` Prasad Pandit
2024-04-20 7:24 ` Masahiro Yamada
2024-04-23 6:16 ` Prasad Pandit
2024-04-23 10:10 ` Masahiro Yamada
2024-04-24 5:25 ` Prasad Pandit [this message]
2024-04-26 19:21 ` Masahiro Yamada
2024-04-30 7:36 ` Prasad Pandit
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=978513013.1900588.1713936355848@mail.yahoo.com \
--to=pjp@fedoraproject.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=pj.pandit@yahoo.in \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).