caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: cilibrar@gmail.com
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Request for hint/help in camlp4/5-ppx conversion of famous logic quotation code by Harrison
Date: Sun, 4 Nov 2018 19:00:54 +0100	[thread overview]
Message-ID: <CAPFanBEG8vnFVb7buZw0o3xd5GqeW9XrZPzyJ+h9n9+1RkKRBw@mail.gmail.com> (raw)
In-Reply-To: <CABvMw3bYyJYOxJAYQBANMgVqMa+XYkW3pOQ-2MXA5ZF4czBV-w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3574 bytes --]

It looks like what this syntax extension is doing is to rewrite fragments
of the form

  <<foo>>

into

  default_parser "foo"

and

  <<|foo|>>

into

  secondary_parser "foo".

You should be able to translate examples from the book simply by doing this
rewriting by hand. If the string/formula contains backslashes, it can be
painful to properly escape them to follow the lexical conventions of OCaml
double-quoted string literals, but you can use the new string literal
{|foo|} to avoid escapes. For example, "a\\b" can be rewritten into {|a\b|}.


On Sun, Nov 4, 2018 at 6:42 PM Rudi Cilibrasi <cilibrar@gmail.com> wrote:

> Greetings ML friends,
>
> I have been gradually following the ML style languages a couple decades
> with HOL/SML etc and recently got interested in the OCaml variation.
>
> I've been able to make simple OCaml programs for my research but am
> hitting a steep learning curve trying to understand the differences
> between the preprocessors camlp4, camlp5, and ppx. The documentation
> is confusing to me at this point.
>
> I have been trying to compile the code from the famous and great book
> on logic called "Handbook of Practical Logic and Automated Reasoning"
> but it does not work for me under Ubuntu 18.04 using OCaml 4.05. I
> have opam 1.2.2.  I am getting an "Unbound module Quotation" error
> that Icannot solve and I suspect is related to old coding convention
> for preprocessing.  Would anybody on the list be able to help me (perhaps
> privately via email/github) to convert this small fragment to modern
> PPX syntax so that we can "unlock" the rest of the code describing first
> order logic?  I attach a transcript below trying to compile one of many
> copies of the same code on github, this one from
>
> https://github.com/logic-tools/sml-handbook/tree/master/code/OCaml
>
> Any help or info you can provide to get unblocked would be appreciated.
> Thank you in advance for your kind attention.
>
> Best regards,
>
> Rudi
>
> ----------------------------------------------------------------------------------------
> ➜  sml-handbook git:(master) ✗ cd code/OCaml
> ➜  OCaml git:(master) ✗ make
> echo '#use "init.ml";;' >.ocamlinit; (sleep 3s; rm -f .ocamlinit) & ocaml
>         OCaml version 4.05.0
>
> File "Quotexpander.ml", line 2, characters 5-72:
> Warning 3: deprecated: Pervasives.&
> Use (&&) instead.
> File "Quotexpander.ml", line 7, characters 0-13:
> Error: Unbound module Quotation
> File "Quotexpander.ml", line 998, characters 7-9:
> Unbound quotation: ""
> Camlp5 parsing version 7.06
>
> #
> ➜  OCaml git:(master) ✗ cat Quotexpander.ml
> let quotexpander s =
>   if String.sub s 0 1 = "|" & String.sub s (String.length s - 1) 1 = "|"
> then
>     "secondary_parser \""^
>     (String.escaped (String.sub s 1 (String.length s - 2)))^"\""
>   else "default_parser \""^(String.escaped s)^"\"";;
>
> Quotation.add "" (Quotation.ExStr (fun x -> quotexpander));;
> ➜  OCaml git:(master) ✗ ocaml --version
> The OCaml toplevel, version 4.05.0
> ➜  OCaml git:(master) ✗ opam --version
> 1.2.2
> ➜  OCaml git:(master) ✗
>
>
> --
> Happy to Code with Integrity : Software Engineering Code of Ethics and
> Professional Practice <http://www.acm.org/about/about/se-code>
>

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list https://inbox.ocaml.org/caml-list
Forum: https://discuss.ocaml.org/
Bug reports: http://caml.inria.fr/bin/caml-bugs

[-- Attachment #2: Type: text/html, Size: 4936 bytes --]

  reply	other threads:[~2018-11-04 17:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-04 17:41 Rudi Cilibrasi
2018-11-04 18:00 ` Gabriel Scherer [this message]
2018-11-04 18:06   ` Gabriel Scherer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPFanBEG8vnFVb7buZw0o3xd5GqeW9XrZPzyJ+h9n9+1RkKRBw@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=cilibrar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).