From 39cbe60fd226c6fed26ab9a5f8e91b2fc09e13b7 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 15 Jul 2018 22:30:03 -0500 Subject: [PATCH] vocabs.platforms: Add sections that ignore code for the wrong platform. --- basis/vocabs/platforms/authors.txt | 1 + basis/vocabs/platforms/platforms.factor | 36 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 basis/vocabs/platforms/authors.txt create mode 100644 basis/vocabs/platforms/platforms.factor diff --git a/basis/vocabs/platforms/authors.txt b/basis/vocabs/platforms/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/vocabs/platforms/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/vocabs/platforms/platforms.factor b/basis/vocabs/platforms/platforms.factor new file mode 100644 index 0000000000..4cab775310 --- /dev/null +++ b/basis/vocabs/platforms/platforms.factor @@ -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: " parse-multiline-string + os unix? [ ".unix" parse-platform-section ] [ drop ] if ; + +SYNTAX: " parse-multiline-string + os macosx? [ ".macosx" parse-platform-section ] [ drop ] if ; + +SYNTAX: " parse-multiline-string + os linux? [ ".linux" parse-platform-section ] [ drop ] if ; + +SYNTAX: " parse-multiline-string + os windows? [ ".windows" parse-platform-section ] [ drop ] if ;