factor/basis/alien/syntax/syntax.factor

44 lines
1.2 KiB
Factor
Raw Normal View History

2009-01-16 18:44:29 -05:00
! Copyright (C) 2005, 2009 Slava Pestov, Alex Chapman.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
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 assocs combinators lexer strings.parser alien.parser
2009-03-26 00:00:19 -04:00
fry vocabs.parser words.constant alien.libraries ;
2007-09-20 18:09:08 -04:00
IN: alien.syntax
SYNTAX: DLL" lexer get skip-blank parse-string dlopen parsed ;
2007-09-20 18:09:08 -04:00
SYNTAX: ALIEN: 16 scan-base <alien> parsed ;
2007-09-20 18:09:08 -04:00
SYNTAX: BAD-ALIEN <bad-alien> parsed ;
SYNTAX: LIBRARY: scan "c-library" set ;
2007-09-20 18:09:08 -04:00
SYNTAX: FUNCTION:
(FUNCTION:) define-declared ;
2007-09-20 18:09:08 -04:00
SYNTAX: TYPEDEF:
2009-09-15 16:18:54 -04:00
scan-c-type CREATE typedef ;
2007-09-20 18:09:08 -04:00
SYNTAX: C-STRUCT:
scan current-vocab parse-definition define-struct ; deprecated
2007-09-20 18:09:08 -04:00
SYNTAX: C-UNION:
scan parse-definition define-union ; deprecated
2007-09-20 18:09:08 -04:00
SYNTAX: C-ENUM:
2007-09-20 18:09:08 -04:00
";" parse-tokens
2009-01-16 18:44:29 -05:00
[ [ create-in ] dip define-constant ] each-index ;
2009-09-15 16:18:54 -04:00
SYNTAX: C-TYPE:
"Primitive C type definition not supported" throw ;
ERROR: no-such-symbol name library ;
: address-of ( name library -- value )
2dup load-library dlsym [ 2nip ] [ no-such-symbol ] if* ;
SYNTAX: &:
scan "c-library" get '[ _ _ address-of ] over push-all ;