Skip to content

Commit abe4152

Browse files
committed
Add char-whitespace?
1 parent 579cbbf commit abe4152

6 files changed

Lines changed: 17 additions & 5 deletions

File tree

langs/outlaw/compile-ops.rkt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@
146146
(pad-stack)
147147
(Call 'is_char_alphabetic)
148148
(unpad-stack))]
149+
['char-whitespace?
150+
(seq (assert-char rax)
151+
(Sar rax char-shift)
152+
(Mov rdi rax)
153+
(pad-stack)
154+
(Call 'is_char_whitespace)
155+
(unpad-stack))]
149156

150157
;; Op2
151158
['+

langs/outlaw/compile.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
string->uninterned-symbol
8181
open-input-file
8282
write-char error integer?
83-
eq-hash-code char-alphabetic?
83+
eq-hash-code char-alphabetic? char-whitespace?
8484
;; Op2
8585
+ - < = cons eq? make-vector vector-ref
8686
make-string string-ref string-append
@@ -103,6 +103,7 @@
103103
read_byte_port
104104
peek_byte_port
105105
is_char_alphabetic
106+
is_char_whitespace
106107
system_type)))
107108

108109
(define cons-function

langs/outlaw/parse.rkt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,6 @@
291291
[(? symbol? xs)
292292
(LamRest (gensym 'lamrest) '() xs (parse-e e))]
293293
[_
294-
(eprintf "xs: ~a e: ~a\n" xs e)
295294
(error "parse parameter list error")]))
296295

297296
;; Datum -> Datum
@@ -337,7 +336,7 @@
337336
write-char
338337
error integer?
339338
eq-hash-code
340-
char-alphabetic?))
339+
char-alphabetic? char-whitespace?))
341340
(define op2
342341
'(+ - < = cons eq? make-vector vector-ref make-string string-ref
343342
string-append set-box! quotient remainder

langs/outlaw/print.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ val_t is_char_alphabetic(val_char_t c) {
1919
return val_wrap_bool(uc_is_property_alphabetic(c));
2020
}
2121

22-
22+
val_t is_char_whitespace(val_char_t c) {
23+
return val_wrap_bool(uc_is_property_white_space(c));
24+
}
2325

2426
void print_result(val_t x)
2527
{

langs/outlaw/stdlib.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
not
1414
findf
1515
read-line
16-
char-alphabetic?
16+
char-alphabetic? char-whitespace?
1717
; unimplemented
1818
exact->inexact / expt string->keyword
1919
;; Op0
@@ -553,6 +553,7 @@
553553
(read-line/a (cons c cs)))))
554554

555555
(define (char-alphabetic? x) (%char-alphabetic? x))
556+
(define (char-whitespace? x) (%char-whitespace? x))
556557

557558
(define (exact->inexact x)
558559
(error "exact->inexact not implemented"))

langs/outlaw/test/test-runner.rkt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@
594594
(check-equal? (run '(findf odd? '(2 4 3 7))) 3)
595595
(check-equal? (run '(char-alphabetic? #\a)) #t)
596596
(check-equal? (run '(char-alphabetic? #\space)) #f)
597+
(check-equal? (run '(char-whitespace? #\a)) #f)
598+
(check-equal? (run '(char-whitespace? #\space)) #t)
597599
(check-equal? (run '(begin 1)) 1)
598600
(check-equal? (run '(begin 1 2)) 2)
599601
(check-equal? (run '(begin 1 2 3)) 3)

0 commit comments

Comments
 (0)