Guest User

Untitled

a guest
Oct 22nd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. open Printf;;
  2. open Stream;;
  3. type sign =
  4. Plus
  5. | Minus;;
  6.  
  7. type atom =
  8.  
  9. T
  10. | NIL
  11. | Int of int
  12. | Ident of string;;
  13.  
  14. type token =
  15.  
  16. Lparen
  17. | Rparen
  18. | Dot
  19. | Sign of sign
  20. | Atom of atom;;
  21. Stream.t char s from "lines.txt";;
  22. let rec spaces s=
  23.  
  24. match s with parser
  25. [< '' '|' 't' | 'n' ; _ >] -> spaces s (* ERROR HERE ON '[<' *)
  26. | [< >] -> ()
  27.  
  28. ;;
  29.  
  30. let rec lexid str s =
  31.  
  32. match s with parser
  33.  
  34. [< ' 'a'..'z'| 'A'....'Z'| '0'...'9' as c; _ >] -> lexid (str ^ (Char.escaped c)) s
  35.  
  36. | [< >] -> str;;
  37. let rec lexint v s=
  38. match s with parser
  39. [< ‘’0’..’9’ as n; _ >] -> lexint ((10*v)+(int_of_string(Char.escaped n))) s
  40. | [< >] -> v
  41. ;;
Add Comment
Please, Sign In to add comment