Re: Combining different rules in ocamllex
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
That works, thank you. I corrected the last two parts of my code as follows :
rule usual = parse
| '"' { quoted_string lexbuf;}
| _ as c {add_to_list (CHAR c); usual lexbuf}
| eof { List.rev(!list_accu) }
and quoted_string=parse
| "\\\"" {add_to_string '\''; quoted_string lexbuf}
| "\\\\" {add_to_string '\\'; quoted_string lexbuf}
| '"' {finish_quote(); usual lexbuf}
| _ as c {add_to_string c; quoted_string lexbuf}
|eof { List.rev(!list_accu)}
{
let parse_all s =
let _=(list_accu:=[];string_accu:="") in
usual (Lexing.from_string s)
}