Skip to content

Commit

Permalink
Whitespace fixes in .scm files
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobaldassi committed Oct 30, 2012
1 parent 1c285d9 commit b48a9db
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 55 deletions.
72 changes: 36 additions & 36 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,18 @@
(if (eqv? (peek-char port) #\0)
(begin (write-char (read-char port) str)
(set! leadingzero #t)
(cond ((allow #\x)
(begin
(set! leadingzero #f)
(set! pred char-hex?)))
((allow #\o)
(begin
(set! leadingzero #f)
(set! pred char-oct?)))
((allow #\b)
(begin
(set! leadingzero #f)
(set! pred char-bin?)))))
(cond ((allow #\x)
(begin
(set! leadingzero #f)
(set! pred char-hex?)))
((allow #\o)
(begin
(set! leadingzero #f)
(set! pred char-oct?)))
((allow #\b)
(begin
(set! leadingzero #f)
(set! pred char-bin?)))))
(allow #\.)))
(read-digs leadingzero)
(if (eqv? (peek-char port) #\.)
Expand All @@ -245,41 +245,41 @@
(read-digs #f)
(disallow-dot))
(io.ungetc port c))))
; disallow digits after binary or octal literals, e.g., 0b12
(if (and (or (eq? pred char-bin?) (eq? pred char-oct?))
(not (eof-object? c))
(char-numeric? c))
(error (string "invalid numeric constant "
(get-output-string str) c)))))
; disallow digits after binary or octal literals, e.g., 0b12
(if (and (or (eq? pred char-bin?) (eq? pred char-oct?))
(not (eof-object? c))
(char-numeric? c))
(error (string "invalid numeric constant "
(get-output-string str) c)))))
(let* ((s (get-output-string str))
(r (cond ((eq? pred char-hex?) 16)
((eq? pred char-oct?) 8)
((eq? pred char-bin?) 2)
(else 10)))
(n (string->number s r)))
(r (cond ((eq? pred char-hex?) 16)
((eq? pred char-oct?) 8)
((eq? pred char-bin?) 2)
(else 10)))
(n (string->number s r)))
(if n
(cond ((eq? pred char-hex?) (sized-uint-literal n s 4))
((eq? pred char-oct?) (sized-uint-oct-literal n s))
((eq? pred char-bin?) (sized-uint-literal n s 1))
(else (if (and (integer? n) (> n 9223372036854775807))
(error (string "invalid numeric constant " s))
n)))
(cond ((eq? pred char-hex?) (sized-uint-literal n s 4))
((eq? pred char-oct?) (sized-uint-oct-literal n s))
((eq? pred char-bin?) (sized-uint-literal n s 1))
(else (if (and (integer? n) (> n 9223372036854775807))
(error (string "invalid numeric constant " s))
n)))
(error (string "invalid numeric constant " s))))))

(define (sized-uint-literal n s b)
(let ((l (* (- (length s) 2) b)))
(cond ((<= l 8) (uint8 n))
((<= l 16) (uint16 n))
((<= l 32) (uint32 n))
(else (uint64 n)))))
((<= l 16) (uint16 n))
((<= l 32) (uint32 n))
(else (uint64 n)))))

(define (sized-uint-oct-literal n s)
(if (eqv? (string.char s 2) #\0)
(sized-uint-literal n s 3)
(cond ((< n 256) (uint8 n))
((< n 65536) (uint16 n))
((< n 4294967296) (uint32 n))
(else (uint64 n)))))
((< n 65536) (uint16 n))
((< n 4294967296) (uint32 n))
(else (uint64 n)))))

(define (skip-ws-and-comments port)
(skip-ws port #t)
Expand Down Expand Up @@ -440,7 +440,7 @@
(if (memv (require-token s) closers)
(list head) ; empty block
(let loop ((ex
;; in allow-empty mode skip leading runs of operator
;; in allow-empty mode skip leading runs of operator
(if (and allow-empty (eqv? (require-token s) op))
'()
(if (eqv? op #\newline)
Expand Down
18 changes: 9 additions & 9 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
(define (rewrite-ctor ctor Tname params field-names)
(define (ctor-body body)
`(block ;; make type name global
(global ,Tname)
(global ,Tname)
,(pattern-replace (pattern-set
(pattern-lambda
(call (-/ new) . args)
Expand Down Expand Up @@ -1110,8 +1110,8 @@

(define (get-eltype)
(if (null? atype)
`((call (top eltype) ,oneresult))
`(,atype)))
`((call (top eltype) ,oneresult))
`(,atype)))

;; Evaluate the comprehension
`(scope-block
Expand Down Expand Up @@ -1150,7 +1150,7 @@

;; construct loops to cycle over all dimensions of an n-d comprehension
(define (construct-loops ranges)
(if (null? ranges)
(if (null? ranges)
`(block (= ,oneresult ,expr)
(type_goto ,initlabl)
(call (top assign) ,result ,oneresult ,ri)
Expand Down Expand Up @@ -1180,7 +1180,7 @@
(pattern-lambda
(typed-comprehension atype expr . ranges)
(if (any (lambda (x) (eq? x ':)) ranges)
(lower-nd-comprehension atype expr ranges)
(lower-nd-comprehension atype expr ranges)
(let ( (result (gensy))
(ri (gensy))
(rs (map (lambda (x) (gensy)) ranges)) )
Expand All @@ -1194,7 +1194,7 @@

;; construct loops to cycle over all dimensions of an n-d comprehension
(define (construct-loops ranges rs)
(if (null? ranges)
(if (null? ranges)
`(block (call (top assign) ,result ,expr ,ri)
(+= ,ri 1))
`(for (= ,(cadr (car ranges)) ,(car rs))
Expand Down Expand Up @@ -1756,7 +1756,7 @@ So far only the second case can actually occur.
;(let ((vi (var-info-for (cadr e) env)))
; (if vi
; (begin (vinfo:set-type! vi (caddr e))
; (cadr e))
; (cadr e))
`(call (top typeassert) ,(cadr e) ,(caddr e)))
((or (eq? (car e) 'decl) (eq? (car e) '|::|))
; handle var::T declaration by storing the type in the var-info
Expand All @@ -1769,7 +1769,7 @@ So far only the second case can actually occur.
(if (assq (cadr e) captvars)
(error (string "type of " (cadr e)
" declared in inner scope")))
(vinfo:set-type! vi (caddr e))
(vinfo:set-type! vi (caddr e))
'(null))
`(call (top typeassert) ,(cadr e) ,(caddr e)))))
((eq? (car e) 'lambda)
Expand Down Expand Up @@ -1968,7 +1968,7 @@ So far only the second case can actually occur.
(define (expand-backquote e)
(cond ((or (eq? e 'true) (eq? e 'false)) e)
((symbol? e) `(quote ,e))
((not (pair? e)) e)
((not (pair? e)) e)
((eq? (car e) '$) (cadr e))
((and (eq? (car e) 'quote) (pair? (cadr e)))
(expand-backquote (expand-backquote (cadr e))))
Expand Down
16 changes: 8 additions & 8 deletions src/match.scm
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
((> min max) #f)
; case 1: only allowed to match 0 subexpressions
((= max 0) (match-seq prest expr
(if var (cons (cons var (reverse sofar)) state)
(if var (cons (cons var (reverse sofar)) state)
state)
L))
L))
; case 2: must match at least 1
((> min 0)
(let ((subma (match- p (car expr) state)))
Expand All @@ -97,7 +97,7 @@
; otherwise, must match either 0 or between 1 and max subexpressions
(else
(or (match-star- p prest expr state var 0 0 L sofar)
(match-star- p prest expr state var 1 max L sofar)))))
(match-star- p prest expr state var 1 max L sofar)))))
(define (match-star p prest expr state var min max L)
(match-star- p prest expr state var min max L '()))

Expand All @@ -112,7 +112,7 @@
(if (and (pair? subp)
(eq? (car subp) '--))
(begin (set! var (cadr subp))
(set! subp (caddr subp)))
(set! subp (caddr subp)))
#f)
(let ((head (if (pair? subp) (car subp) '())))
(cond ((eq? subp '...)
Expand Down Expand Up @@ -144,7 +144,7 @@
(apply-patterns (vector-ref plist 2) expr)
enew))
(apply-patterns (vector-ref plist 2) expr)))
((null? plist) expr)
((null? plist) expr)
(else
(let ((enew ((car plist) expr)))
(if (not enew)
Expand All @@ -164,7 +164,7 @@
expr
(let ((enew (apply-patterns plist expr)))
(if (eq? enew expr)
;; expr didn't change; move to subexpressions
;; expr didn't change; move to subexpressions
(let ((sub (lambda (subex)
(if (not (pair? subex))
subex
Expand Down Expand Up @@ -194,7 +194,7 @@
expr
(let ((enew (apply-patterns plist expr)))
(if (eq? enew expr)
;; expr didn't change; move to subexpressions
;; expr didn't change; move to subexpressions
(map (lambda (subex)
(if (not (pair? subex))
subex
Expand Down Expand Up @@ -245,6 +245,6 @@
(define (patargs p)
(cons '__ (patargs- p)))
(let* ((args (patargs pat))
(expander `(lambda ,args ,body)))
(expander `(lambda ,args ,body)))
`(lambda (__ex__)
(plambda-expansion ',pat __ex__ ,expander ',args))))
4 changes: 2 additions & 2 deletions src/utils.scm
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

(define (diff s1 s2)
(cond ((null? s1) '())
((memq (car s1) s2) (diff (cdr s1) s2))
(else (cons (car s1) (diff (cdr s1) s2)))))
((memq (car s1) s2) (diff (cdr s1) s2))
(else (cons (car s1) (diff (cdr s1) s2)))))

(define (unique lst)
(if (null? lst)
Expand Down

0 comments on commit b48a9db

Please sign in to comment.