5 ms·
The Jim Roskind C/C++ Grammar (2018)
- scudd 6y agoBig 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.
- mockery 6y agoI've always seen it called "justified" alignment, which appears to be the common term: https://en.wikipedia.org/wiki/Typographic_alignment#Justified https://en.wikipedia.org/wiki/Typographic_alignment#Justifie...
- deleted 6y ago[deleted]
- thgibbs 6y agoI 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 https://compilers.iecc.com/comparch/article/90-06-049 Very cool to see this history preserved.
- jimroskind 6y agoI'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
- jb1991 6y agoI 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.
- robertelder 6y agoAs 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?
- tom_mellior 6y agoAs 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?
- pjmlp 6y agoBetter tell ISO, NVidia, ARM, Intel, AMD, Microsoft, Apple, Google,... to fix their documentation as well.
- tom_mellior 6y agoI know you're just trolling, but I'll take a link to that ISO "C/C++" standard if you have it handy.
- jey 6y agoThis email it links to is a fun read about ambiguities in parsing C: https://pdos.csail.mit.edu/archive/l/c/roskind.html 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 */
- lou1306 6y agoThis 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?
- jimroskind 6y agoI 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
- lou1306 6y agoFirst 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.