Re: [PATCH v1] kconfig: add config and source entry details

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tuesday, 23 April, 2024 at 03:41:35 pm IST, Masahiro Yamada <masahiroy@xxxxxxxxxx> 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





[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux