From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 00DEDBBC4 for ; Sat, 7 Mar 2009 23:54:56 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak8CAE6KsknRVduukWdsb2JhbACUYz8BAQEBCQkMBw+tLIEHjwoBAwEDhAIGgxQ X-IronPort-AV: E=Sophos;i="4.38,320,1233529200"; d="scan'208";a="36234701" Received: from mail-ew0-f174.google.com ([209.85.219.174]) by mail4-smtp-sop.national.inria.fr with ESMTP; 07 Mar 2009 23:54:56 +0100 Received: by ewy22 with SMTP id 22so602337ewy.27 for ; Sat, 07 Mar 2009 14:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=NUr9PpihxlDcoT1+ytWQx//gnP1yzjfkaUYX2wmvz3o=; b=DeljPtbq/f3TMurYVar+T5l7BHjQ74gjlN9vBKkokSN4O8i2GoGmn2WZvgldovzsRK /njEUfZdIV/EDFKNm+wjhTNfF16cnTfN83SsG0rjphA5L/Hehm+ryn34l1S7+FBwD2yD OIiIDuas1kH0hG4sUecvyzAznG3oLrnXkh6Lw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=dYHoOI/ghnp0gCTYet++gXftw7ruloP5aZXUuE6SpaR4fzhFZmpo17UAqiz7PxRuJo FEANi78Z1gVyIWUfH4HbQwRVTXBsF7eXvK6/0f94xTUmeKRbH+5Xq8HIbi6W6UTEEl7z OX9pPWlP0TsI2ltuK1M/OgvilFP0weL2roKvE= Received: by 10.210.92.11 with SMTP id p11mr2276209ebb.2.1236466496241; Sat, 07 Mar 2009 14:54:56 -0800 (PST) Received: from ?10.10.30.5? (94.Red-88-6-143.staticIP.rima-tde.net [88.6.143.94]) by mx.google.com with ESMTPS id 5sm2745823eyh.11.2009.03.07.14.54.55 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 07 Mar 2009 14:54:55 -0800 (PST) Message-Id: <24D11586-4F15-4B6E-8FB7-58651317164D@gmail.com> From: Joel Reymont To: O'Caml Mailing List In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: camlp4 stream parser syntax Date: Sat, 7 Mar 2009 22:52:52 +0000 References: X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; camlp:01 parser:01 syntax:01 syntax:01 camlp:01 parser:01 ocaml:01 ocamllex:01 lexer:01 lexer:01 kwd:01 expr:01 kwd:01 ocamllex:01 lexbuf:01 > 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