head     1.1;
branch   1.1.1;
access   ;
symbols  start:1.1.1.1 project:1.1.1;
locks    ; strict;
comment  @# @;


1.1
date     2009.07.09.02.51.48;  author yo2dh;  state Exp;
branches 1.1.1.1;
next     ;

1.1.1.1
date     2009.07.09.02.51.48;  author yo2dh;  state Exp;
branches ;
next     ;


desc
@@



1.1
log
@Initial revision
@
text
@This directory consists of a collection of files implementing a C parser in
SML/NJ version 110

To compile. Go into sml (using sml-cm) and invoke the compilation manager
with:

CM.make ();

Note that the 10 reduce/reduce conflicts in the grammar are correctly
resolved by ml-yacc.  The result will leave a top-level declaration
called parse which takes as an argument a string representing a
filename and returns a list of abstract syntax tree declarations
(AST.program) and a source map (a mapping from file offsets to
line/column positions). The data type of the abstract syntax tree is
fleshed out in ast-sig.sml and ast.sml.

Preprocessing Code
------------------

The parser assumes that the input has been preprocessed.  The easiest
way to extract the preprocessed files is to modifying your makefiles
to produce preprocessed output on the fly.  Here is a rule for
compiling C files that will also generate preprocessed code:

.c.o:
	$(CC) $(CFLAGS) -c -E $*.c > $*.i
	$(CC) $(CFLAGS) -c $*.i

For each .c file, this rule will produce a .i file containing the
preprocessed code.

The parser also assumes that there are no #line declarations in the
input, which is not true for the ``raw'' preprocessed code.
Preprocessing also inserts many blank lines.  The following perl
script removes both of these things.

#!/usr/sww/bin/perl

foreach $file (@@ARGV) {
    print "Processing $file\n";
    rename ($file,"$file.save");
    open (OUTFILE, ">$file") || die "Can't open $file";
    open (INFILE, "<$file.save") || die "Can't open $file.save";
    
    while (<INFILE>) {
	print OUTFILE unless /^\#/ or /^$/ or /^[ 	]*$/;
    }
    close (OUTFILE);
    close (INFILE);
}

Note that the regular expression [ 	] contains a space followed by
a tab.  For some reason [ \t] doesn't work reliably.

Changes made to the original version obtained by Detlef Sodtke and
Jens Krinke
------------------------------------------------------------------

The parser has been extensively modified from the original version.
Below is a list of the major changes.

Feb 98  Added two cases in gen.grm to handle the case where we typedef
        a struct name and then use it again in struct <name>. Parser
        got confused by this, e.g. typedef struct IO_FILE IO_FILE,
        then later struct IO_FILE.  Added unparser.

	manuel@@cs

3/12/98	Fixed declaration parsing. Typedef's and declarators weren't
	dealt with correctly. Required keeping correct mappings of
	names to identifiers or typedef names.
	
	Also added sequences of string constants and old-style
	function definition (not well tested).

	manuel@@cs

Apr 98  Added persistent symbol table; parser now provides type
	information for identifiers and scopes.  Struct names
	are also handled.  Required spliiting off lexemes
	from the AST.

	Added extra symbol table and scope information (useful
	for alpha-conversion and tagging identifiers).

	jfoster@@cs


Bugs
----

Send comments and bugs to bane-software@@cs.berkeley.edu.


Copyright
---------

Copyright (c) 1997,1998 The Regents of the University of California.
All rights reserved.

Permission to use, copy, modify, and distribute this software for any
purpose, without fee, and without written agreement is hereby granted,
provided that the above copyright notice and the following two
paragraphs appear in all copies of this software.

IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.


@


1.1.1.1
log
@CVS TEST
@
text
@@
