Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

List comprehension -> binary test.

  • Loading branch information...
commit 4e7a283cf2363b0b3b76f8681efd6a601dfc1588 1 parent 08973b3
@massung authored
Showing with 7 additions and 2 deletions.
  1. +1 −1  debug.ml
  2. +0 −1  interp.ml
  3. +1 −0  parser.mly
  4. +5 −0 test.fc
View
2  debug.ml
@@ -42,7 +42,7 @@ let rec see terms n =
| Jmp_if d -> Printf.sprintf "jmp_if #%04x" (k+d+1)
| Call n -> Printf.sprintf "call %d" n
| For n -> Printf.sprintf "for %d" n
- | Comp n -> Printf.sprintf "comp %d" n
+ | Comp n -> Printf.sprintf "comp list %d" n
| Get m -> Printf.sprintf "get %s" m.Atom.name
| Set m -> Printf.sprintf "set %s" m.Atom.name
| Probe -> "probe"
View
1  interp.ml
@@ -392,4 +392,3 @@ and do_list_comp st n =
(* the actual list comprehension *)
let xs = comprehend [] rs in Vector.push (List xs) st.stack
-
View
1  parser.mly
@@ -244,6 +244,7 @@ tuple:
| PAREN exprs END_PAREN { expr_list $2 tuple }
binary:
+ | BINARY END_BINARY { binary 0 }
| BINARY exprs END_BINARY { expr_list $2 binary }
list:
View
5 test.fc
@@ -12,6 +12,11 @@ let test_string = "Hello"
let binary_test = <<test_string,',',32,"world!">>
let test_print_binary = puts(binary_test)
+;; binary comprehension test
+let rotate c = let cc = c+2 in if cc > 'z' then cc-26 else cc
+let cypher s = <<[rotate(i) for i in s]>>
+let test_cypher = puts(cypher("hello, world!"))
+
;; simple for loops
let to_3 = for i in 1 to 3 { puts("*"), 4 }
let downto_1 = for i in 3 downto 1 { puts("/"), Hello }
Please sign in to comment.
Something went wrong with that request. Please try again.