[honu] fix some tests. always reparse the right hand side of an operator
This commit is contained in:
parent
249c7b02ca
commit
a94b7b9260
|
@ -42,8 +42,8 @@
|
||||||
|
|
||||||
(define-honu-operator/syntax honu-flow 0.001 'left
|
(define-honu-operator/syntax honu-flow 0.001 'left
|
||||||
(lambda (left right)
|
(lambda (left right)
|
||||||
(with-syntax ([left (honu->racket left)]
|
(with-syntax ([left left]
|
||||||
[right (honu->racket right)])
|
[right right])
|
||||||
(racket-syntax (right left)))))
|
(racket-syntax (right left)))))
|
||||||
|
|
||||||
(begin-for-syntax
|
(begin-for-syntax
|
||||||
|
|
|
@ -220,6 +220,9 @@
|
||||||
(racket-syntax (define (function parsed-arguments ...)
|
(racket-syntax (define (function parsed-arguments ...)
|
||||||
body.result)))])
|
body.result)))])
|
||||||
|
|
||||||
|
(define (definition? code)
|
||||||
|
#f)
|
||||||
|
|
||||||
;; E = macro
|
;; E = macro
|
||||||
;; | E operator E
|
;; | E operator E
|
||||||
;; | [...]
|
;; | [...]
|
||||||
|
@ -299,6 +302,7 @@
|
||||||
re-parse re-parse))))
|
re-parse re-parse))))
|
||||||
#;
|
#;
|
||||||
(debug "Reparsed output ~a\n" (pretty-format (syntax->datum re-parse)))
|
(debug "Reparsed output ~a\n" (pretty-format (syntax->datum re-parse)))
|
||||||
|
(define terminate (definition? re-parse))
|
||||||
(if terminate?
|
(if terminate?
|
||||||
(values (left re-parse)
|
(values (left re-parse)
|
||||||
#'rest)
|
#'rest)
|
||||||
|
@ -375,13 +379,14 @@
|
||||||
(let-values ([(parsed unparsed)
|
(let-values ([(parsed unparsed)
|
||||||
(do-parse #'(rest ...) new-precedence
|
(do-parse #'(rest ...) new-precedence
|
||||||
(lambda (stuff)
|
(lambda (stuff)
|
||||||
|
(define right (parse-all stuff))
|
||||||
(define output
|
(define output
|
||||||
(if current
|
(if current
|
||||||
(if binary-transformer
|
(if binary-transformer
|
||||||
(binary-transformer current stuff)
|
(binary-transformer current right)
|
||||||
(error 'binary "cannot be used as a binary operator in ~a" #'head))
|
(error 'binary "cannot be used as a binary operator in ~a" #'head))
|
||||||
(if unary-transformer
|
(if unary-transformer
|
||||||
(unary-transformer stuff)
|
(unary-transformer right)
|
||||||
(error 'unary "cannot be used as a unary operator in ~a" #'head))))
|
(error 'unary "cannot be used as a unary operator in ~a" #'head))))
|
||||||
#;
|
#;
|
||||||
(debug "Binary transformer ~a\n" binary-transformer)
|
(debug "Binary transformer ~a\n" binary-transformer)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
(for-syntax racket/base
|
(for-syntax racket/base
|
||||||
"parse2.rkt"
|
"parse2.rkt"
|
||||||
"literals.rkt"
|
"literals.rkt"
|
||||||
|
"compile.rkt"
|
||||||
syntax/parse
|
syntax/parse
|
||||||
unstable/syntax))
|
unstable/syntax))
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
(make-accessors #'name (syntax->list #'(fields.name ...)))]
|
(make-accessors #'name (syntax->list #'(fields.name ...)))]
|
||||||
[(fields.name/mutator ...)
|
[(fields.name/mutator ...)
|
||||||
(make-mutators #'name (syntax->list #'(fields.name ...)))])
|
(make-mutators #'name (syntax->list #'(fields.name ...)))])
|
||||||
#'(%racket (struct name (fields.name ...)
|
(racket-syntax (struct name (fields.name ...)
|
||||||
#:transparent
|
#:transparent
|
||||||
#:mutable
|
#:mutable
|
||||||
#:property honu-struct-mutable
|
#:property honu-struct-mutable
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#lang honu
|
#lang honu
|
||||||
|
|
||||||
foo(x){
|
function foo(x){
|
||||||
x + 1
|
x + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
bar(x){
|
function bar(x){
|
||||||
x * 2
|
x * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
buz(z){
|
function buz(z){
|
||||||
z - 4
|
z - 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(for-syntax racket/base
|
(for-syntax racket/base
|
||||||
honu/core/private/literals
|
honu/core/private/literals
|
||||||
honu/core/private/parse2
|
honu/core/private/parse2
|
||||||
|
honu/core/private/compile
|
||||||
syntax/parse))
|
syntax/parse))
|
||||||
|
|
||||||
(define-literal+set linq-literals
|
(define-literal+set linq-literals
|
||||||
|
@ -36,9 +37,9 @@
|
||||||
#'(sort store.result string<?
|
#'(sort store.result string<?
|
||||||
#:key (lambda (name) order-by.result))
|
#:key (lambda (name) order-by.result))
|
||||||
#'store.result)])
|
#'store.result)])
|
||||||
#'(%racket (for/list ([name order]
|
(racket-syntax (for/list ([name order]
|
||||||
guard ...)
|
guard ...)
|
||||||
select.result))))
|
select.result))))
|
||||||
(values out #'rest #f)])))
|
(values out #'rest #f)])))
|
||||||
|
|
||||||
#|
|
#|
|
||||||
|
|
|
@ -8,7 +8,7 @@ macro testx () {x:expression} {
|
||||||
|
|
||||||
testx 5 * 2
|
testx 5 * 2
|
||||||
|
|
||||||
for z in 1 to testx 5 * 2 do
|
for z in 1 to testx 6 * 2 do
|
||||||
printf("z is ~a\n", z)
|
printf("z is ~a\n", z)
|
||||||
|
|
||||||
macro testfor () {x:expression} {
|
macro testfor () {x:expression} {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user