From 6c3632d43e0fe678c533124631f94a571d3788c3 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 23 Jun 2016 22:46:12 -0700 Subject: [PATCH] factor: support -- in { } V{ } H{ } and $doc{ } --- core/kernel/kernel-docs.factor | 10 +++++----- core/splitting/splitting.factor | 5 ++++- core/syntax/syntax.factor | 10 +++++----- tools/help/syntax/syntax.factor | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/core/kernel/kernel-docs.factor b/core/kernel/kernel-docs.factor index a9edc913bf..2486ee1ea6 100644 --- a/core/kernel/kernel-docs.factor +++ b/core/kernel/kernel-docs.factor @@ -12,7 +12,7 @@ HELP: WIN-EXCEPTION-HANDLER $description{ "This special object is an " $link{ alien } " containing a pointer to the processes global exception handler. Only applicable on " $link{ windows } "." } ; HELP: eq? -$values{ { "obj1" object } { "obj2" object } { "?" boolean } } +$values{ "obj1" object -- "obj2" object -- "?" boolean } $description{ "Tests if two references point at the same object." } ; HELP: drop $shuffle ; @@ -76,7 +76,7 @@ HELP: leaf-signal-handler $description{ "A word called by the VM when a VM error occurs." } ; HELP: hashcode* -$values{ { "depth" integer } { "obj" object } { "code" fixnum } } +$values{ "depth" integer -- "obj" object -- "code" fixnum } $contract{ "Outputs the hashcode of an object. The hashcode operation must satisfy the following properties:" $list{ { "If two objects are equal under " $link{ = } ", they must have equal hashcodes." } @@ -97,7 +97,7 @@ $description{ "Outputs the identity hashcode of an object. The identity hashcode { hashcode hashcode* identity-hashcode } related-words HELP: = -$values{ { "obj1" object } { "obj2" object } { "?" boolean } } +$values{ "obj1" object -- "obj2" object -- "?" boolean } $description{ "Tests if two objects are equal. If " $snippet{ "obj1" } " and " $snippet{ "obj2" } " point to the same object, outputs " $link{ t } ". Otherwise, calls the " $link{ equal? } " generic word." } @@ -141,11 +141,11 @@ $examples{ } ; HELP: clone -$values{ { "obj" object } { "cloned" "a new object" } } +$values{ "obj" object -- "cloned" "a new object" } $contract{ "Outputs a new object equal to the given object. This is not guaranteed to actually copy the object; it does nothing with immutable objects, and does not copy words either. However, sequences and tuples can be cloned to obtain a shallow copy of the original." } ; HELP: ? -$values{ { "?" "a generalized boolean" } { "true" object } { "false" object } { "true/false" { $snippet{ "true" } " or " $snippet{ "false" } } } } +$values{ "?" "a generalized boolean" -- "true" object -- "false" object -- "true/false" { $snippet{ "true" } " or " $snippet{ "false" } } } $description{ "Chooses between two values depending on the boolean value of " $snippet{ "cond" } "." } ; HELP: boolean diff --git a/core/splitting/splitting.factor b/core/splitting/splitting.factor index f5b8fa222e..9cb1d87c07 100644 --- a/core/splitting/splitting.factor +++ b/core/splitting/splitting.factor @@ -99,7 +99,10 @@ PRIVATE> [ member? ] curry split-when ; inline : ?split ( seq separators -- pieces/seq ) - split dup length 1 = [ first ] when ; inline + split dup length 1 = [ first ] [ [ >array ] map ] if ; inline + +: split-dashes ( seq -- seq/seq' ) + { -- } ?split ; inline : split-slice ( seq separators -- pieces ) [ member? ] curry split-when-slice ; inline diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 8892b9c27e..f60696a5e4 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -56,7 +56,7 @@ IN: bootstrap.syntax { "]" "}" ";" ">>" "COMPILE>" } [ define-delimiter ] each "--" [ - "--" define-symbol + "--" "syntax" lookup-word suffix! ] define-core-syntax { "_" "@" } define-fry-specifiers @@ -181,14 +181,14 @@ IN: bootstrap.syntax ] define-core-syntax "[" [ parse-quotation suffix! ] define-core-syntax - "{" [ \ } [ >array ] parse-literal ] define-core-syntax - "V{" [ \ } [ >vector ] parse-literal ] define-core-syntax + "{" [ \ } [ split-dashes >array ] parse-literal ] define-core-syntax + "V{" [ \ } [ split-dashes >vector ] parse-literal ] define-core-syntax "B{" [ \ } [ >byte-array ] parse-literal ] define-core-syntax "BV{" [ \ } [ >byte-vector ] parse-literal ] define-core-syntax - "H{" [ \ } [ parse-hashtable ] parse-literal ] define-core-syntax + "H{" [ \ } [ split-dashes parse-hashtable ] parse-literal ] define-core-syntax "T{" [ parse-tuple-literal suffix! ] define-core-syntax "W{" [ \ } [ first ] parse-literal ] define-core-syntax - "HS{" [ \ } [ >hash-set ] parse-literal ] define-core-syntax + "HS{" [ \ } [ split-dashes >hash-set ] parse-literal ] define-core-syntax "postpone\\" [ scan-word suffix! ] define-core-syntax "\\" [ scan-word suffix! ] define-core-syntax diff --git a/tools/help/syntax/syntax.factor b/tools/help/syntax/syntax.factor index 34a969b19b..c086bac8f9 100644 --- a/tools/help/syntax/syntax.factor +++ b/tools/help/syntax/syntax.factor @@ -27,7 +27,7 @@ SYNTAX: \ ABOUT: COMPILE< SYNTAX: \ HELP-SYNTAX: scan-new-escaped scan-word ";" expect - '[ \ } parse-until >array _ prefix suffix! ] define-syntax ; + '[ \ } parse-until split-dashes >array _ prefix suffix! ] define-syntax ; COMPILE> HELP-SYNTAX: \ $breadcrumbs{ $breadcrumbs ;