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