let of_lexbuf = fun lexbuf ->
  let state = ref TmplLexer.LexText in
    try
      TmplLexer.line := 0;
      TmplParser.main (TmplLexer.lex state) lexbuf
    with
      | TmplLexer.Lex_error -> raise Parsing.Parse_error