Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] camlp4 and syntax modifications
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Frederic Tronel <Frederic.Tronel@i...>
Subject: [Caml-list] camlp4 and syntax modifications
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