From cb92c8c4486f4d8ca5d9cba331cb432fead4fe02 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 6 Jun 2016 13:17:14 -0700 Subject: [PATCH] factor: allow SYNTAX: to have escaped names. --- core/parser/parser.factor | 16 +++++++++++----- core/syntax/syntax.factor | 2 +- libs/units/reduction/reduction.factor | 2 +- tools/help/syntax/syntax.factor | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/parser/parser.factor b/core/parser/parser.factor index 16bb6bde86..82812f9c67 100644 --- a/core/parser/parser.factor +++ b/core/parser/parser.factor @@ -108,12 +108,18 @@ ERROR: staging-violation word ; V{ } clone swap execute-parsing first ] when ; -: scan-parsing-word ( -- word ) +! Allows HELP: \ { ... ; and SYNTAX: \ { ... ; +: scan-escaped-word-string ( -- string ) ?scan-token dup "\\" = [ - drop scan-word - ] [ - parse-word - ] if ; + drop ?scan-token + ] when ; + +: scan-escaped-word ( -- word ) + scan-escaped-word-string parse-word ; + +: scan-new-escaped ( -- word ) + scan-escaped-word-string check-word-name + create-word-in dup reset-generic ; ERROR: classoid-expected object ; diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index e303a3ee4c..1e0f2054bf 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -159,7 +159,7 @@ in: bootstrap.syntax "@deprecated" [ last-word make-deprecated ] define-core-syntax "SYNTAX:" [ - scan-new-word + scan-new-escaped mark-top-level-syntax parse-definition define-syntax ] define-core-syntax diff --git a/libs/units/reduction/reduction.factor b/libs/units/reduction/reduction.factor index ef2c8d1d7f..c66b4d0a85 100644 --- a/libs/units/reduction/reduction.factor +++ b/libs/units/reduction/reduction.factor @@ -55,4 +55,4 @@ ERROR: bad-storage-string string reason ; : n>money ( n -- string ) 3 10 { "" "K" "M" "B" "T" } reduce-magnitude ; -SYNTAX: STORAGE: scan-token storage>n suffix! ; +SYNTAX: \ STORAGE: scan-token storage>n suffix! ; diff --git a/tools/help/syntax/syntax.factor b/tools/help/syntax/syntax.factor index 9db2960edc..7f53e6999a 100644 --- a/tools/help/syntax/syntax.factor +++ b/tools/help/syntax/syntax.factor @@ -5,7 +5,7 @@ help.topics kernel math parser sequences vocabs.parser words ; in: help.syntax SYNTAX: HELP: - scan-parsing-word bootstrap-word + scan-escaped-word bootstrap-word [ >link save-location ] [ [ \ ; parse-until >array ] dip set-word-help ] bi ;