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