Skip to content

Commit

Permalink
rename PUSH to push! and pop to pop!.
Browse files Browse the repository at this point in the history
Issue #33.
  • Loading branch information
samrushing committed Aug 29, 2018
1 parent 264125a commit 6b2789c
Show file tree
Hide file tree
Showing 68 changed files with 226 additions and 229 deletions.
14 changes: 7 additions & 7 deletions demo/bignum.scm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
(let ((r '()))
;; iterate in reverse to accumulate
(for-range-rev i (vlen digs)
(PUSH r (format (zpad big/repr-width (hex digs[i])))))
(push! r (format (zpad big/repr-width (hex digs[i])))))
(format (join "." r))))

;; eventually we'll add support to the reader for big literals
Expand Down Expand Up @@ -987,11 +987,11 @@
(while (> nbits 0)
;; make sure we have some bits
(when (= bbits 0)
(set! byte (pop bytes))
(set! byte (pop! bytes))
(set! bbits 8))
;; start a new digit if we need to
(when (= dbits 0)
(PUSH digits digit)
(push! digits digit)
(set! digit 0)
(set! dbits big/bits))
;; roll some bits in
Expand All @@ -1002,7 +1002,7 @@
(dec! nbits bits)
(set! byte (logand byte (- (<< 1 bits) 1)))
))
(PUSH digits digit)
(push! digits digit)
(reverse digits)
))

Expand Down Expand Up @@ -1034,11 +1034,11 @@
(while (> nbits 0)
;; make sure we have some bits
(when (= dbits 0)
(set! digit (pop digits))
(set! digit (pop! digits))
(set! dbits big/bits))
;; start a new byte if we need to
(when (= bbits 0)
(PUSH bytes byte)
(push! bytes byte)
(set! byte 0)
(set! bbits 8))
;; roll some bits in
Expand All @@ -1052,7 +1052,7 @@
(dec! bbits bits)
(dec! nbits bits)
))
(PUSH bytes byte)
(push! bytes byte)
(remove-zeros bytes)
))

Expand Down
2 changes: 1 addition & 1 deletion demo/brainfuck.scm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#\, -> (loop (cons (insn:in) code) (+ i 1))
#\[ -> (let ((sub (P))
(len (length sub)))
(PUSH code (insn:left len))
(push! code (insn:left len))
(loop (append sub code) (+ i len)))
#\] -> (let ((len (length code)))
(cons (insn:right (+ len 1)) code))
Expand Down
4 changes: 2 additions & 2 deletions demo/frb.scm
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@
;; some way to do these using foldr?
(define (tree/keys t)
(let ((r '()))
(tree/reverse (lambda (k v) (PUSH r k)) t)
(tree/reverse (lambda (k v) (push! r k)) t)
r))

(define (tree/values t)
(let ((r '()))
(tree/reverse (lambda (k v) (PUSH r v)) t)
(tree/reverse (lambda (k v) (push! r v)) t)
r))

(define tree/dump
Expand Down
2 changes: 1 addition & 1 deletion demo/maze/ascii.scm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
(define (graph->base85 G m n)
(let ((result '()))
(for ch (b85-enc (bytegen G m n))
(PUSH result ch))
(push! result ch))
(printf (list->string (reverse result)) "\n")
))

Expand Down
10 changes: 5 additions & 5 deletions demo/maze/js.scm
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ function draw_maze (data, w, h, s) {
(for-range x m
(let ((walls G[(+ x (* y m))]))
(match (bit-set? walls 3) (bit-set? walls 1) with
#t #t -> (PUSH line #\T)
#t #f -> (PUSH line #\U)
#f #t -> (PUSH line #\L)
#f #f -> (PUSH line #\space)
#t #t -> (push! line #\T)
#t #f -> (push! line #\U)
#f #t -> (push! line #\L)
#f #f -> (push! line #\space)
)))
(PUSH lines (list->string (reverse line)))
(push! lines (list->string (reverse line)))
(set! line '()))
(emitf "maze_data = [\n")
(for-list line (reverse lines)
Expand Down
2 changes: 1 addition & 1 deletion demo/maze/solve.scm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
(when (not (bit-set? walls i))
(let ((node0 (move node (<< 1 i))))
(when (not visited[node0])
(PUSH r node0)))))
(push! r node0)))))
r))

(define (search node dx path)
Expand Down
6 changes: 3 additions & 3 deletions demo/maze/svg2.scm
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
(let ((walls G[(+ x (* y m))]))
(match (bit-set? walls 3) (bit-set? walls 1) with
;; U L
#t #f -> (PUSH u y)
#f #t -> (PUSH l y)
#t #t -> (PUSH ul y)
#t #f -> (push! u y)
#f #t -> (push! l y)
#t #t -> (push! ul y)
_ _ -> #u
)))
;; draw a column of each of the markers placed.
Expand Down
18 changes: 9 additions & 9 deletions demo/parse/antlr2irken/antlr2irken.scm
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
(define (replace-rule exp make)
(let ((index (cmap/add rule-map exp))
(new-name (string->symbol (format (sym name) "-" (int index)))))
(PUSH new-rules (make new-name exp))
(push! new-rules (make new-name exp))
(exp:name new-name)))

(define walk-exp
Expand Down Expand Up @@ -340,8 +340,8 @@
(for-list mhi hd0
(for-list tli tl0
(match mhi with
(maybe:yes hi) -> (PUSH r (list:cons hi tli))
(maybe:no) -> (PUSH r tli)
(maybe:yes hi) -> (push! r (list:cons hi tli))
(maybe:no) -> (push! r tli)
)))
;; (printf "recur: => ") (printn r)
(reverse r)))
Expand Down Expand Up @@ -369,7 +369,7 @@
(let ((new-alts '()))
(for-list alt alts
(for-list alt0 (process-alt alt)
(PUSH new-alts alt0)))
(push! new-alts alt0)))
(:tuple (reverse new-alts) (reverse new-rules))
)))

Expand All @@ -386,7 +386,7 @@
(match rule with
(rule:parse name exp)
-> (let (((new-alts new-rules) (convert-rule name (exp->alts exp))))
(PUSH result (rule:parse name (exp:or new-alts)))
(push! result (rule:parse name (exp:or new-alts)))
(for-list new-rule new-rules
(queue/add! fifo new-rule)))
other
Expand Down Expand Up @@ -416,7 +416,7 @@
(let ((chars (string->list (read-antlr-string s)))
(r '()))
(for-list ch chars
(PUSH r (rx:sym (charset/single (char->int ch)))))
(push! r (rx:sym (charset/single (char->int ch)))))
(nary->binary rx:cat (reverse r))))

(define (cs->rx s)
Expand Down Expand Up @@ -504,7 +504,7 @@
(for-list exp exps
(match exp with
(exp:literal lit)
-> (PUSH lits (lit->rx lit))
-> (push! lits (lit->rx lit))
_ -> (raise (:ANTLR2Irken/UnexpectedGrammarItem (rule-repr rule)))
))
(nary->binary rx:or lits)))
Expand Down Expand Up @@ -595,12 +595,12 @@
(lexicon '()))
(for-list rule new-rules
(let (((rrxmap0 earley-rule) (rule->earley rrxmap rule)))
(PUSH earley-rules earley-rule)
(push! earley-rules earley-rule)
(set! rrxmap rrxmap0)))
(set! used-terminals (collect-used-terminals used-terminals earley-rules))
(for-map rx name rrxmap
(when (set/member? used-terminals symbol-index-cmp name)
(PUSH lexicon (sexp (sym name) (rx->sexp rx)))))
(push! lexicon (sexp (sym name) (rx->sexp rx)))))
(printf ";; -*- Mode: Lisp -*-\n")
(pp (sexp (sym 'parser)
(sexp1 'lexicon (reverse lexicon))
Expand Down
2 changes: 1 addition & 1 deletion demo/parse/antlr2sexp.scm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
(r '()))
(alist/iterate
(lambda (name alts)
(PUSH r (sexp1 name (map prods->sexp alts))))
(push! r (sexp1 name (map prods->sexp alts))))
gram)
(printf ";; -*- Mode: Irken -*-\n\n")
(printf ";; generated by " sys.argv[0] " from " sys.argv[1] "\n")
Expand Down
2 changes: 1 addition & 1 deletion demo/repl/repl.scm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
(for-list rand rands
(match rand with
(sexp:symbol name)
-> (begin (PUSH formals name) (univ:undef))
-> (begin (push! formals name) (univ:undef))
_ -> (repl-error (format "bad formals: " (repr (sexp:list rands))))
))
(univ:function (reverse formals) body)
Expand Down
8 changes: 4 additions & 4 deletions doom/dns.scm
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@
(printf "reply truncated\n")
(raise (:DNSTruncated)))
(printf "header: " (dnsheader-repr h) "\n")
(for-range i h.qdcount (PUSH r.qd (unpack-question)))
(for-range i h.ancount (PUSH r.an (unpack-rr)))
(for-range i h.nscount (PUSH r.ns (unpack-rr)))
(for-range i h.arcount (PUSH r.ar (unpack-rr)))
(for-range i h.qdcount (push! r.qd (unpack-question)))
(for-range i h.ancount (push! r.an (unpack-rr)))
(for-range i h.nscount (push! r.ns (unpack-rr)))
(for-range i h.arcount (push! r.ar (unpack-rr)))
(:tuple h r)
))

Expand Down
16 changes: 8 additions & 8 deletions doom/http/hpack.scm
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
(left 8)
(byte 0))
(define (emit-byte)
(PUSH data (int->char byte))
(push! data (int->char byte))
(set! left 8)
(set! byte 0))
(define (emit n bits)
Expand Down Expand Up @@ -225,7 +225,7 @@
(while (>= bits 5) ;; shortest code is 5 bits.
(let loop ((t huffman-table))
(match t with
(hufftree:leaf val) -> (PUSH r (int->char val))
(hufftree:leaf val) -> (push! r (int->char val))
(hufftree:node L R) -> (if (> bits 0) (loop (if (get-bit) R L)))
)))
(list->string (reverse r))
Expand Down Expand Up @@ -320,7 +320,7 @@
(tree/range
map magic-cmp
(:tuple name "") (:tuple name "\xff")
(lambda (k v) (PUSH range (:tuple k v))))
(lambda (k v) (push! range (:tuple k v))))
(reverse range)))

(define (lookup-name-only map name)
Expand Down Expand Up @@ -471,7 +471,7 @@
(table.set-size (get-integer 5)))
(else
(let ((r0 (get-header)))
(PUSH r r0)))))
(push! r r0)))))
(reverse r)))

unpack
Expand All @@ -486,11 +486,11 @@
(never (set/empty)))

(define (emit byte)
(PUSH data (int->char byte)))
(push! data (int->char byte)))

(define (emit-string s)
(for-string ch s
(PUSH data ch)))
(push! data ch)))

(define (emit-integer n0 bits n1)
(let ((mask masks[bits]))
Expand Down Expand Up @@ -564,8 +564,8 @@
(match header with
(:tuple name val)
-> (if (eq? (string-ref name 0) #\:)
(PUSH pseudo header)
(PUSH normal header))))
(push! pseudo header)
(push! normal header))))
(for-list header (append (reverse pseudo) (reverse normal))
(match header with
(:tuple name val)
Expand Down
2 changes: 1 addition & 1 deletion doom/http/websocket.scm
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
(define (pack-uint c n)
(let ((r (list:nil)))
(for-range i c
(PUSH r (int->char (logand #xff n)))
(push! r (int->char (logand #xff n)))
(set! n (>> n 8)))
(list->string r)))

Expand Down
2 changes: 1 addition & 1 deletion doom/s2n.scm
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
(let ((recvd (recv0)))
(when (= recvd 0)
(raise (:Doom/EOF sock)))
(PUSH parts (buffer/get! ibuf (min left recvd)))
(push! parts (buffer/get! ibuf (min left recvd)))
(dec! left (min left recvd))
))
(string-concat (reverse parts)))))
Expand Down
2 changes: 1 addition & 1 deletion doom/socket.scm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
(let ((recvd (loop-nb-read sock.fd (sock/recv sock ibuf))))
(when (= recvd 0)
(raise (:Doom/EOF sock)))
(PUSH parts (buffer/get! ibuf (min left recvd)))
(push! parts (buffer/get! ibuf (min left recvd)))
(dec! left (min left recvd))
))
(string-concat (reverse parts)))))
Expand Down
4 changes: 2 additions & 2 deletions doom/tls/codec.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

(define (assure n)
(when (> n (- blen pos))
(PUSH current buf)
(push! current buf)
(let (((fkind frag) (get-fragment))
(flen (string-length frag)))
(when (not (or (= kind -1) (= fkind kind)))
Expand Down Expand Up @@ -215,7 +215,7 @@
(last (substring buf 0 pos))
(pkt (string-concat (reverse (list:cons last current))))
(plen (string-length pkt)))
(PUSH records {raw=pkt record=record kind=kind version=#x303 length=plen})))
(push! records {raw=pkt record=record kind=kind version=#x303 length=plen})))
(reverse records))
))

Expand Down
6 changes: 3 additions & 3 deletions doom/tls/keysched.scm
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
))

(define (add-tscript-packet pkt)
(PUSH tscript pkt))
(push! tscript pkt))

(define (get-tscript-hash)
(let ((h (hash.make)))
Expand Down Expand Up @@ -101,9 +101,9 @@
(chunk (rope:leaf zeros))
(padding '()))
(when (> r 0)
(PUSH padding (rope:leaf (substring zeros 0 r))))
(push! padding (rope:leaf (substring zeros 0 r))))
(for-range i q
(PUSH padding chunk))
(push! padding chunk))
(rope/cat padding)))

;; how to encrypt pkt[s]:
Expand Down
Loading

0 comments on commit 6b2789c

Please sign in to comment.