我想要编译Libra toolkit运行Ubuntu哈代与OCaml的3.10的机器上之前NEW_LINE等价,我不能升级操作系统,也没有更新OCaml的,我不知道OCaml的事情。只有一条线,让我一个绑定值错误,因为它使用的NEW_LINE功能,这是在ocaml的3.11(http://caml.inria.fr/pub/docs/manual-ocaml/libref/Lexing.html)介绍,有人能告诉我如何改变它与OCaml的3.10兼容?它的邻近该代码的末尾行:OCaml的:3.11
{
open MnParseTypes;;
open MnParser;;
(* Raised when parsing ends *)
exception Eof;;
module L = Lexing
let linenum lexbuf = lexbuf.L.lex_curr_p.L.pos_lnum
let line = ref 1;;
let keywords = Hashtbl.create 10
let _ =
List.iter2 (Hashtbl.add keywords)
["mn"; "features"; "tree"; "table"; "w"; "eof"]
[Tmn; Tfeatures; Ttree; Ttable; Tweight; EOF];;
}
let digits = ['0'-'9']+
let identifier = ['a'-'z' 'A'-'Z']+
rule lexer = parse
(* eat blank characters *)
[' ' '\t'] {lexer lexbuf}
(* | "Feature list:" {lexer lexbuf} *)
| '{' {Tlbrace}
| '}' {Trbrace}
| '(' {Tlparen}
| ')' {Trparen}
| ('-')? "inf" {Tfloat(float_of_string(L.lexeme lexbuf))}
| identifier {
let x = String.lowercase (Lexing.lexeme lexbuf) in
try Hashtbl.find keywords x
with Not_found ->
failwith((Lexing.lexeme lexbuf)
^": unknown identifier on line "^string_of_int (linenum lexbuf))}
| digits {Tint (int_of_string (L.lexeme lexbuf))}
| ('-')? digits ('.' digits)? (['e' 'E'] ['+' '-']? digits)?
{Tfloat(float_of_string(L.lexeme lexbuf))}
| '+' 'v' (digits as var) '_' (digits as value)
{Tcond(true, int_of_string var, int_of_string value)}
| '-' 'v' (digits as var) '_' (digits as value)
{Tcond(false, int_of_string var, int_of_string value)}
| 'v' (digits as var) '_' (digits as value)
{Tvar(int_of_string var, int_of_string value)}
| ['\n' '\r']+ {L.new_line lexbuf; TEOL} (* THIS GIVES THE ERROR *)
| eof {EOF}
| _ {failwith((L.lexeme lexbuf)^
": mistake on line "^string_of_int lexbuf.L.lex_curr_p.L.pos_lnum)}
这将帮助,它实际上是说我想要做什么的功能,但我不知道如何将它插入我的代码:http://caml.inria.fr/mantis/view.php?id=3930 – user2059990 2013-05-12 03:41:33
我试图使用这样的:在 '(*让start_next_line lexbuf =()*) 让start_next_line lexbuf = 让LCP = lexbuf.lex_curr_p lexbuf.lex_curr_p < - { LCP与 pos_lnum = lcp.pos_lnum + 1 ; pos_bol = lcp.pos_cnum;} }'然后'| ['\ n''\ r'] + {start_next_line lexbuf; TEOL}'但是我得到错误**致命错误:异常Data.Eof **有时候 – user2059990 2013-05-12 04:04:39
如果相关,你应该在你的问题体中包含这些错误。 – didierc 2013-05-12 08:18:18