News for hackers. Stuff that matters.
Re:The Jim Roskind C/C++ Grammar (2018) by jimroskind on Friday October 09, 2020 @06:50PM (#24735210)
I'm Jim Roskind, the author of the grammars.

It is an honor to see my grammars still being discussed.

These days I work at Amazon, but I can be found on LinkedIn. If contacted with a comment about the grammars (as opposed to a spam missive from a head hunter), I'll typically respond.

What I really need to (finally) do someday is publish my hacks that I added to byacc to increase usability (I think I called it jryacc).

I've always felt that yacc's "error reports" are kindred to having a compiler error listing limited to:

"you have 7 severe errors, 3 errors, and 23 warnings,"

and a reference:

  "to understand the issues, please read the machine code."
:-)

With yacc, verbose output suggests (at best) that you read the "state transition diagrams" <ugh> to make sense of "n shift reduce, and m reduce-reduce conflicts."

jryacc provided the shortest sequence of terminals to reach any state, identifies any non-terminal that is both left and right recursive (a common malady in grammar construction, which ensures ambiguity), the shortest sequence of terminals to construct each non-terminal, etc.

...oh... and not to fear... I have copies of the grammars and files mentioned... so hopefully they won't be too lost too soon.

Thanks again for the interesting comments.

Jim

Re:The Jim Roskind C/C++ Grammar (2018) by jey on Friday October 09, 2020 @10:43AM (#24730350)
This email it links to is a fun read about ambiguities in parsing C: https://pdos.csail.mit.edu/archive/l/c/roskind.html

    # Getting back to your example, since you copied the grammar from the ANSI
    # Standard, your grammar is probably wrong.  To expose the problem, try
    # parsing:
    #
    #         typedef int A, B(A); /* my bet is you get a syntax error*/
    #
    # When correctly parsed, the above is equivalent to:
    #
    #         typedef int A;
    #         typedef int B(A);
    #
    # or simply:
    #
    #         typedef int A;
    #         typedef int B(int); /* B's type is function taking an int
    #                 returning and int */
Re:The Jim Roskind C/C++ Grammar (2018) by thgibbs on Friday October 09, 2020 @01:18PM (#24732141)
I did my PhD work in the late 90s/early 2000s on a C++ parser. In my PhD thesis, I give credit to Roskind for the "lex hack" and cite his 1989 grammar. We reference this posting, basically: https://compilers.iecc.com/comparch/article/90-06-049 Very cool to see this history preserved.
Re:The Jim Roskind C/C++ Grammar (2018) by lou1306 on Friday October 09, 2020 @11:31AM (#24730835)
This stuff seems pretty famous and worthy of being preserved, so why is that someone like @historicalcode on GitHub hasn't put it into a repository yet? Some licensing issues?
Re:The Jim Roskind C/C++ Grammar (2018) by jimroskind on Sunday October 11, 2020 @11:28AM (#24746434)
I doubt there are licensing issues (or at least that is how I TRIED to write the license I included)... but if there are, please contact me on LinkedIn. Are you suggesting I should just put it all on Github as a publicly readable repo? I could probably do so.

Thanks,

Jim

Re:The Jim Roskind C/C++ Grammar (2018) by lou1306 on Monday October 12, 2020 @11:29AM (#24755408)
First of all, I have to say that your work on the C/C++ grammars is amazing.

My comment was mostly a reaction to this section of the blog post:

> I could only find a single mirror where I could download [the archives c++grammar1.1.tar.Z and c++grammar2.0.tar.Z].

If you happen to have the spare time to set up a public repo (GitHub or whatever), I think it would be great. It would surely help with long-term availability of the files, and people would have a somehow "canonical" link they can reference when they want to cite your work.

Re:The Jim Roskind C/C++ Grammar (2018) by scudd on Friday October 09, 2020 @12:43PM (#24731711)
Big aside from the actual content, but is there a name for the formatting in the text files like `freegrm4.txt`? Each line has a number of distributed extra spaces so that every line ends with the ending of a word. It makes it really pleasant to read, kind of like a newspaper.
Re:The Jim Roskind C/C++ Grammar (2018) by mockery on Friday October 09, 2020 @12:51PM (#24731814)
I've always seen it called "justified" alignment, which appears to be the common term: https://en.wikipedia.org/wiki/Typographic_alignment#Justifie...
Re:The Jim Roskind C/C++ Grammar (2018) by scudd on Friday October 09, 2020 @01:01PM (#24731933)
Thanks!
Re:The Jim Roskind C/C++ Grammar (2018) by ksherlock on Friday October 09, 2020 @06:06PM (#24734899)
fmt, par, and nroff are common unix utilities that can justify text (in order of complexity). I've been told that fmt was the disk formatter on at least one oddball unix. Or maybe it's just an urban legend to keep people from running unknown commands as root.
Re:The Jim Roskind C/C++ Grammar (2018) by jb1991 on Friday October 09, 2020 @10:39AM (#24730317)
I love this. I often come back, time and time again, to just re-read this when I have nothing else to do and just want to relax. It’s a very inspiring and educational read, I cannot get enough of it.
Re:The Jim Roskind C/C++ Grammar (2018) by robertelder on Friday October 09, 2020 @10:46AM (#24730379)
As the author of this blog post, I find this statement interesting. Can you expand upon the sentiments expressed in your statement? Also, by 'read this', do you mean just the blog post, or contents of the works by Jim Roskind?
Re:The Jim Roskind C/C++ Grammar (2018) by tom_mellior on Friday October 09, 2020 @11:00AM (#24730512)
As the author of the blog post, would you be willing to change its title to "The Jim Roskind C and C++ Grammars"? The text makes it very clear that you know that C and C++ are separate languages, and that the archives actually contain separate grammar files for these separate languages. As they should.

From past experience I find "C/C++" a very grating term. Back when I was reading comp.lang.c, "C/C++" was used in questions by particular brands of people, who tried to compile C++ with a C compiler, or compile C with a C++ compiler, or use C++ features in what they thought was C, or in general were confused about the fact that there is no single language called "C/C++", but rather two separate, incompatible languages called "C" and "C++". Anyway, wouldn't it be good to not add to the (potential) confusion?

Re:The Jim Roskind C/C++ Grammar (2018) by robertelder on Friday October 09, 2020 @11:15AM (#24730665)
hah, because you care so much, I'll go ahead and make that change. It's probably better for SEO anyway. I made the change on my local copy. It will get pushed next time I re-build the site.
Re:The Jim Roskind C/C++ Grammar (2018) by tom_mellior on Friday October 09, 2020 @12:56PM (#24731873)
Awesome, thanks!
Re:The Jim Roskind C/C++ Grammar (2018) by choeger on Friday October 09, 2020 @04:46PM (#24734274)
The languages are related but quite different. The eco system and ABI are rather similar, though.
Re:The Jim Roskind C/C++ Grammar (2018) by pjmlp on Friday October 09, 2020 @01:18PM (#24732138)
Better tell ISO, NVidia, ARM, Intel, AMD, Microsoft, Apple, Google,... to fix their documentation as well.
Re:The Jim Roskind C/C++ Grammar (2018) by tom_mellior on Friday October 09, 2020 @07:08PM (#24735341)
I know you're just trolling, but I'll take a link to that ISO "C/C++" standard if you have it handy.
Re:The Jim Roskind C/C++ Grammar (2018) by pjmlp on Saturday October 10, 2020 @11:53AM (#24739751)
Not trolling at all, just fed up with "I know better", C/C++ is an abbreviation for C and C++, a very basic English grammar rule.

You want a link? Here are several,

https://www.arm.com/products/development-tools/server-and-hp...

https://software.intel.com/content/www/us/en/develop/videos/...

https://docs.microsoft.com/en-us/cpp/cpp/c-cpp-language-and-...

https://www.ibm.com/products/xl-cpp-aix-compiler-power

https://developer.amd.com/amd-aocc/

Ah, from ISO as well, no problem, can I start with one paper from Bjarne?

https://isocpp.org/blog/2020/06/thriving-in-a-crowded-and-ch...

> In addition to these groups, there is a semi-official C/C++ liaison group consisting of people who are members of both the C++ committee and the C committee....

I can provide you more papers from the same author, maybe you feel like educating Bjarne Stroustrup on how to write it.