hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.39k stars 232 forks source link

Digit separator doesn't parse with opening brace #881

Closed ntrel closed 8 months ago

ntrel commented 8 months ago

Fixes #862.

ntrel commented 8 months ago

Note that keeping Cpp1 apostrophe as digit separator caused this parsing complication. Personally I think underscore reads much nicer (and is used in many other languages) and wouldn't need special tracking here.

JohelEGP commented 8 months ago

The last point of https://github.com/hsutter/cppfront/issues/289#issuecomment-1480594843 also addresses a comment about using something other than ' as a digit separator.

gregmarr commented 8 months ago

@ntrel It's possible that underscore would conflict with user defined literals.

JohelEGP commented 8 months ago

Not really. 0_0 separates. 0_d UDLs.

gregmarr commented 8 months ago

This is a valid UDL. https://www.godbolt.org/z/sn8r9a3zv https://www.godbolt.org/z/PvnK3jvMj

double operator ""_0(const char* args);

SebastianTroy commented 8 months ago

Now that there is no comma operator, could comma be used instead?

On 8 December 2023 16:55:28 gregmarr @.***> wrote:

@ntrelhttps://github.com/ntrel It's possible that underscore would conflict with user defined literals.

— Reply to this email directly, view it on GitHubhttps://github.com/hsutter/cppfront/pull/881#issuecomment-1847521542, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AALUZQNDERFHIXPFZDDJCOTYINA75AVCNFSM6AAAAABAMZ5ODSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGUZDCNJUGI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

JohelEGP commented 8 months ago

No. For ambiguities, see https://www.reddit.com/r/cpp/comments/18canwt/small_rant_the_comma_operator_is_one_of_the_worst/. One example is f(1,2). Is that 12, or 1 and 2?

SebastianTroy commented 8 months ago

Oof, yeah how could I have missed such a blatant ambiguity...

On 8 December 2023 17:42:28 Johel Ernesto Guerrero Peña @.***> wrote:

No. For ambiguities, see https://www.reddit.com/r/cpp/comments/18canwt/small_rant_the_comma_operator_is_one_of_the_worst/. One example is f(1,2). Is that 12, or 1 and 2?

— Reply to this email directly, view it on GitHubhttps://github.com/hsutter/cppfront/pull/881#issuecomment-1847579696, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AALUZQKCACPZWDHGEOGQ2BLYINGQFAVCNFSM6AAAAABAMZ5ODSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGU3TSNRZGY. You are receiving this because you commented.Message ID: @.***>

JohelEGP commented 8 months ago

862 was fixed by commit fb820ebf8d3130498d3b3de4881987ae08722855.

hsutter commented 8 months ago

Thanks for this! I appreciate the PR, but I ended up fixing it a different way (using a shortcut to try not to duplicate as much of numeric literal parsing during brace matching, but if we discover problems with that we can look at this PR again). Again, thanks very much.