summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorgy Komarov <jubnzv@gmail.com>2021-10-03 17:09:56 +0300
committerDavid Peter <sharkdp@users.noreply.github.com>2021-10-03 19:17:26 +0200
commitd04a83de7b9ed1ed8ff23f505b08212fea6086a3 (patch)
tree6d640c977e34cab3d164befc435fa754a25c1504
parentb622a4d8907a7f8fa05d8eeca22219eab6ce7c4e (diff)
Add Racket syntax
-rw-r--r--.gitmodules3
-rw-r--r--CHANGELOG.md1
m---------assets/syntaxes/02_Extra/Racket0
-rw-r--r--assets/syntaxes/02_Extra/Racket.sublime-syntax52
-rw-r--r--tests/syntax-tests/highlighted/Racket/test.rkt56
-rw-r--r--tests/syntax-tests/source/Racket/test.rkt56
6 files changed, 168 insertions, 0 deletions
diff --git a/.gitmodules b/.gitmodules
index 5f28570c..2426d305 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -230,3 +230,6 @@
[submodule "assets/syntaxes/02_Extra/Slim"]
path = assets/syntaxes/02_Extra/Slim
url = https://github.com/slim-template/ruby-slim.tmbundle.git
+[submodule "assets/syntaxes/02_Extra/Racket"]
+ path = assets/syntaxes/02_Extra/Racket
+ url = https://github.com/follesoe/sublime-racket.git
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e699099..364ad0d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,7 @@
- Highlight for `vimrc` and `gvimrc` files, see #1763 (@SuperSandro2000)
- Syslog highlighting improvements, see #1793 (@scop)
- Added support for `slim` syntax, see #1693 (@mfinelli)
+- Racket, see #1884 (@jubnzv)
## New themes
diff --git a/assets/syntaxes/02_Extra/Racket b/assets/syntaxes/02_Extra/Racket
new file mode 160000
+Subproject 7df4479c079768edd994b20052761152e277af2
diff --git a/assets/syntaxes/02_Extra/Racket.sublime-syntax b/assets/syntaxes/02_Extra/Racket.sublime-syntax
new file mode 100644
index 00000000..82e2b852
--- /dev/null
+++ b/assets/syntaxes/02_Extra/Racket.sublime-syntax
@@ -0,0 +1,52 @@
+%YAML 1.2
+---
+# http://www.sublimetext.com/docs/3/syntax.html
+name: Racket
+file_extensions:
+ - rkt
+scope: source.racket
+contexts:
+ main:
+ - match: '[^\\](\"[^\"]*\")'
+ captures:
+ 1: string.quoted.double.source.racket
+ - match: '\((define)\s+([a-zA-Z0-9_\-?\+^]+)\s*'
+ scope: meta.variable.source.racket
+ captures:
+ 1: keyword.source.racket
+ 2: entity.name.variable.source.racket
+ - match: '\((define)\s+\(([a-zA-Z0-9_\-?\+^]+)\s*'
+ scope: meta.function.source.racket
+ captures:
+ 1: keyword.source.racket
+ 2: entity.name.function
+ - match: '\((struct)\s+([a-zA-Z0-9_\-?\+^]+)\s+'
+ scope: meta.struct.source.racket
+ captures:
+ 1: keyword.source.racket
+ 2: entity.name.type
+ - match: '[\s\(](if|lambda|cond|define|type-case|let|letrec|let!|\#lang|require|test|else|first|rest|define-type|define-type-alias|define-struct|not|local|error|lang)[\s\)]'
+ scope: meta.keywords.source.racket
+ captures:
+ 1: keyword.source.racket
+ - match: '[\s\(](true|false|empty|null)[\s\)]'
+ captures:
+ 1: constant.language.source.racket
+ - match: '[\s\(\[\{](#t|#true|#f|#false)[\s\)\]\}]'
+ captures:
+ 1: constant.language.source.racket
+ - match: '(#\\[a-zA-Z0-9_\-?\+\.\!\"]+)'
+ captures:
+ 1: constant.language.source.racket
+ - match: '\b(0|([1-9][0-9_]*))\b'
+ scope: constant.numeric.integer.source.racket
+ - match: ;
+ push:
+ - meta_scope: comment.line.documentation.source.racket
+ - match: $\n
+ pop: true
+ - match: '#\|'
+ push:
+ - meta_scope: comment.block.source.racket
+ - match: '\|#'
+ pop: true
diff --git a/tests/syntax-tests/highlighted/Racket/test.rkt b/tests/syntax-tests/highlighted/Racket/test.rkt
new file mode 100644
index 00000000..62281b08
--- /dev/null
+++ b/tests/syntax-tests/highlighted/Racket/test.rkt
@@ -0,0 +1,56 @@
+#lang racket
+
+(require "main.rkt" rackunit)
+
+;; Helper for test cases with multiple outputs
+;; See: https://stackoverflow.com/questions/41081395/unit-testing-in-racket-with-multiple-outputs
+(define-syntax check-values-equal?
+ (syntax-rules ()
+ [(_ a b) (check-equal? (call-with-values (thunk a) list) b)]))
+
+
+;; Named POSIX semaphores
+(test-begin
+ (define test-sem-name "/test-nix-1")
+
+ ;; Unlink if already exists
+ (sem-unlink test-sem-name)
+
+ ;; Open and unlink
+ (define test-sem-p (sem-open test-sem-name (+ O_CREAT O_EXCL)))
+ (check-not-false test-sem-p)
+ (check-not-equal? test-sem-p (void))
+ (check-exn exn:fail?
+ (lambda () (sem-open test-sem-name (+ O_CREAT O_EXCL)))
+ "Permission denied")
+ (check-exn exn:fail?
+ (lambda () (sem-open test-sem-name (+ O_CREAT O_EXCL))))
+
+ ;; Change values
+ (check-equal? (sem-getvalue test-sem-p) 0)
+ (sem-post test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 1)
+ (sem-wait test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 0)
+ (sem-post test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 1)
+ (sem-post test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 2)
+ (sem-trywait test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 2)
+
+ ;; Can't unlink twice
+ (check-not-false (sem-unlink test-sem-name))
+ (check-false (sem-unlink test-sem-name)))
+
+
+;; Named POSIX shared memory
+(test-begin
+ (define test-shm-name "test-nix-mem-1")
+
+ ;; Open and unlink
+ (shm-unlink test-shm-name)
+ (define test-shm-fd (shm-open test-shm-name (+ O_EXCL O_CREAT O_RDWR) #o644))
+ (check > test-shm-fd 0)
+ (check-not-false (shm-unlink test-shm-name))
+ (check-false (shm-unlink test-shm-name)))
diff --git a/tests/syntax-tests/source/Racket/test.rkt b/tests/syntax-tests/source/Racket/test.rkt
new file mode 100644
index 00000000..ed9a3131
--- /dev/null
+++ b/tests/syntax-tests/source/Racket/test.rkt
@@ -0,0 +1,56 @@
+#lang racket
+
+(require "main.rkt" rackunit)
+
+;; Helper for test cases with multiple outputs
+;; See: https://stackoverflow.com/questions/41081395/unit-testing-in-racket-with-multiple-outputs
+(define-syntax check-values-equal?
+ (syntax-rules ()
+ [(_ a b) (check-equal? (call-with-values (thunk a) list) b)]))
+
+
+;; Named POSIX semaphores
+(test-begin
+ (define test-sem-name "/test-nix-1")
+
+ ;; Unlink if already exists
+ (sem-unlink test-sem-name)
+
+ ;; Open and unlink
+ (define test-sem-p (sem-open test-sem-name (+ O_CREAT O_EXCL)))
+ (check-not-false test-sem-p)
+ (check-not-equal? test-sem-p (void))
+ (check-exn exn:fail?
+ (lambda () (sem-open test-sem-name (+ O_CREAT O_EXCL)))
+ "Permission denied")
+ (check-exn exn:fail?
+ (lambda () (sem-open test-sem-name (+ O_CREAT O_EXCL))))
+
+ ;; Change values
+ (check-equal? (sem-getvalue test-sem-p) 0)
+ (sem-post test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 1)
+ (sem-wait test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 0)
+ (sem-post test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 1)
+ (sem-post test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 2)
+ (sem-trywait test-sem-p)
+ (check-equal? (sem-getvalue test-sem-p) 2)
+
+ ;; Can't unlink twice
+ (check-not-false (sem-unlink test-sem-name))
+ (check-false (sem-unlink test-sem-name)))
+
+
+;; Named POSIX shared memory
+(test-begin
+ (define test-shm-name "test-nix-mem-1")
+
+ ;; Open and unlink
+ (shm-unlink test-shm-name)
+ (define test-shm-fd (shm-open test-shm-name (+ O_EXCL O_CREAT O_RDWR) #o644))
+ (check > test-shm-fd 0)
+ (check-not-false (shm-unlink test-shm-name))
+ (check-false (shm-unlink test-shm-name)))