/[cparse]/cparse/README
ViewVC logotype

Contents of /cparse/README

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Mon Mar 18 08:04:59 2002 UTC (12 years, 1 month ago) by clynbech
Branch: CPARSE
CVS Tags: CPARSE_0_2_4
Changes since 1.1: +0 -0 lines
Import of CPARSE upstream version 0.2.4
1 cparse is a Common Lisp package for parsing the subset of ANSI C that is
2 likely to be in header files. It understands variable and function
3 declarations arrays, structures, enums, and constant expressions. It
4 also includes cmu-alien.lisp, which uses cparse to construct foreign
5 function definitions for CMUCL's alien facility.
6
7 CPARSE
8
9 cparse goes to some effort to simulate C integer arithmetic for a
10 given host and compiler implementation; while it implements floating
11 point arithmetic too, it just uses Lisp floats for that.
12
13 cparse:cparse-stream is the main entry point for cparse; it parses a
14 stream of raw C i.e., C that has already been run through the C
15 preprocessor. It doesn't grok any preprocessor directives but it does
16 understand the line directives output by cpp for error reporting. It
17 returns a big list of lists of type and variable names, and a scope
18 structure that contains everything that was defined in the top-level
19 lexical environment.
20
21 cparse-stream also supports another interface: it takes a :stmt-fun
22 argument, a function that gets called for every statement parsed by
23 cparse. cmu-alien uses this interface.
24
25
26 CMU-ALIEN
27
28 cmu-alien is an example of using cparse. Its entry point,
29 make-alien-defs, produces a form that uses CMUCL's alien facility to
30 make a definition for everything found in the header files. This form
31 could, for example, be returned from a macroexpansion or dumped into a
32 file for manual editing.
33
34
35 INSTALLATION
36
37 I use defsystem from clocc (http://clocc.sourceforge.net).
38 (mk:oos "cparse" :compile) does the trick.
39
40 It should be easy to build and install by hand if you don't want to
41 use defsystem.
42
43 I've only tested cparse and cmu-alien in CMU Common Lisp, but the
44 cparse parts (everything other than cmu-alien.lisp) should be portable
45 to other Lisps.
46
47
48 LIMITATIONS AND FUTURE WORK
49
50 Plenty, I'm sure.
51
52 Bitfields aren't implemented.
53
54 gcc's __attribute__ isn't supported. I use the
55 :extra-cpp-lines argument to make-alien-defs to work around the
56 __attribute__ problem. Sort of.
57
58 The C arithmetic in ctype.lisp has high aspirations, but probably has
59 many bugs in its handling of overflow.
60
61 CMUCL's alien facility doesn't understand stdargs yet, so functions
62 that declare stdargs are silently ignored.
63
64 Interfaces to Objective C and C++ would be nice. The former is a lot
65 easier than the latter.
66
67
68 REPORTING BUGS
69
70 Send bugs to moore@bricoworks.com. It's most helpful if you can send
71 C files that have been preprocessed.

  ViewVC Help
Powered by ViewVC 1.1.5