]> gitweb.factorcode.org Git - factor.git/commitdiff
vocabs.platforms: Add <LINUX LINUX> sections that ignore code for the wrong platform.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 16 Jul 2018 03:30:03 +0000 (22:30 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 16 Jul 2018 03:30:45 +0000 (22:30 -0500)
basis/vocabs/platforms/authors.txt [new file with mode: 0644]
basis/vocabs/platforms/platforms.factor [new file with mode: 0644]

diff --git a/basis/vocabs/platforms/authors.txt b/basis/vocabs/platforms/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/vocabs/platforms/platforms.factor b/basis/vocabs/platforms/platforms.factor
new file mode 100644 (file)
index 0000000..4cab775
--- /dev/null
@@ -0,0 +1,36 @@
+! Copyright (C) 2018 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors compiler.units kernel multiline parser
+sequences splitting system vocabs.parser ;
+IN: vocabs.platforms
+
+: with-vocabulary ( quot suffix -- )
+    [
+        [ [ current-vocab name>> ] dip ?tail drop ]
+        [ append ] bi set-current-vocab
+        call
+    ] [
+        [ current-vocab name>> ] dip ?tail drop set-current-vocab
+    ] bi ; inline
+
+: parse-platform-section ( string suffix -- )
+    [
+        [ [ string-lines parse-lines ] curry with-nested-compilation-unit ]
+        curry
+    ] dip with-vocabulary drop ; inline
+
+SYNTAX: <UNIX
+    "UNIX>" parse-multiline-string
+    os unix? [ ".unix" parse-platform-section ] [ drop ] if ;
+
+SYNTAX: <MACOSX
+    "MACOSX>" parse-multiline-string
+    os macosx? [ ".macosx" parse-platform-section ] [ drop ] if ;
+
+SYNTAX: <LINUX
+    "LINUX>" parse-multiline-string
+    os linux? [ ".linux" parse-platform-section ] [ drop ] if ;
+
+SYNTAX: <WINDOWS
+    "WINDOWS>" parse-multiline-string
+    os windows? [ ".windows" parse-platform-section ] [ drop ] if ;