notes and semi cleanup

This commit is contained in:
Jay McCarthy 2015-12-22 15:25:04 -05:00
parent c092fcf3a1
commit 774df1dd38
5 changed files with 27 additions and 65 deletions

View File

@ -1,22 +1,6 @@
TODO add ; as #%semicolon that adds ()s between occurrences
TODO add syntax property for def transformer on RHS (for function call
results, alloc, etc)
TODO maybe add , as special
TODO #%dot is extensible transformer
(struct posn ((complex x) y))
(define (f (posn p))
p.x.real-part)
p.x.real-part
(#%dot (#%dot p x) real-part)
(let ([(complex tmp) (posn-x p)])
(#%dot tmp real-part))
(define (from-origin x) : posn
(posn x x))
@ -24,20 +8,10 @@ p.x.real-part
(begin a (from-origin 5)).x
TODO #%dot app syntax differently
obj.(move 5 6)
(define (f (cons x y))
stuff)
(define (f (a-cons p))
stuff)
(define (f [: b box])
stuff)
(define (f box.b)
stuff)
(define (f (box x))
stuff)
TODO robby's request
(haskell-style

View File

@ -12,4 +12,5 @@
(provide (rename-out
[remix-module-begin #%module-begin])
#%semi
unquote
require)

View File

@ -9,17 +9,13 @@
(define-syntax-class not-semi
#:literals (#%semi unquote)
(pattern (~and (~not #%semi)
(~not (unquote #%semi)))))
(~not (unquote . _)))))
(define-splicing-syntax-class semi-piece
#:literals (#%semi unquote)
#:attributes (it)
(pattern (~seq #%semi it))
(pattern (unquote it))
(pattern (~seq sp:not-semi ... #%semi)
#:attr it #'(sp ...))
(pattern (~seq sp:not-semi ... (~and uqs (unquote #%semi)))
#:attr it
(with-syntax ([semi-#%braces (datum->syntax #'uqs '#%braces)])
#'(semi-#%braces sp ...))))
#:attr it #'(sp ...)))
(define-splicing-syntax-class semi-seq
#:attributes ([semi-form 1] [tail-form 1])
(pattern (~seq s:semi-piece ... tail-form:not-semi ...)

View File

@ -164,7 +164,7 @@
(syntax->list
#'(output ...)))])))
(define-syntax (the-#%braces stx)
(define-syntax (#%braces stx)
(syntax-parse stx
[(_ input-tokens ...)
(shunting-yard:consume-input
@ -172,7 +172,7 @@
empty
empty)]))
(define-syntax (#%braces stx)
(define-syntax (block-#%braces stx)
(syntax-parse stx
[(_ s:semi-seq)
(syntax-case #'(s.semi-form ...) ()
@ -376,7 +376,6 @@
(rename-out [... ]) ;; \ldots
#%datum
quote
unquote
module
module*
module+

View File

@ -8,17 +8,15 @@ require remix/stx0
remix/num/gen0;
;; A semi introduces a set of parens to its left
;; If there is nothing to its left, then it ;-quotes what is to its
;; right and makes it not introduce a set of parens
;; As usual `unquote` escapes from its context, in the case of a
;; semi-sequence, this means that the term is not wrapped.
,(module+ test
;; This introduces ≡ as a testing form
;
(module+ test
;; This introduces ≡ as a testing form
;; XXX Drop this and instead have a macro for writing down
;; properties that communicates with boolean forms, etc. Supports ∀,
;; etc.
(require remix/test0))
;; XXX Drop this and instead have a macro for writing down
;; properties that communicates with boolean forms, etc. Supports ∀,
;; etc.
(require remix/test0))
;; define is replaced with def
def z 42;
@ -30,9 +28,8 @@ def x
(def a 40)
(def b 2)
(+ a b) ;
;
(module+ test
{x 42})
,(module+ test
{x 42})
;; If you would like to use ;-syntax in the inside of def, then you
;; need more punctuation. You have two choices.
@ -40,25 +37,20 @@ def x2
[def a 40;
def b 2;
(+ a b)];
;
(module+ test
{x2 42})
,(module+ test
{x2 42})
def x3
{def a 40;
[def a 40;
def b 2;
a + b};
;
(module+ test
{x3 42})
{a + b}];
,(module+ test
{x3 42})
;; If the kind of delimiters you want ; to introduce are {}s, then use
;; ,;
def x4
{a := 40,;
b := 2,;
a + b};
;
[,{a := 40}
def b 2 ;
{a + b}];
(module+ test
{x4 42})