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 ;
8 : with-vocabulary ( quot suffix -- )
10 [ [ current-vocab name>> ] dip ?tail drop ]
11 [ append ] bi set-current-vocab
14 [ current-vocab name>> ] dip ?tail drop set-current-vocab
17 : parse-platform-section ( string suffix -- )
19 [ [ split-lines parse-lines ] curry with-nested-compilation-unit ]
21 ] dip with-vocabulary drop ; inline
24 "UNIX>" parse-multiline-string
25 os unix? [ ".unix" parse-platform-section ] [ drop ] if ;
28 "MACOSX>" parse-multiline-string
29 os macosx? [ ".macosx" parse-platform-section ] [ drop ] if ;
32 "LINUX>" parse-multiline-string
33 os linux? [ ".linux" parse-platform-section ] [ drop ] if ;
36 "WINDOWS>" parse-multiline-string
37 os windows? [ ".windows" parse-platform-section ] [ drop ] if ;
40 "!UNIX>" parse-multiline-string
41 os unix? [ drop ] [ ".unix" parse-platform-section ] if ;
44 "!MACOSX>" parse-multiline-string
45 os macosx? [ drop ] [ ".macosx" parse-platform-section ] if ;
48 "!LINUX>" parse-multiline-string
49 os linux? [ drop ] [ ".linux" parse-platform-section ] if ;
52 "!WINDOWS>" parse-multiline-string
53 os windows? [ drop ] [ ".windows" parse-platform-section ] if ;
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 ;
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 ;
72 SYNTAX: USE-IF: scan-token scan-object call( -- ? ) [ use-vocab ] [ drop ] if ;
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 ;
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( -- ) ;