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=1.2 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id F2E2EBC69 for ; Tue, 27 Mar 2007 16:06:32 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.230]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2RE6WNO028079 for ; Tue, 27 Mar 2007 16:06:32 +0200 Received: by nz-out-0506.google.com with SMTP id r28so1958917nza for ; Tue, 27 Mar 2007 07:06:31 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HIqxV2UavoL4MXgbX0EAEfTVyP1eBn4Fitc/Vl/NoMnGMq2Cn80qglGgoS+HXBKDKWKg2/6papAjATG1o5LRuYZ2MgJmLGAo+jsBodRsTcJtnRIvApFdrmqXlG347YgZOIQnYaFVsTwrUeXcVeYbshjLF/3M2LcZSbpzn5GVJSM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=TA8xPPaPIR+l3/8DpAnVJnL9mnaSlHnfnl6jYCu3q5F5RlEglMjam19zKyZVW2vSlmmvAXRbaO4pWEZxua25WMHm1nWVcYjWkjIdmEA8kNLUIO0P2ceGs9BEUfW/+3Q9KO/HVjAIYP7E03JQReBeGQ5k9iIJ2n4gcJoluHCGJ24= Received: by 10.114.12.9 with SMTP id 9mr3161734wal.1175004391387; Tue, 27 Mar 2007 07:06:31 -0700 (PDT) Received: by 10.114.183.4 with HTTP; Tue, 27 Mar 2007 07:06:31 -0700 (PDT) Message-ID: Date: Tue, 27 Mar 2007 16:06:31 +0200 From: "Nicolas Pouillard" To: "Loup Vaillant" Subject: Re: [Caml-list] Misunderstandings about the AST Cc: caml-list@yquem.inria.fr In-Reply-To: <6f9f8f4a0703270644r52490af8ieeedb8f474b95f8e@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6f9f8f4a0703270644r52490af8ieeedb8f474b95f8e@mail.gmail.com> X-j-chkmail-Score: MSGID : 460924E8.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 460924E8.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; syntax:01 ocaml:01 ocaml-:01 parsing:01 parsetree:01 mli:01 constructors:01 desc:01 pexp:01 pexp:01 longident:01 bool:01 parser:01 camlp:01 arity:01 On 3/27/07, Loup Vaillant wrote: > Good afternoon, > > Pursuing my goal of making a lisp syntax for Ocaml, I began to take a > close look at the AST (Ocaml-3.09.3/parsing/parsetree.mli). I don't > understand some of the constructors in the type expression_desc: > > > | Pexp_function of label * expression option * (pattern * expression) list > What is the "expression option" for? The default value for labeled arguments << fun ?(label=default_value) -> ... >> > | Pexp_construct of Longident.t * expression option * bool > > What is the boolean for? Ha, ha... Is one is more tricky this it seems not produced by the parser (my main source of inspiration for this mail). In fact it's use by camlp4, and it means that you know that the arity is good. When you write: A(x, y) how to know if it's 2 args for A or 1 arg but a pair. If you directly produce AST nodes and that you know want you do you can set this flag to true. > | Pexp_variant of label * expression option > > What is a "variant"? (Does not seem to be related to variant types, as > "Pexp_construct" is used for them) It's for polymorphic variants, checkout the documentation... > | Pexp_record of (Longident.t * expression) list * expression option > What is the "expression option" for? { (expression) with field1 = expr1; ... ; fieldN = exprN } > | Pexp_constraint of expression * core_type option * core_type option > Why two "core_type option", instead of just a "core_type"? Since there is 3 type of constraints. (e : t) (e :> t) (e : t1 :> t2) > | Pexp_when of expression * expression > Why not "pattern * expression"? The `when' form is: pattern when expr1 -> expr2 expr1 and expr2 are paired with Pexp_when > | Pexp_send of expression * string > What does "Pexp_send" stand for? Method call. object_value#method_name > | Pexp_new of Longident.t > What does "Pexp_new" stand for? new class_name > | Pexp_setinstvar of string * expression > What does "Pexp_setinstvar" stand for? object_value.instance_variable <- expr > | Pexp_override of (string * expression) list > What does "Pexp_override" stand for? {< instvar1 = expr1 ; ... ; instvarN = exprN >} Same as { expr with ... } but for objects and automatically on self. > | Pexp_lazy of expression > Why does this constructor even exist? Are some specific optimizations made? Since the evaluation of the expression is delayed it's not a plain function. > | Pexp_poly of expression * core_type option > What does "Pexp_poly" stand for? It's for methods with polymorphic types, some syntax nodes are inserted to keep track of this polymorphism. Regards, -- Nicolas Pouillard