Commits

rivo  committed 0ae81aa

restore (check EXPRESSION) syntax

  • Participants
  • Parent commits 240230f
  • Tags bitstring-0.5

Comments (0)

Files changed (4)

File bitstring.scm

         (bitstring-pattern "read" stream handler pattern ...)))))
 
 (define-syntax bitstring-pattern
-  (syntax-rules (big little bitstring ? float double bitpacket)
+  (syntax-rules (big little bitstring check float double bitpacket)
     ; all patterns take expansion
     ((_ "read" stream handler)
       (and
     ((_ "write" stream handler ())
       stream)
     ; user guard expression
-    ((_ mode stream handler (? guard) rest ...)
+    ((_ mode stream handler (check guard) rest ...)
       (and
         guard
         (bitstring-pattern mode stream handler rest ...)))
     (bitmatch data
       (()
         (reverse acc))
-      (((? little-endian) (value bits little) (rest bitstring))
+      (((check little-endian) (value bits little) (rest bitstring))
         (loop rest (cons value acc)))
       (((value bits big) (rest bitstring))
         (loop rest (cons value acc)))

File tests/examples.scm

     (Reserved 1) (DF 1) (MF 1)
     (FramgentOffset 13)
     (TTL 8)
-    (Protocol 8) (? (or (= Protocol 1)
-                        (= Protocol 2)
-                        (= Protocol 6)
-                        (= Protocol 17))) 
+    (Protocol 8) (check (or (= Protocol 1)
+                            (= Protocol 2)
+                            (= Protocol 6)
+                            (= Protocol 17)))
     (CheckSum 16)
     (SourceAddr 32 bitstring)
     (DestinationAddr 32 bitstring)

File tests/run.scm

 (test 'ok
   (bitmatch `#( #x8F )
     (((1 1) (rest)) 'fail)
-    (((x 1) (? (= x 0)) (rest bitstring)) 'fail2) 
+    (((x 1) (check (= x 0)) (rest bitstring)) 'fail2) 
     (((1 1) (rest bitstring)) 'ok)))
 
 (test 'ok

File tests/tga.scm

     (bitmatch data
       ; True-Color uncompressed
       (((TGA-Header bitpacket)
-      	(? (and (= 0 ColorMapType) (= 2 ImageType)))
+      	(check (and (= 0 ColorMapType) (= 2 ImageType)))
       	(ID-data ID-length bitstring)
         (Image-data (* ImageWidth ImageHeight PixelDepth) bitstring)
         (Rest-data bitstring))
         	    PixelDepth Image-data)))
       ; True-Color compressed
       (((TGA-Header bitpacket)
-      	(? (and (= 0 ColorMapType) (= 10 ImageType)))
+      	(check (and (= 0 ColorMapType) (= 10 ImageType)))
       	(ID-data ID-length bitstring)
       	(Image-data bitstring))
       		(begin