<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2009/10/5d8af1da433fb68c732a6e6ec72601ca"
  from="Aaron Bohannon &lt;bohannon@c...&gt;"
  author="Aaron Bohannon"
  date="2009-10-08T14:39:53"
  subject="Re: [Caml-list] camlp5/revised syntax questions"
  prev="2009/10/f264a933b70853017a592acf45adc39f"
  next="2009/10/cc30b4a069b2db9ebf8f94287b328051"
  prev-in-thread="2009/10/074829c26a2d5bddcf9e6a023e1a9b4a"
  next-in-thread="2009/10/6fc25f4b77ba5ce29700dc5405925c02"
  prev-thread="2009/10/f4c2db533557676eb31a47d6e4761518"
  next-thread="2009/10/0e9c7e2ae6689422e1e9d874cd8f3816"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="camlp5/revised syntax questions">
<msg 
  url="2009/10/804fc006b1807f248f1f9646c35a70a0"
  from="Aaron Bohannon &lt;bohannon@c...&gt;"
  author="Aaron Bohannon"
  date="2009-10-07T16:20:10"
  subject="camlp5/revised syntax questions">
<msg 
  url="2009/10/074829c26a2d5bddcf9e6a023e1a9b4a"
  from="blue storm &lt;bluestorm.dylc@g...&gt;"
  author="blue storm"
  date="2009-10-07T20:16:39"
  subject="Re: [Caml-list] camlp5/revised syntax questions">
<msg 
  url="2009/10/5d8af1da433fb68c732a6e6ec72601ca"
  from="Aaron Bohannon &lt;bohannon@c...&gt;"
  author="Aaron Bohannon"
  date="2009-10-08T14:39:53"
  subject="Re: [Caml-list] camlp5/revised syntax questions">
<msg 
  url="2009/10/6fc25f4b77ba5ce29700dc5405925c02"
  from="blue storm &lt;bluestorm.dylc@g...&gt;"
  author="blue storm"
  date="2009-10-10T12:31:45"
  subject="Re: [Caml-list] camlp5/revised syntax questions">
<msg 
  url="2009/10/4ad3ab7d4dbfb154c1200f9e52f982fe"
  from="Aaron Bohannon &lt;bohannon@c...&gt;"
  author="Aaron Bohannon"
  date="2009-10-14T02:04:13"
  subject="Re: [Caml-list] camlp5/revised syntax questions">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
Thanks for your detailed reply.  I had a suspicion I would have to
read the source code to get the all of the necessary documentation.
However, I'm still missing some basic point here.

On Wed, Oct 7, 2009 at 4:16 PM, blue storm &lt;bluestorm.dylc@gmail.com&gt; wrote:
&gt; The different "level names" are not absolute among all camlp4 grammars
&gt; : they're a property of each grammar rule of each grammar. If you want
&gt; to "modify" a specific grammar (that is, EXTEND it), you must check
&gt; the different levels available in the definition.

Yes, I understand that.  But how do you specify which grammar your
file is extending?  My file is structured like this:

#load "pa_extend.cmo";
#load "q_MLast.cmo";
open Pcaml;

EXTEND
  GLOBAL: expr;
  ...
END;

So where did I specify whether I was extending the original syntax or
the revised syntax (or some other grammar entirely)?  I suppose I must
have implicitly chosen the original syntax because my code works fine
on that.

&gt; While concrete syntaxes for revised and classical syntax are
&gt; different, the abstract syntax tree is the same. Camlp4 quotations
&gt; works by replacing (using camlp4) the quotation you wrote by the
&gt; concrete ocaml AST representation.

Yes, this point is crystal clear, and I have no problem writing the
quotations in the revised syntax.

&gt; In your specific case, you can parse whatever syntax you want using
&gt; the "&lt;-" operator, then output the corresponding AST using a quotation
&gt; in the revised syntax, that is &lt;:expr&lt; a := b &gt;&gt; (instead of "a &lt;-
&gt; b"). For a reference, see the related rules in etc/pa_o.ml :
&gt;
&gt;  | ":=" NONA
&gt;    [ e1 = SELF; ":="; e2 = expr LEVEL "expr1" -&gt;
&gt;      &lt;:expr&lt; $e1$.val := $e2$ &gt;&gt;
&gt;    | e1 = SELF; "&lt;-"; e2 = expr LEVEL "expr1" -&gt;
&gt;      &lt;:expr&lt; $e1$ := $e2$ &gt;&gt; ]

Thanks, I found this piece of code.  Now on a more specific point, I
am confused about the parsing of record access and update:

1) In the parsing rule for the simple dot noation...

      | e1 = SELF; "."; e2 = SELF -&gt; &lt;:expr&lt; $e1$ . $e2$ &gt;&gt; ]

...why is the field label an "expr"?  This does not agree with the
OCaml manual, which has a separate syntactic category for "field"
(http://caml.inria.fr/pub/docs/manual-ocaml/expr.html), nor with my
intuition about the meaning of the code.

2) Furthermore, as one can see from the ":=" entry above, the entire
left side of a record update is parsed as its own subexpression.  So
this means, that in the context of a record update, that subexpression
has to be interpreted as a reference, but in other contexts, the very
same expression must be interpreted as a value.  I don't necessarily
care what kind of magic makes this possible on the back end, but I am
wondering whether this has any implications for modifying the record
syntax.

 - Aaron

</contents>

</message>

