]> gitweb.factorcode.org Git - factor.git/blob - basis/vocabs/platforms/platforms.factor
factor: more top level forms.
[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 arrays compiler.units kernel lexer multiline
4 namespaces parser sequences sets splitting system vocabs
5 vocabs.loader.private vocabs.parser ;
6 IN: vocabs.platforms
7
8 : with-vocabulary ( quot suffix -- )
9     [
10         [ [ current-vocab name>> ] dip ?tail drop ]
11         [ append ] bi set-current-vocab
12         call
13     ] [
14         [ current-vocab name>> ] dip ?tail drop set-current-vocab
15     ] bi ; inline
16
17 : parse-platform-section ( string suffix -- )
18     [
19         [ [ split-lines parse-lines ] curry with-nested-compilation-unit ]
20         curry
21     ] dip with-vocabulary drop ; inline
22
23 SYNTAX: <UNIX
24     "UNIX>" parse-multiline-string
25     os unix? [ ".unix" parse-platform-section ] [ drop ] if ;
26
27 SYNTAX: <MACOSX
28     "MACOSX>" parse-multiline-string
29     os macosx? [ ".macosx" parse-platform-section ] [ drop ] if ;
30
31 SYNTAX: <LINUX
32     "LINUX>" parse-multiline-string
33     os linux? [ ".linux" parse-platform-section ] [ drop ] if ;
34
35 SYNTAX: <WINDOWS
36     "WINDOWS>" parse-multiline-string
37     os windows? [ ".windows" parse-platform-section ] [ drop ] if ;
38
39 SYNTAX: <!UNIX
40     "!UNIX>" parse-multiline-string
41     os unix? [ drop ] [ ".unix" parse-platform-section ] if ;
42
43 SYNTAX: <!MACOSX
44     "!MACOSX>" parse-multiline-string
45     os macosx? [ drop ] [ ".macosx" parse-platform-section ] if ;
46
47 SYNTAX: <!LINUX
48     "!LINUX>" parse-multiline-string
49     os linux? [ drop ] [ ".linux" parse-platform-section ] if ;
50
51 SYNTAX: <!WINDOWS
52     "!WINDOWS>" parse-multiline-string
53     os windows? [ drop ] [ ".windows" parse-platform-section ] if ;
54
55 SYNTAX: USE-UNIX: scan-token os unix? [ use-vocab ] [ drop ] if ;
56 SYNTAX: USE-FREEBSD: scan-token os freebsd? [ use-vocab ] [ drop ] if ;
57 SYNTAX: USE-LINUX: scan-token os linux? [ use-vocab ] [ drop ] if ;
58 SYNTAX: USE-MACOSX: scan-token os macosx? [ use-vocab ] [ drop ] if ;
59 SYNTAX: USE-WINDOWS: scan-token os windows? [ use-vocab ] [ drop ] if ;
60 SYNTAX: USE-OS-SUFFIX: scan-token os name>> "." glue require ;
61
62 SYNTAX: USE-X86: scan-token cpu x86? [ use-vocab ] [ drop ] if ;
63 SYNTAX: USE-X86-32: scan-token cpu x86.32? [ use-vocab ] [ drop ] if ;
64 SYNTAX: USE-X86-64: scan-token cpu x86.64? [ use-vocab ] [ drop ] if ;
65 SYNTAX: USE-ARM: scan-token cpu arm? [ use-vocab ] [ drop ] if ;
66 SYNTAX: USE-ARM-32: scan-token cpu arm.32? [ use-vocab ] [ drop ] if ;
67 SYNTAX: USE-ARM-64: scan-token cpu arm.64? [ use-vocab ] [ drop ] if ;
68 SYNTAX: USE-PPC: scan-token cpu ppc? [ use-vocab ] [ drop ] if ;
69 SYNTAX: USE-PPC-32: scan-token cpu ppc.32? [ use-vocab ] [ drop ] if ;
70 SYNTAX: USE-PPC-64: scan-token cpu ppc.64? [ use-vocab ] [ drop ] if ;
71
72 SYNTAX: USE-IF: scan-token scan-object call( -- ? ) [ use-vocab ] [ drop ] if ;
73
74 SYNTAX: WHEN-UNIX: scan-object os unix? [ call( -- ) ] [ drop ] if ;
75 SYNTAX: WHEN-FREEBSD: scan-object os freebsd? [ call( -- ) ] [ drop ] if ;
76 SYNTAX: WHEN-LINUX: scan-object os linux? [ call( -- ) ] [ drop ] if ;
77 SYNTAX: WHEN-MACOSX: scan-object os macosx? [ call( -- ) ] [ drop ] if ;
78 SYNTAX: WHEN-WINDOWS: scan-object os windows? [ call( -- ) ] [ drop ] if ;
79
80 SYNTAX: IF-UNIX: scan-object scan-object os unix? -rot ? call( -- ) ;
81 SYNTAX: IF-FREEBSD: scan-object scan-object os freebsd? -rot ? call( -- ) ;
82 SYNTAX: IF-LINUX: scan-object scan-object os linux? -rot ? call( -- ) ;
83 SYNTAX: IF-MACOSX: scan-object scan-object os macosx? -rot ? call( -- ) ;
84 SYNTAX: IF-WINDOWS: scan-object scan-object os windows? -rot ? call( -- ) ;