[honu] use = for mutation to be consistent with other uses. put where clauses of list comprehensions on the right side
This commit is contained in:
parent
2af9100a5d
commit
d7a35c1eb8
|
@ -19,7 +19,7 @@
|
|||
[racket:void void]
|
||||
[honu-function function]
|
||||
[honu-var var]
|
||||
[honu-equal =]
|
||||
[honu-== ==]
|
||||
[honu-not-equal !=]
|
||||
[honu--> %arrow]
|
||||
[honu-class class]
|
||||
|
@ -49,8 +49,8 @@
|
|||
[honu-> >] [honu-< <]
|
||||
[honu->= >=]
|
||||
[honu-<= <=]
|
||||
[honu-equal =]
|
||||
[honu-assignment :=]
|
||||
;; [honu-equal =]
|
||||
;; [honu-assignment :=]
|
||||
[honu-map map]
|
||||
[honu-flow \|]
|
||||
[honu-dot %dot]
|
||||
|
@ -63,6 +63,7 @@
|
|||
[honu-structure structure]
|
||||
[honu-structure struct]
|
||||
[honu-syntax syntax]
|
||||
[literal:honu-equal =]
|
||||
[literal:honu-prefix prefix]
|
||||
[literal:honu-then then]
|
||||
[literal:colon %colon]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(require "macro2.rkt"
|
||||
"literals.rkt"
|
||||
(only-in "honu2.rkt" honu-declaration honu-equal separate-ids)
|
||||
(only-in "honu2.rkt" honu-declaration separate-ids)
|
||||
(for-syntax racket/base
|
||||
"literals.rkt"
|
||||
"parse2.rkt"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
honu-in
|
||||
honu-in-lines
|
||||
honu-prefix
|
||||
honu-equal
|
||||
semicolon
|
||||
honu-comma
|
||||
define-literal
|
||||
|
@ -248,7 +249,7 @@
|
|||
|
||||
(define-unary-operator honu-not 0.7 'left not)
|
||||
|
||||
(define-binary-operator honu-equal 1 'left equal?)
|
||||
(define-binary-operator honu-== 1 'left equal?)
|
||||
(define-binary-operator honu-not-equal 1 'left (lambda (left right)
|
||||
(not (equal? left right))))
|
||||
|
||||
|
@ -379,7 +380,7 @@
|
|||
;; var a, b, c = values(1 + 2, 5, 9)
|
||||
(define-splicing-syntax-class honu-declaration
|
||||
#:literal-sets (cruft)
|
||||
#:literals (honu-equal honu-var)
|
||||
#:literals (honu-var)
|
||||
[pattern (~seq honu-var (~var variables (separate-ids (literal-syntax-class honu-comma)
|
||||
(literal-syntax-class honu-equal)))
|
||||
honu-equal one:honu-expression)
|
||||
|
@ -390,7 +391,6 @@
|
|||
(define-honu-syntax honu-var
|
||||
(lambda (code context)
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
#:literals (honu-equal)
|
||||
[(var:honu-declaration . rest)
|
||||
(define result #'(%racket (define-values (var.name ...) var.expression)))
|
||||
(values result #'rest #t)])))
|
||||
|
@ -414,7 +414,7 @@
|
|||
(define-honu-syntax honu-for
|
||||
(lambda (code context)
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
#:literals (honu-equal honu-in)
|
||||
#:literals (honu-in)
|
||||
[(_ (~seq iterator:id honu-in stuff:honu-expression (~optional honu-comma)) ...
|
||||
honu-do body:honu-expression . rest)
|
||||
(values #'(%racket (for ([iterator stuff.result] ...)
|
||||
|
@ -434,7 +434,6 @@
|
|||
#:with variable #'iterator
|
||||
#:with expression #'(in-lines)])
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
#:literals (honu-equal)
|
||||
[(_ (~seq init:id honu-equal init-expression:honu-expression (~optional honu-comma)) ...
|
||||
(~seq sequence:sequence-expression (~optional honu-comma)) ...
|
||||
honu-do body:honu-expression . rest)
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
honu-+= honu--= honu-*= honu-/= honu-%=
|
||||
honu-&= honu-^= honu-\|= honu-<<= honu->>= honu->>>=
|
||||
honu->> honu-<< honu->>> honu-< honu-> honu-<= honu->=
|
||||
honu-!= honu-==
|
||||
honu-!=
|
||||
honu-equal
|
||||
honu-<-
|
||||
honu-literal
|
||||
honu-then
|
||||
|
@ -43,4 +44,4 @@
|
|||
|
||||
(define-literal-set cruft (#%parens #%brackets #%braces
|
||||
%racket
|
||||
semicolon colon honu-comma honu-<-))
|
||||
semicolon colon honu-comma honu-equal))
|
||||
|
|
|
@ -384,16 +384,17 @@
|
|||
[(#%brackets stuff ...)
|
||||
(define-literal-set wheres (honu-where))
|
||||
(syntax-parse #'(stuff ...) #:literal-sets (cruft wheres)
|
||||
[(work:honu-expression (~optional (~seq honu-where where:honu-expression))
|
||||
colon (~seq variable:id honu-<- list:honu-expression (~optional honu-comma)) ...)
|
||||
[(work:honu-expression
|
||||
colon (~seq variable:id honu-equal list:honu-expression (~optional honu-comma)) ...
|
||||
(~seq honu-where where:honu-expression (~optional honu-comma)) ...)
|
||||
(define filter (if (attribute where)
|
||||
#'(#:when where.result)
|
||||
#'((#:when where.result) ...)
|
||||
#'()))
|
||||
(define comprehension
|
||||
(with-syntax ([(filter ...) filter])
|
||||
(with-syntax ([((filter ...) ...) filter])
|
||||
#'(for/list ([variable list.result]
|
||||
...
|
||||
filter ...)
|
||||
filter ... ...)
|
||||
work.result)))
|
||||
(if current
|
||||
(values (left current) stream)
|
||||
|
|
|
@ -116,8 +116,8 @@
|
|||
(test
|
||||
"list comprehension"
|
||||
@input{
|
||||
[x + 1: x <- [1, 2, 3]];
|
||||
[x + y: x <- [1, 2, 3], y <- [4, 5, 6]]
|
||||
[x + 1: x = [1, 2, 3]];
|
||||
[x + y: x = [1, 2, 3], y = [4, 5, 6]]
|
||||
}
|
||||
|
||||
@output{'(2 3 4)
|
||||
|
|
Loading…
Reference in New Issue
Block a user