2005-06-12 03:38:57 -04:00
|
|
|
! Copyright (C) 2005 Alex Chapman.
|
2006-01-10 23:56:00 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2005-12-13 17:33:58 -05:00
|
|
|
IN: !syntax
|
|
|
|
USING: alien compiler kernel lists math namespaces parser
|
|
|
|
sequences syntax words ;
|
2005-06-12 03:38:57 -04:00
|
|
|
|
2006-01-19 23:28:45 -05:00
|
|
|
: DLL" skip-blank parse-string dlopen swons ; parsing
|
|
|
|
|
|
|
|
: ALIEN: scan-word <alien> swons ; parsing
|
|
|
|
|
2005-06-12 03:38:57 -04:00
|
|
|
: LIBRARY: scan "c-library" set ; parsing
|
|
|
|
|
|
|
|
: FUNCTION:
|
|
|
|
scan "c-library" get scan string-mode on
|
|
|
|
[ string-mode off define-c-word ] [ ] ; parsing
|
|
|
|
|
2006-03-26 21:08:02 -05:00
|
|
|
: TYPEDEF: scan scan typedef ; parsing
|
2005-06-12 03:38:57 -04:00
|
|
|
|
2005-08-24 10:19:09 -04:00
|
|
|
: BEGIN-STRUCT: ( -- offset )
|
|
|
|
scan "struct-name" set 0 ; parsing
|
|
|
|
|
|
|
|
: FIELD: ( offset -- offset )
|
|
|
|
scan scan define-field ; parsing
|
|
|
|
|
|
|
|
: END-STRUCT ( length -- )
|
|
|
|
define-struct-type ; parsing
|
|
|
|
|
2006-03-26 21:08:02 -05:00
|
|
|
: C-UNION:
|
2006-03-26 19:47:51 -05:00
|
|
|
scan "struct-name" set
|
|
|
|
string-mode on [
|
|
|
|
string-mode off
|
|
|
|
0 [ define-member ] reduce define-struct-type
|
|
|
|
] [ ] ; parsing
|
|
|
|
|
|
|
|
: C-ENUM:
|
|
|
|
string-mode on [
|
|
|
|
string-mode off 0 [
|
|
|
|
create-in swap [ unit define-compound ] keep 1+
|
|
|
|
] reduce drop
|
|
|
|
] [ ] ; parsing
|