Guest User

Untitled

a guest
Nov 8th, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. open Buffer
  2. type scanning = InputVarName | InputRest;;
  3. let testcharsq x = match x with
  4. | 'A'..'Z' | 'a'..'z' -> true
  5. | _ -> false;;
  6. (* We're getting a string. *)
  7. let process x =
  8. let s = ref InputRest in
  9. let r = Buffer.create 100 in
  10. for i = 0 to (String.length(x)-1) do
  11. if x.[i] = '$' then s := InputVarName;
  12. if !s = InputRest then add_char r x.[i];
  13. if !s = InputVarName and testcharsq x.[i] then
  14.  
  15. ();
  16. done;
  17. contents r;;
  18.  
  19.  
  20. open Printf;;
  21. printf "%s" (process "abc$or");;
  22. ---
  23. File "p.ml", line 13, characters 24-27:
  24. Error: Syntax error
Advertisement
Add Comment
Please, Sign In to add comment