add reader syntax for []

Now [...] reads to (¤ ...) for easy semantic processing
This commit is contained in:
2025-10-21 21:22:22 +03:00
parent cca63fb4df
commit 4165fbe299
4 changed files with 73 additions and 4 deletions

View File

@@ -19,7 +19,7 @@
(test '%define (atom-to-fmt-c 'define))
(test '%pointer (atom-to-fmt-c 'pointer))
(test '%array (atom-to-fmt-c 'array))
(test 'vector-ref (atom-to-fmt-c '@))
(test 'vector-ref (atom-to-fmt-c '¤))
(test '%include (atom-to-fmt-c 'include))
(test '%cast (atom-to-fmt-c 'cast))

28
tests/reader.scm Normal file
View File

@@ -0,0 +1,28 @@
(import (chicken port))
(test-group "reader"
;; []-syntax. For array types and array access expressions
(test '((¤ * char))
(with-input-from-string "[* char]"
(lambda ()
(read-raw-forms 'stdin))))
(test '((¤ * * char const 512))
(with-input-from-string "[* * char const 512]"
(lambda ()
(read-raw-forms 'stdin))))
(test '((¤))
(with-input-from-string "[]"
(lambda ()
(read-raw-forms 'stdin))))
(test '((¤ (¤)))
(with-input-from-string "[[]]"
(lambda ()
(read-raw-forms 'stdin))))
(test '((¤ (¤ const char)))
(with-input-from-string "[[const char]]"
(lambda ()
(read-raw-forms 'stdin)))))

View File

@@ -9,6 +9,7 @@
(include "basic.scm")
(include "semen.scm")
(include "reader.scm")
(include "utils.scm")
;;; Should be the last in the test suite