我想要編譯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