C Grammer - From unix-sources-request Wed Mar 4 01:44:50...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 From unix-sources-request Wed Mar 4 01:44:50 1987 Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85 Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85 Path: prandtl!unix-sources-request From: unix-sources-request@BRL.ARPA Newsgroups: nas.list.sources Subject: ANSI C draft yacc grammar Message-ID: <17067@prandtl.ARPA> Date: 4 Mar 87 09:44:50 GMT Date-Received: 4 Mar 87 09:44:50 GMT Sender: daemon@prandtl.ARPA Organization: NASA Ames-NAS, Moffet Field, CA Lines: 777 From: Tom Stockfisch People keep asking me for a copy, so I am reposting a yacc grammar (actually, a complete program) for the April 1985 draft of the ANSI C standard. It finds syntax errors in its input. Oh yeah, this was originally posted by Jeff Lee. || Tom Stockfisch, UCSD Chemistry tps%chem@sdcsvax.UCSD #!/bin/sh # to extract, remove the header and type "sh filename" if `test ! -s ./Makefile` then echo "writting ./Makefile" cat > ./Makefile << '\Rogue\Monster\' YFLAGS = -dv CFLAGS = -O LFLAGS = SRC = gram.y scan.l main.c OBJ = gram.o scan.o main.o $(BIN)/ansi_c : $(OBJ) cc $(CFLAGS) $(OBJ)/ansi_c scan.o : y.tab.h clean : rm -f y.tab.h y.output *.o \Rogue\Monster\ else echo "will not over write ./Makefile" fi if `test ! -s ./README` then echo "writting ./README"
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sheet1 Page 2 cat > ./README << '\Rogue\Monster\' The files in this directory contain the ANSI C grammar from the April 30, 1985 draft of the proposed standard. This copy also incorporates all bug fixes I have seen since the last two postings. With a little work this grammar can be made to parse the C that most of us know and love (sort of). There is one bug fix to the grammar that is in this posting. On line 295 of gram.y it previously read declaration_specifiers instead of type_specifier_list as it does now. I believe the folks at the ANSI committee made a mistake since if you replace the line with what the original read you will end up with 16 shift/reduce errors and 2 reduce/reduce errors (the good ones). As it is, it only has 1 shift/reduce error that occurs on the if/else construct. YACC creates the correct parser and I don't want to ugly my grammar up. Anyway, all cumquats unite and generate this sucker. Then just sit and play with it. Remember, the grammar accepts things like Hello, world++ 1.23 *'a' but this is not a bug, but simply a shuffling of the checking into the semantic analysis. If you want to hack it up to do lvalue and rvalue checking, I'm sure the ANSI committee would be glad to have your changes. Don't send'em to me though. I don't want'em. Wear this in good health. Jeff Lee gatech!jeff jeff@gatech jeff%gatech.CSNet@CSNet-Relay.ARPA \Rogue\Monster\ else echo "will not over write ./README" fi if `test ! -s ./gram.y` then echo "writting ./gram.y" cat > ./gram.y << '\Rogue\Monster\' %token IDENTIFIER CONSTANT STRING_LITERAL SIZEOF %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP %token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN %token XOR_ASSIGN OR_ASSIGN TYPE_NAME
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 64

C Grammer - From unix-sources-request Wed Mar 4 01:44:50...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online