Version française
Home     About     Download     Resources     Contact us    
Browse thread
quotations inside comments?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Allsopp <dra-news@m...>
Subject: RE: [Caml-list] quotations inside comments?
> Hi,
> 
> why does camlp4 parse quotations inside comments? Eg

I don't know for certain, but I guess it might be for the same reason as the compiler which checks string literals (amongst other things) inside comments e.g.

(* This will not compile " *)

File "foo.ml", line 1, characters 0-2:
Error: This comment contains an unterminated string literal

The compiler does this to ensure that you can consistently nest comments (i.e. that commenting out a block actually comments the entire block out), without it you could write:

(*
let foo = "*)" in ()
*)

which wouldn't behave as you'd expect (and the syntax error could be a lot further down the file!) 


David

> 
>     echo "(* << *)" | camlp4o -impl -
> 
> gives
> 
>     File "-", line 1, characters 3-9 (end at line 2, character 0):
>     Quotation not terminated
> 
> Quotation parsing/lexing seems to be controlled by context.quotations. How
> can I switch this off?
> 
> Wouldn't it make more sense to have quotations and antiquotation
> parsing/lexing switched off in freshly created parsers/lexers and switch
> them only on when a syntax extension with quotations is installed (eg,
> inside Camlp4QuotationCommon.Make)?
> 
> Bye,
> 
> Hendrik
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs