]> gitweb.factorcode.org Git - factor.git/blob - basis/alien/syntax/syntax.factor
Delete empty unit tests files, remove 1- and 1+, reorder IN: lines in a lot of places...
[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 alien.libraries ;
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     (FUNCTION:) define-declared ;
20
21 SYNTAX: TYPEDEF:
22     scan scan typedef ;
23
24 SYNTAX: C-STRUCT:
25     scan current-vocab parse-definition define-struct ;
26
27 SYNTAX: C-UNION:
28     scan parse-definition define-union ;
29
30 SYNTAX: C-ENUM:
31     ";" parse-tokens
32     [ [ create-in ] dip define-constant ] each-index ;
33
34 ERROR: no-such-symbol name library ;
35
36 : address-of ( name library -- value )
37     2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ;
38
39 SYNTAX: &:
40     scan "c-library" get '[ _ _ address-of ] over push-all ;