Browse thread
ocamlbuild: args to tags?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] ocamlbuild: args to tags? |
On Mon, 2007-09-24 at 17:23 +0200, Nicolas Pouillard wrote: > > (* My Ocaml File .. *) > > (*#Syntax Mycamlp4syn *) (* for compatibility *) > > #syntax Mycamlp4syn; (* better *) > > This sounds like a good idea. That's not a new one and it was our first > choice when designing ocamlbuild. However after some reflections we decided > that one can first do _tags method and then provide a way to read tags from > the file itself. There's slight difference in view as expressed here. I wouldn't suggested arbitrary "tags" or hints be first class syntax (although one might put them in comments). I'm not against tags annotations.. I'm suggesting the specification of the syntax extension doesn't belong on the command line, or in a tags file, it belongs in the file. > The main problem with the solution with embedded tags is that one must at > least define a how to read these annotations. This is not that easy since a > .ml file can be a pre-processed file with a totally different syntax. No, this should not be allowed: that's my point. Every Ocaml file uses THE syntax for either *.mli or *.ml, end of story. If it uses some other language, it should have a different extension. However the syntax can be extensible, but the extensions must be at least loaded, if not defined, IN the file. Felix does this. It uses Dypgen GLR parser and OCS Scheme to implement it. You have to say: open syntax felix; or you can't parse anything except syntax extensions :) The whole of the language proper (except nonterminals mapped to terminals such as literals) is specified by a dynamically specified grammar. In Felix, you can extend the grammar 'anywhere', the extensions are properly scoped. So actually, there's no problem designing a syntax which allows loading another syntax, that is, a bootstrap syntax. For Ocaml, you could easily add a directive open syntax Mysyntax or #syntax Mysyntax to the standard grammar, and make camlp4 parse it and use it to load syntax extensions. Running camlp4 so this happens should be the mandatory, no -pp command stuff: camlp4 IS the Ocaml parser. Then, when you run, say, ocamldoc, it knows which extensions to load, as does the human reader. It's just the same as let (@) f g x = f (g x) The "syntax extension" of the user defined operator @ for composition is defined IN the program. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net