All pastes #509893 Raw Edit

Something

public text v1 · immutable
·published 2007-05-25 18:01 UTC
rendered paste body
# #load "camlp4o.cma";;
	Camlp4 Parsing version 3.10.0

# let process_line line =
  let rec parse_line s =
    match s with parser
      [< 'Genlex.Kwd "*" ; l >] -> " " ^ (parse_line l)
    | [< 'Genlex.Kwd "'" ; l >] -> "'" ^ (parse_line l)
    | [< 'Genlex.Kwd "." ; l >] -> "." ^ (parse_line l)
    | [< 'Genlex.Kwd "," ; l >] -> "," ^ (parse_line l)
    | [< 'Genlex.Kwd "-" ; l >] -> "-" ^ (parse_line l)
    | [< 'Genlex.Ident s ; l >] -> ((* Spell.dico *) s) ^ (parse_line l)
    | [<>] -> ""
  and lexer = Genlex.make_lexer ["*"; "'"; "."; ","; "-"]
  and replace s char_to_change char_to_use =
    for i = 0 to ((String.length s) - 1) do
      if s.[i] = char_to_change then
	s.[i] <- char_to_use
    done;
    s
  in
  let line = replace line ' ' '*' in
    parse_line (lexer (Stream.of_string line));;
                                      val process_line : string -> string = <fun>

-----

$ocamlc camlp4o.cma -c page.ml
File "page.ml", line 47, characters 6-8:
Syntax error
zsh: exit 2     ocamlc camlp4o.cma -c page.ml