From 8c9bb02fe3c958d657857117825a83548cdfe2f0 Mon Sep 17 00:00:00 2001 From: Alex Maestas Date: Tue, 8 Nov 2022 04:19:57 +0000 Subject: [PATCH] add extra:syntax.terse, for bitwise ops. Addresses #2641. --- extra/syntax/terse/authors.txt | 1 + extra/syntax/terse/terse.factor | 10 ++++++++++ misc/fuel/factor-mode.el | 2 +- misc/fuel/strange-syntax.factor | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 extra/syntax/terse/authors.txt create mode 100644 extra/syntax/terse/terse.factor diff --git a/extra/syntax/terse/authors.txt b/extra/syntax/terse/authors.txt new file mode 100644 index 0000000000..d514ff4aab --- /dev/null +++ b/extra/syntax/terse/authors.txt @@ -0,0 +1 @@ +Alex Maestas diff --git a/extra/syntax/terse/terse.factor b/extra/syntax/terse/terse.factor new file mode 100644 index 0000000000..66ac59faeb --- /dev/null +++ b/extra/syntax/terse/terse.factor @@ -0,0 +1,10 @@ +USING: math words ; +IN: syntax.terse + +! shorthand/C-like bitwise ops +ALIAS: `& bitand +ALIAS: `| bitor +ALIAS: `^ bitxor +ALIAS: `~ bitnot +ALIAS: `<< shift +: `>> ( x n -- x/2^n ) neg shift ; inline diff --git a/misc/fuel/factor-mode.el b/misc/fuel/factor-mode.el index c2d64ff2f5..a1533a378f 100644 --- a/misc/fuel/factor-mode.el +++ b/misc/fuel/factor-mode.el @@ -178,7 +178,7 @@ these lines in your .emacs: ;;; Regexps galore: ;; Utility regexp used by other regexps to match a Factor symbol name -(setq-local symbol-nc "\\(?:\\sw\\|\\s_\\|\"\\|\\s(\\|\\s)\\|\\s\\\\)+") +(setq-local symbol-nc "\\(?:\\sw\\|\\s_\\|`\\|\"\\|\\s(\\|\\s)\\|\\s\\\\)+") (setq-local symbol (format "\\(%s\\)" symbol-nc)) (setq-local c-symbol-nc "\\(?:\\sw\\|\\s_\\|\\[\\|\\]\\)+") (setq-local c-symbol (format "\\(%s\\)" c-symbol-nc)) diff --git a/misc/fuel/strange-syntax.factor b/misc/fuel/strange-syntax.factor index 538265bbef..ee05308e74 100644 --- a/misc/fuel/strange-syntax.factor +++ b/misc/fuel/strange-syntax.factor @@ -101,3 +101,6 @@ COLOR: #ffffff COLOR: green NAN: 1234 CHAR: m ALIEN: 93 PRIMITIVE: one ( a -- b ) PRIMITIVE: two ( c -- d ) + +: `word ( -- ) ; +: word ( -- ) ; ! this isn't strange, just for contrast with the above -- 2.34.1