2 Internals
This section describes the internals of Rince as a reference for developers. The interfaces here may change at any time. Do not use these in external code.
2.1 Parenthetical C
The parser transforms C syntax into the S-expressions described here.
syntax
(declare maybe-storage-class base-type decl ...)
maybe-storage-class =
| #:extern | #:static | #:auto | #:register decl = declarator | declarator = initializer
C |
| Racket |
extern int x, y = 1; |
| (declare #:extern int x y = 1) |
int * const p; |
| (declare int (const (ptr p))) |
int (*f)(int); |
| |
struct { int x; } s; |
| (declare (struct ([int x])) s) |
struct foo { int x; }; |
| (declare (struct foo ([int x]))) |
struct foo; |
| (declare (struct foo)) |
int f(void); |
|
syntax
(function ret-type args)
(function maybe-storage-class ret-type id args body)
args = (arg ...) | (arg ... ...) arg = [type] | [base-type declarator]
The second form defines a function.
As in C, an unspecified argument list is (), and an empty argument list is ([void]). Unspecified trailing arguments are represented by ... at the end of the list.
The first form defines a (possibly anonymous) struct type.
The second form refers to a previously defined struct type, or (as the base type in a declaration) declares a new struct tag.