/[cparse]/cparse/README
ViewVC logotype

Contents of /cparse/README

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri May 14 21:17:59 2004 UTC (9 years, 11 months ago) by clynbech
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +10 -3 lines
<doc>
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 three usages of cparse to construct foreign
5 function definitions for different alien facilities:
6 - cmu-alien.lisp FFI for CMUCL
7 - acl-alien.lisp FFI for Allegro CL
8 - uffi-alien.lisp FFI for the portable UFFI library
9 All three are included for historical completeness. The CMUCL solution
10 was what cparse was originally written to handle. The ACL solution was
11 later written by Christian Lynbech. Both are no longer supported, all
12 effort will be used on the UFFI solution.
13
14 CPARSE
15
16 cparse goes to some effort to simulate C integer arithmetic for a
17 given host and compiler implementation; while it implements floating
18 point arithmetic too, it just uses Lisp floats for that.
19
20 cparse:cparse-stream is the main entry point for cparse; it parses a
21 stream of raw C i.e., C that has already been run through the C
22 preprocessor. It doesn't grok any preprocessor directives but it does
23 understand the line directives output by cpp for error reporting. It
24 returns a big list of lists of type and variable names, and a scope
25 structure that contains everything that was defined in the top-level
26 lexical environment.
27
28 cparse-stream also supports another interface: it takes a :stmt-fun
29 argument, a function that gets called for every statement parsed by
30 cparse. cmu-alien uses this interface.
31
32
33 CMU-ALIEN
34
35 cmu-alien is an example of using cparse. Its entry point,
36 make-alien-defs, produces a form that uses CMUCL's alien facility to
37 make a definition for everything found in the header files. This form
38 could, for example, be returned from a macroexpansion or dumped into a
39 file for manual editing.
40
41
42 INSTALLATION
43
44 I use defsystem from clocc (http://clocc.sourceforge.net).
45 (mk:oos "cparse" :compile) does the trick.
46
47 It should be easy to build and install by hand if you don't want to
48 use defsystem.
49
50 I've only tested cparse and cmu-alien in CMU Common Lisp, but the
51 cparse parts (everything other than cmu-alien.lisp) should be portable
52 to other Lisps.
53
54
55 LIMITATIONS AND FUTURE WORK
56
57 Plenty, I'm sure.
58
59 Bitfields aren't implemented.
60
61 gcc's __attribute__ isn't supported. I use the
62 :extra-cpp-lines argument to make-alien-defs to work around the
63 __attribute__ problem. Sort of.
64
65 The C arithmetic in ctype.lisp has high aspirations, but probably has
66 many bugs in its handling of overflow.
67
68 CMUCL's alien facility doesn't understand stdargs yet, so functions
69 that declare stdargs are silently ignored.
70
71 Interfaces to Objective C and C++ would be nice. The former is a lot
72 easier than the latter.
73
74
75 REPORTING BUGS
76
77 Send bugs to cparse-devel@common-lisp.net. It's most helpful if you can send
78 C files that have been preprocessed.

  ViewVC Help
Powered by ViewVC 1.1.5