]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/syntax/syntax.factor
Update unicode.categories.syntax
[factor.git] / basis / alien / syntax / syntax.factor
1 ! Copyright (C) 2005, 2009 Slava Pestov, Alex Chapman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays alien alien.c-types alien.structs
4 alien.arrays alien.strings kernel math namespaces parser
5 sequences words quotations math.parser splitting grouping
6 effects assocs combinators lexer strings.parser alien.parser 
7 fry vocabs.parser words.constant ;
8 IN: alien.syntax
9
10 SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
11
12 SYNTAX: ALIEN: scan string>number <alien> parsed ;
13
14 SYNTAX: BAD-ALIEN <bad-alien> parsed ;
15
16 SYNTAX: LIBRARY: scan "c-library" set ;
17
18 SYNTAX: FUNCTION:
19     scan "c-library" get scan ";" parse-tokens
20     [ "()" subseq? not ] filter
21     define-function ;
22
23 SYNTAX: TYPEDEF:
24     scan scan typedef ;
25
26 SYNTAX: C-STRUCT:
27     scan in get parse-definition define-struct ;
28
29 SYNTAX: C-UNION:
30     scan parse-definition define-union ;
31
32 SYNTAX: C-ENUM:
33     ";" parse-tokens
34     [ [ create-in ] dip define-constant ] each-index ;
35
36 : address-of ( name library -- value )
37     load-library dlsym [ "No such symbol" throw ] unless* ;
38
39 SYNTAX: &:
40     scan "c-library" get '[ _ _ address-of ] over push-all ;