2008-03-20 21:11:45 -04:00
|
|
|
! Copyright (C) 2005, 2008 Slava Pestov, Alex Chapman.
|
2007-09-20 18:09:08 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2008-07-01 17:33:45 -04:00
|
|
|
USING: accessors arrays alien alien.c-types alien.structs
|
|
|
|
alien.arrays alien.strings kernel math namespaces parser
|
|
|
|
sequences words quotations math.parser splitting grouping
|
|
|
|
effects prettyprint prettyprint.sections prettyprint.backend
|
2008-11-30 18:47:29 -05:00
|
|
|
assocs combinators lexer strings.parser alien.parser ;
|
2007-09-20 18:09:08 -04:00
|
|
|
IN: alien.syntax
|
|
|
|
|
2008-03-18 19:02:24 -04:00
|
|
|
: DLL" lexer get skip-blank parse-string dlopen parsed ; parsing
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: ALIEN: scan string>number <alien> parsed ; parsing
|
|
|
|
|
2008-07-01 17:33:45 -04:00
|
|
|
: BAD-ALIEN <bad-alien> parsed ; parsing
|
|
|
|
|
2007-09-20 18:09:08 -04:00
|
|
|
: LIBRARY: scan "c-library" set ; parsing
|
|
|
|
|
|
|
|
: FUNCTION:
|
|
|
|
scan "c-library" get scan ";" parse-tokens
|
2008-04-26 00:12:44 -04:00
|
|
|
[ "()" subseq? not ] filter
|
2007-09-20 18:09:08 -04:00
|
|
|
define-function ; parsing
|
|
|
|
|
|
|
|
: TYPEDEF:
|
|
|
|
scan scan typedef ; parsing
|
|
|
|
|
|
|
|
: C-STRUCT:
|
2008-12-02 01:24:00 -05:00
|
|
|
scan in get parse-definition define-struct ; parsing
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: C-UNION:
|
2008-12-02 01:24:00 -05:00
|
|
|
scan parse-definition define-union ; parsing
|
2007-09-20 18:09:08 -04:00
|
|
|
|
|
|
|
: C-ENUM:
|
|
|
|
";" parse-tokens
|
|
|
|
dup length
|
2008-11-29 14:37:38 -05:00
|
|
|
[ [ create-in ] dip 1quotation define ] 2each ;
|
2007-09-20 18:09:08 -04:00
|
|
|
parsing
|
|
|
|
|
|
|
|
M: alien pprint*
|
2007-11-07 19:26:39 -05:00
|
|
|
{
|
2008-07-01 17:33:45 -04:00
|
|
|
{ [ dup expired? ] [ drop \ BAD-ALIEN pprint-word ] }
|
2007-11-07 19:26:39 -05:00
|
|
|
{ [ dup pinned-c-ptr? not ] [ drop "( displaced alien )" text ] }
|
2008-04-11 13:53:22 -04:00
|
|
|
[ \ ALIEN: [ alien-address pprint* ] pprint-prefix ]
|
2007-11-07 19:26:39 -05:00
|
|
|
} cond ;
|
2007-09-20 18:09:08 -04:00
|
|
|
|
2007-12-03 19:19:18 -05:00
|
|
|
M: dll pprint* dll-path dup "DLL\" " "\"" pprint-string ;
|