Where can I read up on the syntax of the following in a camlp4
stream parser?
| [<' INT n >] -> Int n
For example, where are [< ... >] described and why is the ' needed
in between?
To be more precise, I'm using camlp4 to parse a language into a non-
OCaml AST.
I'm trying to figure out the meaning of [<, >], [[ and ]]
My ocamllex lexer is wrapped to make it look like a stream lexer
(below) and I'm returning a tuple of (tok, loc) because I don't see
another way of making token location available to the parser.
Still, I'm how to integrate the reporting of error location into ?? in
something like this
| [< 'Token.Kwd '('; e=parse_expr; 'Token.Kwd ')' ?? "expected ')'"
>] -> e
Would someone kindly shed light on this?
Thanks in advance, Joel
P.S. ocamllex wrapper to return a' Stream.t
{
let from_lexbuf tab lb =
let next _ =
let tok = token tab lb in
let loc = Loc.of_lexbuf lb in
Some (tok, loc)
in Stream.from next
let setup_loc lb loc =
let start_pos = Loc.start_pos loc in
lb.lex_abs_pos <- start_pos.pos_cnum;
lb.lex_curr_p <- start_pos
let from_string loc tab str =
let lb = Lexing.from_string str in
setup_loc lb loc;
from_lexbuf tab lb
}
---
http://tinyco.de
Mac, C++, OCaml
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs