[wg-camlp4] On domain-specific foreign syntaxes

Alain Frisch alain.frisch at lexifi.com
Thu Jan 31 13:42:04 GMT 2013


On 01/31/2013 02:32 PM, Hongbo Zhang wrote:
> Would you mind elaborating a bit why it will complex editor support?

The content of a quotation can use arbitrary grammar and even arbitrary 
lexical rules.

If the editor cannot lex the content of the quotation, it cannot produce 
nice colors for lexical entities in it.  If emacs produce decent colors 
on some example with quotation, it is only because it does not know 
anything about quotation and the example is simple enough so that 
applying OCaml rules works quite well.  But if the content of the 
quotation follows other lexical rules, emacs gets confused. Write:

   let x = foo << " >> bar

and emacs will color ">> bar" as if it were a string.  The only decent 
think an editor could do with a quotation is to understand where it 
stops and not try to do anything clever with it.  If we adapt the OCaml 
emacs mode to recognize camlp4's quotation and do that, you won't get 
any colors within quotations (correct behavior, but not if you write 
non-trivial multi-line OCaml expressions in it, as in your 'sedlex' 
version).

Even if the lexical conventions are right, the editor cannot produce 
correct indentation if it doesn't know the grammar used inside the 
quotation.


Alain



More information about the wg-camlp4 mailing list