From: Joe Marshall
Subject: Parsing C or C++
Date: 
Message-ID: <ad38lfkr.fsf@ccs.neu.edu>
I have made a modified version Ed Willink's C++ parser that emits
s-expressions.  A preprocessed C or C++ file can be read on stdin and
a fully parenthesised syntactic parse (lisp readable) is emitted on
stdout.  An AST may be created by processing the syntactic parse.

This is alpha code and may undergo several changes, but if you're
interested, drop me a line.

Example:

void wxMediaEdit::SetBetweenThreshold(float t)
{
  if (t > 99.0)
    t = 99.0;
  betweenThreshold = t;
}

is parsed as:

(declaration-list
 (expression/function-definition
  (expression/call
   (typed-name token/void
	       (expression/name
		(nested-id
		 (nested-scope "wxMediaEdit")
		 "SetBetweenThreshold")))
   (parenthesised
    (parameter-list
     (expression/parameter
      (typed-name token/float
		  (expression/name "t"))))
    '()
    '()))
  (function-block
   (compound-statement
    (statement-list
     (statement/if
      (condition
       (parameter-list
	(expression/parameter
	 (greater-than
	  (expression/name "t")
	  (expression/integer-literal "99.0")))))
      (declaration-statement
       (simple-declaration
	(expression/assignment =
			       (expression/name "t")
			       (expression/integer-literal "99.0"))))
      '())
     (declaration-statement
      (simple-declaration
       (expression/assignment =
			      (expression/name "betweenThreshold")
			      (expression/name "t")))))))))
From: Michael Walter
Subject: Re: Parsing C or C++
Date: 
Message-ID: <c1fqsa$1hfikg$1@ID-88904.news.uni-berlin.de>
Joe Marshall wrote:
> I have made a modified version Ed Willink's C++ parser that emits
> s-expressions.  A preprocessed C or C++ file can be read on stdin and
> a fully parenthesised syntactic parse (lisp readable) is emitted on
> stdout.  An AST may be created by processing the syntactic parse.
> 
> This is alpha code and may undergo several changes, but if you're
> interested, drop me a line.
That's cute :) Is the code available for download somewhere?

Cheers,
Michael