]> gitweb.factorcode.org Git - factor.git/blob - basis/vocabs/platforms/platforms.factor
4cab77531041b411b848d607df9c4a1335170cc3
[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 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         [ [ string-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 ;