lua-users home
lua-l archive

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




On Tue, Nov 2, 2021 at 6:36 PM eugeny gladkih <john@drweb.com> wrote:

> On 2 Nov 2021, at 16:29, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>
>> (To go off on a tangent: [...]
>
> As a somewhat similar example, but more common and still "problematic":
> In C, a+++++b could be correctly parsed as a++ + ++b, but it's not.
> Following the "longest" rule in the scanner, it's parsed as a++ ++ +b,
> which raises an error, as one cannot increment 'a++'.

no, it’s parsed as "a++ ++ +b”

> cat 1.cxx
int a=0, b=0;
int c = a+++++b;
> clang++ -std=c++17 1.cxx -c
1.cxx:2:12: error: _expression_ is not assignable
int c = a+++++b;
        ~~~^
1 error generated.
> cat 2.cxx
int a=0, b=0;
int c = a++ ++ +b;
> clang++ -std=c++17 2.cxx -c
2.cxx:2:13: error: _expression_ is not assignable
int c = a++ ++ +b;
        ~~~ ^
1 error generated.

apple clang V13

--
Yours sincerely, Eugeny.
+33 6 38 52 27 93

That's what he said. The first example would be a parse that wouldn't error, but the second example is how the parser actually does it.

/s/ Adam