caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] camlp4 and syntax modifications
@ 2002-04-03  8:49 Frederic Tronel
  2002-04-03  9:21 ` Daniel de Rauglaudre
  0 siblings, 1 reply; 4+ messages in thread
From: Frederic Tronel @ 2002-04-03  8:49 UTC (permalink / raw)
  To: caml-list

Hello,

I'm using camlp4 to embed a specification language (Lotos)
into caml. I've written quotations that allow to write and
use Lotos expressions directly in my caml code. But I'm facing
a problem with what appears to be slight syntax changes. Here's
an example:

open Lotos (* grammar extension for lotos *)

let _ =
  let send f t e = <:sync<SEND ^(Send f) ^(Send t) ^(Send e) >> 
  in
  let p = <:process<process Toto [SEND,RECV] () noexit := 
    hide SEND in ((G ; STOP) |[SEND]| (STOP)) [> (Toto [SEND,RECV] ())
    where
	process Titi [] () noexit := STOP endproc
      endproc
    >>
  in
  let s = <:spec<specification toto [SEND,RECV] () : exit(NAT)
      behavior 
      $(send "A" "B" "C") ; [LENGTH L eq 10] -> STOP [] [not(false and
true)] -> STOP
      where
      ^(p)>>
  in 
  Printf.fprintf stdout "%s\n" (dump_spec s 0) 

Does compile smoothly (${OCAMLC} -pp "${CAMLP4O} ./lotos.cmo" -I +camlp4
-c test_embedded_lotos.ml)

However if I add a "for" control structure in my code, like:

open Lotos

let _ =
  let send f t e = <:sync<SEND ^(Send f) ^(Send t) ^(Send e) >> 
  in
  let p = <:process<process Toto [SEND,RECV] () noexit := 
    hide SEND in ((G ; STOP) |[SEND]| (STOP)) [> (Toto [SEND,RECV] ())
    where
	process Titi [] () noexit := STOP endproc
      endproc
    >>
  in
  let s = <:spec<specification toto [SEND,RECV] () : exit(NAT)
      behavior 
      $(send "A" "B" "C") ; [LENGTH L eq 10] -> STOP [] [not(false and
true)] -> STOP
      where
      ^(p)>>
  in 
  for i = 0 to 10 do () done;
  Printf.fprintf stdout "%s\n" (dump_spec s 0) 
 
which is perfectly legal according to the original caml syntax, it does
not compile.
/users/tronel/bin/ocamlc -pp "/users/tronel/bin/camlp4o ./lotos.cmo" -I
+camlp4 -c test_embedded_lotos.ml
File "test_embedded_lotos.ml", line 18, characters 5-7:
Parse error: [expr level top] expected after 'in' (in [expr])
Preprocessing error
*** Error code 2

I'm intentionally using the original syntax (camlp4o) since I've a bunch
of code already
written that I don't want to translate to the revised syntax.
What is the correct syntax to use ??? 

Regards,

Frederic Tronel.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-04-05 14:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-03  8:49 [Caml-list] camlp4 and syntax modifications Frederic Tronel
2002-04-03  9:21 ` Daniel de Rauglaudre
2002-04-03 10:45   ` [Caml-list] binaire advi pour windows Christophe Raffalli
2002-04-05 14:41     ` Sven

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).