]> gitweb.factorcode.org Git - factor.git/blob - basis/vocabs/platforms/platforms.factor
4f91ab1c72c4ec4114707d73f2ef9bb9a20c699e
[factor.git] / basis / vocabs / platforms / platforms.factor
1 ! Copyright (C) 2018 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors compiler.units kernel lexer multiline parser
4 sequences splitting system vocabs.parser ;
5 IN: vocabs.platforms
6
7 : with-vocabulary ( quot suffix -- )
8     [
9         [ [ current-vocab name>> ] dip ?tail drop ]
10         [ append ] bi set-current-vocab
11         call
12     ] [
13         [ current-vocab name>> ] dip ?tail drop set-current-vocab
14     ] bi ; inline
15
16 : parse-platform-section ( string suffix -- )
17     [
18         [ [ split-lines parse-lines ] curry with-nested-compilation-unit ]
19         curry
20     ] dip with-vocabulary drop ; inline
21
22 SYNTAX: <UNIX
23     "UNIX>" parse-multiline-string
24     os unix? [ ".unix" parse-platform-section ] [ drop ] if ;
25
26 SYNTAX: <MACOSX
27     "MACOSX>" parse-multiline-string
28     os macosx? [ ".macosx" parse-platform-section ] [ drop ] if ;
29
30 SYNTAX: <LINUX
31     "LINUX>" parse-multiline-string
32     os linux? [ ".linux" parse-platform-section ] [ drop ] if ;
33
34 SYNTAX: <WINDOWS
35     "WINDOWS>" parse-multiline-string
36     os windows? [ ".windows" parse-platform-section ] [ drop ] if ;
37
38 SYNTAX: <!UNIX
39     "!UNIX>" parse-multiline-string
40     os unix? [ drop ] [ ".unix" parse-platform-section ] if ;
41
42 SYNTAX: <!MACOSX
43     "!MACOSX>" parse-multiline-string
44     os macosx? [ drop ] [ ".macosx" parse-platform-section ] if ;
45
46 SYNTAX: <!LINUX
47     "!LINUX>" parse-multiline-string
48     os linux? [ drop ] [ ".linux" parse-platform-section ] if ;
49
50 SYNTAX: <!WINDOWS
51     "!WINDOWS>" parse-multiline-string
52     os windows? [ drop ] [ ".windows" parse-platform-section ] if ;
53
54 SYNTAX: USE-UNIX: scan-token os unix? [ use-vocab ] [ drop ] if ;
55 SYNTAX: USE-FREEBSD: scan-token os freebsd? [ use-vocab ] [ drop ] if ;
56 SYNTAX: USE-LINUX: scan-token os linux? [ use-vocab ] [ drop ] if ;
57 SYNTAX: USE-MACOSX: scan-token os macosx? [ use-vocab ] [ drop ] if ;
58 SYNTAX: USE-WINDOWS: scan-token os windows? [ use-vocab ] [ drop ] if ;
59
60 SYNTAX: USE-X86-32: scan-token os x86.32? [ use-vocab ] [ drop ] if ;
61 SYNTAX: USE-X86-64: scan-token os x86.64? [ use-vocab ] [ drop ] if ;
62 SYNTAX: USE-ARM-32: scan-token os arm.32? [ use-vocab ] [ drop ] if ;
63 SYNTAX: USE-ARM-64: scan-token os arm.64? [ use-vocab ] [ drop ] if ;
64
65 SYNTAX: USE-IF: scan-token scan-object call( -- ? ) [ use-vocab ] [ drop ] if ;