Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Lexing
- let lb_chan = from_channel stdin
- let lb_str = from_string "\nEND OF INPUT\n"
- let lexbuf =
- { lb_chan with refill_buff =
- let in_string = ref false in
- fun lb ->
- if !in_string then lb_str.refill_buff lb
- else begin
- lb_chan.refill_buff lb;
- if lb.lex_eof_reached
- then begin
- in_string := true;
- lb.lex_buffer <- lb_str.lex_buffer;
- lb.lex_buffer_len <- lb_str.lex_buffer_len;
- lb.lex_abs_pos <- lb_str.lex_abs_pos;
- lb.lex_start_pos <- lb_str.lex_start_pos;
- lb.lex_curr_pos <- lb_str.lex_curr_pos;
- lb.lex_last_pos <- lb_str.lex_last_pos;
- lb.lex_last_action <- lb_str.lex_last_action;
- lb.lex_eof_reached <- lb_str.lex_eof_reached;
- lb.lex_mem <- lb_str.lex_mem;
- lb.lex_start_p <- lb_str.lex_start_p;
- lb.lex_curr_p <- lb_str.lex_curr_p;
- lb_str.refill_buff lb
- end
- end
- }
- let rec read () =
- lexbuf.refill_buff lexbuf;
- print_string lexbuf.lex_buffer;
- if lexbuf.lex_eof_reached then print_string "\nDone reading.\n"
- else read ()
- let () = read ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement